Skip to content

fix(context): remove redundant allocation and document analyzer proof - #1196

Merged
unbraind merged 2 commits into
mainfrom
fix/context-usage-array-allocation
Sep 5, 2026
Merged

fix(context): remove redundant allocation and document analyzer proof#1196
unbraind merged 2 commits into
mainfrom
fix/context-usage-array-allocation

Conversation

@unbraind

@unbraind unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner

The release analyzer gate rejected the context-usage row accumulator because CodeFactor reported an unnecessary outer array spread, even though its PR check conclusion was successful. Use the conditional array directly and preserve all delivered-identity traversal behavior.

Tracked under pm-08mt4k, with the original release refusal, correction, linked verification, and structured closure recorded through PM. The agent guide now documents the review helper, complete feedback inventory, and mandatory exact-head zero-annotation analyzer proof before merge. This completes release readiness for #1195. The changelog is generated by the latest pm-changelog package.

Validation: 44 existing context packing, final-egress, relevance and execution-role tests; full repository ESLint; build, docs/skills and record-integrity assurance. The exact-head hosted-analysis gate must explicitly confirm zero outstanding CodeFactor annotations before merge; a successful check conclusion alone is insufficient. Hosted coverage and all required CI gates remain mandatory.

Use the conditional array directly as the mutable row accumulator instead of
copying it immediately through an outer array spread. Preserve recommendation,
gate, container, blocker and unblock identity collection.

CodeFactor returned a successful PR check with a no-useless-spread notice; the
stricter release analyzer gate correctly refused that outstanding annotation.
Record the escape and correction under the existing execution-role PM owner,
and require exact-head hosted analyzer proof before merging this correction.

Validation: 44 existing context packing, egress, relevance and execution-role
tests pass, repository ESLint passes, record-integrity passes, and the changelog
is generated through pm-changelog.

PM: pm-08mt4k.
@sourcery-ai

sourcery-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes an unnecessary array spread in context-usage row accumulation by using the conditional array directly, without changing delivered-identity traversal. It also updates PM records and generated changelog metadata; review should confirm the required 44 tests, lint, build, record-integrity checks, hosted coverage, and exact-head CodeFactor annotation gate.

File-Level Changes

Change Details Files
Eliminate the redundant outer array spread while preserving delivered-result traversal behavior.
  • Use the conditional expression directly to initialize the recommended-row accumulator.
  • Continue appending rows from all existing result categories and traversing delivered identities unchanged.
src/sdk/context-usage.ts
Update PM tracking and generated release metadata for the completed correction.
  • Record the release refusal, correction, verification, and closure in PM extension state and history.
  • Regenerate changelog ordering to include the tracked fix.
.agents/pm/extensions/.managed-extensions.json
.agents/pm/history/pm-08mt4k.jsonl
.agents/pm/issues/pm-08mt4k.toon
CHANGELOG.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Team

Run ID: 59e31ec2-ed55-406b-ab45-0053c816aea9

📥 Commits

Reviewing files that changed from the base of the PR and between 22a7a1a and f729327.

📒 Files selected for processing (6)
  • .agents/pm/extensions/.managed-extensions.json
  • .agents/pm/history/pm-08mt4k.jsonl
  • .agents/pm/issues/pm-08mt4k.toon
  • CHANGELOG.md
  • docs/AGENT_GUIDE.md
  • src/sdk/context-usage.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Documentation

    • Added guidance for pre-merge review workflows, analyzer verification, and disposition of findings.
  • Refactor

    • Simplified internal result collection without changing output behavior.
  • Chores

    • Updated release metadata and project records.
    • Refined the unreleased changelog entry order.
    • Added validation coverage and completed analyzer checks with no outstanding findings.
  • End-User Impact

    • No changes to public features or application behavior.

Walkthrough

The PR removes a redundant array spread from context result collection, records regression and analyzer verification, adds exact-head review guidance, updates issue history, refreshes metadata, and reorders two changelog entries.

Changes

Context correction and verification

Layer / File(s) Summary
Context allocation correction and regression records
src/sdk/context-usage.ts, .agents/pm/history/pm-08mt4k.jsonl, .agents/pm/issues/pm-08mt4k.toon
collectNextResultItemIds assigns the conditional array directly. Issue records include context, egress, execution-role, and hosted analyzer verification.
Exact-head review and analyzer proof
docs/AGENT_GUIDE.md, .agents/pm/history/pm-08mt4k.jsonl, .agents/pm/issues/pm-08mt4k.toon
The guide documents review-loop and hosted-analysis commands, exact-head receipts, finding acknowledgement, and analyzer requirements. Project records document the lifecycle and verification results.
Release metadata updates
.agents/pm/extensions/.managed-extensions.json, CHANGELOG.md
The managed-extension timestamp is refreshed. Two Unreleased changelog entries are reordered without content changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🟡 Moderate · up to f7293

The allocation simplification preserves the resulting rows, but the required static validation has not reached a confirmed terminal successful state for the current revision. Merge should wait for that result to avoid releasing without the required analyzer proof.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (5 skipped: 5 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary code change and the related analyzer-proof documentation. It is concise and specific.
Description check ✅ Passed The description directly explains the redundant allocation fix, preserved behavior, analyzer requirements, tracked issue, and validation performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

@greptileai
@coderabbitai full review
@sourcery-ai review

Please review the correction to the redundant array allocation and its PM evidence. The previous green CodeFactor check had one notice, which the stricter release analyzer gate correctly rejected. No quality threshold or behavior has been weakened; existing context-use and final-egress tests pass.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

@unbraind I will perform a full review of #1196. I will check the allocation correction, delivered-identity traversal, PM evidence, and available quality-gate evidence.

⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 25 minutes.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="CHANGELOG.md" line_range="7" />
<code_context>
 ### Fixed

-- Windows published-release verifier test can preempt its own readiness and cleanup contract ([pm-euqm7x](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-euqm7x.toon))
 - pm next recommends outcome-milestone gates as actionable work, and summary.containers counts a bucket the envelope never emits ([pm-08mt4k](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-08mt4k.toon))
+- Windows published-release verifier test can preempt its own readiness and cleanup contract ([pm-euqm7x](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-euqm7x.toon))
 - Commander usage refusals omit token_accounting even when --token-accounting is parsed ([pm-bfa1ob](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-bfa1ob.toon))
</code_context>
<issue_to_address>
**nitpick:** The changelog change removes the `pm-08mt4k` release-note entry without adding it elsewhere in the shown diff, so the completed context-usage fix is omitted from the generated release notes.

**Suggested fix:** Retain the `pm-08mt4k` entry in the appropriate changelog section and correct only its ordering or formatting.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread CHANGELOG.md
@codspeed-hq

codspeed-hq Bot commented Sep 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing fix/context-usage-array-allocation (f729327) with main (22a7a1a)

Open in CodSpeed

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

The guide correctly scopes the allocation correction and the separate zero-annotation release proof. All required hosted checks pass, and hosted-analysis-gate confirms exact_commit evidence with CodeFactor outstanding_annotations=0 and DeepScan new_issues=0.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Read the explicit free OSS quota notice. This is not a completed review; the full review will be requested after the stated reset around 07:21 UTC. Other required checks and exact-head analyzer proof have passed.

Read the completed full review on f729327: no code or documentation findings. The watcher has now completed successfully, including Gates (static), which was still running when the bot checked. The refreshed exact-head hosted-analysis gate confirms zero CodeFactor annotations, zero new DeepScan issues and strict branch protection. The diff-level private-function docstring heuristic is separate from the repository-defined source/export documentation gate, which passed.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

The action-not-completed section reports the free review cooldown. The corrected head now has zero outstanding CodeFactor annotations and no new DeepScan issues. I will request the full review again after included capacity resets.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Read the exact-head result for 3e949c1: the 11 tracked benchmarks are unchanged. This claim is limited to those benchmark cases.

Read the updated f729327 report: all 11 tracked benchmarks remain unchanged. The result is scoped to those measured cases.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Read the coverage result on 3e949c1: all modified coverable lines and all tests passed. The mandatory hosted full-coverage gate also completed successfully.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

The review approval is noted, but its sole proposed correction is false. The pm-08mt4k changelog entry is an unchanged context line at line 7; only the Windows entry moves below it after canonical package regeneration. Both entries remain exactly once, and the generated check passes. The direct inline response provides that evidence.

Document the repository review helper, terminal check receipts, complete
comment inventory and explicit full-SHA hosted analyzer gate in the agent
guide. Explain that a successful CodeFactor check can retain notices and that
only the stricter zero-annotation proof establishes release eligibility.

Record the verified correction and reusable workflow under pm-08mt4k, keeping
reviewer quota limitations separate from approvals and preserving explicit
dispositions for false or stale feedback.

Validation: build, docs/skills and link/content checks, record integrity, and
package-generated changelog. Runtime remains identical to 3e949c1, whose
full hosted checks and exact-commit analyzer proof passed.

PM: pm-08mt4k.
@unbraind unbraind changed the title fix(context): avoid redundant delivered-row array allocation fix(context): remove redundant allocation and document analyzer proof Sep 5, 2026
@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

@greptileai
@coderabbitai full review
@sourcery-ai review

The free-review reset has elapsed. Please review final head f729327, which combines the redundant-array correction with the documented review-helper and exact-head analyzer-proof sequence. The runtime is identical to 3e949c1, whose full hosted checks and strict analyzer proof passed with zero CodeFactor annotations and zero new DeepScan issues. The subsequent guide and PM evidence update passed local build, docs/skills and record-integrity checks. The earlier changelog observation was a diff-reading error: pm-08mt4k remains at line 7 and only the Windows entry moves below it.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== PR metadata =='
gh pr view 1196 --repo unbraind/pm-cli --json number,title,baseRefOid,headRefOid,files,commits,statusCheckRollup,reviews,comments

echo '== Changed files =='
gh pr diff 1196 --repo unbraind/pm-cli --name-only

echo '== Diff, excluding large context only =='
gh pr diff 1196 --repo unbraind/pm-cli --patch

echo '== Commit check-runs for stated runtime head =='
gh api "repos/unbraind/pm-cli/commits/3e949c195/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`' || true

echo '== Commit check-runs for final head =='
gh api "repos/unbraind/pm-cli/commits/f7293276a/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`' || true

Length of output: 99266


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Locate candidate scripts and workflows =='
fd -a -t f '^(context-usage\.ts|pr-review-loop\.mjs|hosted-analysis-gate\.mjs)$|\.ya?ml$' . \
  | sed -n '1,160p'

echo '== Source structure =='
ast-grep outline src/sdk/context-usage.ts --items all --view expanded
echo '== Review helper structure =='
ast-grep outline scripts/reviews/pr-review-loop.mjs --items all --view expanded
echo '== Hosted analyzer gate structure =='
ast-grep outline scripts/release/hosted-analysis-gate.mjs --items all --view expanded

echo '== collectNextResultItemIds and call sites =='
rg -n -A45 -B10 '\bcollectNextResultItemIds\b|\basObjectRecord\b' src/sdk/context-usage.ts
rg -n -A4 -B4 '\bcollectNextResultItemIds\s*\(' --glob '*.ts' .

echo '== Relevant test definitions and assertions =='
rg -n -A10 -B6 'context-usage|final egress|recommended|gate_needed|held_by_others|containers' \
  tests --glob '*.{ts,tsx}' | sed -n '1,320p'

echo '== Final-head guide section and referenced helper command syntax =='
sed -n '185,240p' docs/AGENT_GUIDE.md
rg -n -A10 -B6 'watch|inventory|acknowledge-inline|acknowledge' scripts/reviews/pr-review-loop.mjs
rg -n -A12 -B6 'process\.argv|hosted-analysis|annotations|DeepScan|branch protection' \
  scripts/release/hosted-analysis-gate.mjs

echo '== Final-head static gate and analyzer workflow definitions =='
rg -n -A35 -B10 'Gates \(static\)|hosted-analysis-gate|Release analyzer readiness' \
  .github --glob '*.{yml,yaml}' || true

echo '== Current final-head checks =='
gh api "repos/unbraind/pm-cli/commits/f7293276add7a10f0fec41e9275c4be5c047bee7/check-runs?per_page=100" \
  --jq '.check_runs[] | select(.name == "Gates (static)" or .name == "Release analyzer readiness (main)") | [.name,.status,.conclusion,.completed_at,.details_url] | `@tsv`'

Length of output: 78985


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="unbraind/pm-cli"
sha="f7293276add7a10f0fec41e9275c4be5c047bee7"

echo '== Final-head required and non-success check states =='
gh api "repos/${repo}/commits/${sha}/check-runs?per_page=100" \
  --jq '.check_runs[] | select(.conclusion != "success" and .conclusion != "neutral" and .conclusion != "skipped") | [.name,.status,(.conclusion // ""),.output.title,.output.annotations_count,.details_url] | `@tsv`'

echo '== Final-head CodeFactor check evidence =='
gh api "repos/${repo}/commits/${sha}/check-runs?per_page=100" \
  --jq '.check_runs[] | select(.name == "CodeFactor") | {name,status,conclusion,output:{title:.output.title,summary:.output.summary,annotations_count:.output.annotations_count}}'

echo '== Final-head DeepScan commit status =='
gh api "repos/${repo}/commits/${sha}/status" \
  --jq '.statuses[] | select(.context == "DeepScan") | {context,state,description,target_url}'

echo '== Fresh PR review inventory =='
gh api graphql -F owner="unbraind" -F name="pm-cli" -F pr=1196 -f query='
query($owner: String!, $name: String!, $pr: Int!) {
  repository(owner:$owner,name:$name) {
    pullRequest(number:$pr) {
      headRefOid
      reviewThreads(first:100) {
        nodes {
          isResolved
          comments(first:20) { nodes { author { login } body path line originalLine } }
        }
      }
      reviews(first:100) { nodes { author { login } state commit { oid } body } }
    }
  }
}' --jq '.data.repository.pullRequest'

echo '== Changed-file whitespace errors =='
git diff --check 22a7a1a9b829c540036340f5f7ca8f354b3cc008 f7293276add7a10f0fec41e9275c4be5c047bee7

echo '== Final PM record closeout and history tail =='
sed -n '1,170p' .agents/pm/issues/pm-08mt4k.toon
tail -n 8 .agents/pm/history/pm-08mt4k.jsonl

Length of output: 42178


@unbraind Full review found no code or documentation findings.

  • collectNextResultItemIds preserves the delivered-row traversal. It removes only the redundant outer array allocation.
  • The final head reports CodeFactor with annotations_count: 0.
  • The final head reports DeepScan with 0 new and 0 fixed issues.
  • The guide command syntax matches both implemented helper scripts.
  • The PM evidence is consistent with the change.
  • The pm-08mt4k changelog entry remains present. The prior changelog finding was based on unchanged diff context.

Gates (static) remains in_progress for f7293276a. I cannot confirm complete CI verification until that check reaches a terminal successful state. Do not merge until then.

✅ Action performed

Full review finished.

@unbraind

unbraind commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

The full review found no code/documentation findings and correctly waited for the remaining static check. The watcher has since reached terminal success for all required checks on f729327. The independent hosted-analysis gate also passes on that exact head with zero outstanding CodeFactor annotations, zero new DeepScan issues and strict branch protection. The changelog entry remains present as verified; no source changes followed this review.

@unbraind
unbraind merged commit 4b693c5 into main Sep 5, 2026
33 checks passed
@unbraind
unbraind deleted the fix/context-usage-array-allocation branch September 5, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant