Skip to content

fix(retrieval): stabilize async report flows - #623

Merged
mohanagy merged 2 commits into
nextfrom
agent/issue-622-full-flow-retrieval
Jul 29, 2026
Merged

mohanagy merged 2 commits into
nextfrom
agent/issue-622-full-flow-retrieval

Conversation

@mohanagy

@mohanagy mohanagy commented Jul 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #622.

What changed

  • make full report-flow paraphrases recover the same bounded controller → enqueue → orchestration/planning → research → assembly → DB-sync skeleton
  • preserve only authenticated relationships and emit exact disconnected targets for asynchronous handoffs
  • keep focused locator queries bounded instead of activating full-flow recovery
  • add compilerOptions.removeComments: true to tsconfig.build.json, exactly as owner-authorized on [Bug]: beta.2 full-flow retrieval remains prompt-sensitive and misses async pipeline handoffs #622, so the unchanged package ceiling remains satisfied
  • add the frozen JS/TS fixture, packed-consumer parity checks, governance receipts, and build-output sentinels

Frozen constraints

  • target is next, never main
  • no dependency, package/lockfile, workflow, graph/index, CLI, MCP, retrieval-budget, or public-semantic change
  • no compatibility alias or repository/path-specific ranking
  • no npm publication, release, Registry publication, or tag
  • package remains within 102 files / 165,000 packed bytes / 640,000 unpacked bytes

Exact candidate

  • head: 3b3fb9d404864e725305dc491b75e82006c2371f
  • tree: d43d9d3cb7cf7d566bcb35eca7df2564f0d9ff8c
  • package: 102 files / 158,295 packed bytes / 639,867 unpacked bytes
  • artifact SHA-256: 89971e2c2df3f698f48ee066b08923c0ca28853a547d1aaab2d0bd64fdacf005

Local gates

  • 74 test files / 630 tests passed
  • coverage: 82.20% statements / 73.88% branches / 89.44% functions / 86.01% lines
  • typecheck, production build, evaluation build
  • Core Reset baseline and governance tests
  • packed checkout/direct/CLI/MCP parity
  • package isolation and exact comment-removal/shebang sentinels
  • release hygiene and MCP Registry schema validation
  • npm audit: 0 vulnerabilities
  • demo regression: 95% recall, 1.0 MRR, 100% snippet coverage, 95% grounded match rate
  • real GoValidate graph: exact 10-stage long flow at 3,669 tokens; exact MasterAgent follow-up at 3,849; both untruncated

Two independent exact-head reviews found no blocker and are recorded on this exact head before merge. CodeRabbit is not counted as an independent review; it reviewed this non-default-base PR and its rerun passed with no new actionable comments, while reusing prior analysis for four unchanged/similar files.

Summary by CodeRabbit

  • New Features
    • Improved retrieval for end-to-end report-generation flows, including pipeline stages, handoffs, and disconnected boundaries.
    • Added support for recognizing flow-oriented queries and tracing related branches more accurately.
  • Bug Fixes
    • Improved consistency between retrieval results across source, packaged, direct, and CLI execution modes.
    • Strengthened packaged artifact integrity checks to prevent unintended metadata (including comment handling) from appearing in distributed outputs.
  • Tests
    • Added expanded coverage for report-flow prompts, evidence quality, budgets, and retrieval parity.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change stabilizes full-flow retrieval by carrying flow metadata through ranking and traversal, expanding an asynchronous report-generation fixture, and adding packed parity, artifact-integrity, build-configuration, and governance validation for regression #622.

Changes

Retrieval regression #622

Layer / File(s) Summary
Flow-aware ranking and traversal
src/domain/query/rank.ts, src/domain/query/traverse.ts, src/domain/query/types.ts
Ranking returns flow and branch metadata, while traversal distinguishes pipeline chains from side branches and selects corresponding targets.
Asynchronous report-flow fixture and retrieval coverage
tests/fixtures/pack-quality/runtime-generation-explain-report-flow/*, tests/unit/retrieve-context.test.ts
The fixture models queue-based orchestration, planning, research, assembly, and database synchronization, with expanded prompt variants and retrieval assertions.
Packed parity and governed build output
.github/scripts/verify-packed-retrieval-parity.mjs, tsconfig.build.json, tools/eval/core-reset/verify-isolation.mjs, tests/unit/core-reset-*.test.ts, docs/core-reset/*, docs/designs/*, docs/roadmap.md
Packed receipts, artifact contents, comment stripping, full-flow evidence, package parity, and the bounded #622 governance amendment are validated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OrchestratorWorker
  participant PlannerService
  participant SectionResearchWorker
  participant ResearchAgentService
  participant AssemblyWorker
  participant AssemblyService
  participant DbSyncWorker
  OrchestratorWorker->>PlannerService: plan pipeline job
  PlannerService->>SectionResearchWorker: enqueue section research
  SectionResearchWorker->>ResearchAgentService: research section
  ResearchAgentService->>AssemblyWorker: enqueue assembly
  AssemblyWorker->>AssemblyService: assemble report
  AssemblyService->>DbSyncWorker: enqueue persistence
Loading

Possibly related PRs

Suggested labels: core-reset

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning No description was provided, so the required template sections and testing/core-reset details are missing. Add the template sections: Summary, Testing, Core Reset contract, Checklist, and Related issues, with the applicable issue/manifest details.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests align with #622 by adding bounded full-flow ranking, exact handoff targets, removeComments exception, and packed parity checks.
Out of Scope Changes check ✅ Passed The docs, tests, fixture, and build-config changes are all tied to the retrieval regression and pack/parity validation; no unrelated scope stands out.
Title check ✅ Passed The title is concise and matches the main change: stabilizing retrieval for asynchronous report-flow queries.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/issue-622-full-flow-retrieval

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

@mohanagy mohanagy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent exact-head semantic review — NO BLOCKER

Reviewed commit 9b17c6ce04c8f8bb03fcfb4b5b6b56e3b85e8921, tree 23c8a4e9c0fe9e0fad91693c122f8acbacd65f30, against #622 and protected base 5df59886190a65ba80e07339203aeba013c94ef2.

Evidence:

  • real GoValidate full flow: exact 10-stage skeleton, 5 authenticated relationships, 4 honest disconnected handoffs, 3,669 tokens, untruncated;
  • MasterAgent follow-up: 10 relevant nodes including MasterAgentService.call, 6 relationships, 3 honest handoffs, 3,849 tokens, untruncated;
  • focused locators: 2 files/2 snippets and 1 file/1 snippet, both untruncated;
  • no repository/path literals or hard-coded phase names remain in production changes; recovery is graph-structural;
  • traversal returns authenticated edges only and exact disconnected verification targets for asynchronous gaps;
  • production delta is confined to rank.ts, traverse.ts, and types.ts; no graph/index, dependency, package-script, CLI, or MCP semantic change;
  • 52 focused tests, 23 governance/baseline tests, typecheck, and diff cleanliness passed;
  • packed parity passed at 102 files / 158,284 packed bytes / 639,839 unpacked bytes.

This review is independent from CodeRabbit and does not represent CodeRabbit's disposition.

@mohanagy mohanagy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent exact-head governance/package review — NO BLOCKER

Reviewed commit 9b17c6ce04c8f8bb03fcfb4b5b6b56e3b85e8921, tree 23c8a4e9c0fe9e0fad91693c122f8acbacd65f30, sole parent/base 5df59886190a65ba80e07339203aeba013c94ef2.

Evidence:

  • fresh package matches the manifest and PR receipts byte-for-byte: 102 files, 158,284 packed bytes, 639,839 unpacked bytes, SHA-1 d9be5a2b86de370c74938e58343b862334c8d9e6, integrity sha512-kHuWp72gv/g0r2dROXvM9nTvHeOAHmIRdzPZpJo7GVCdWHIoRMZWaoDQarZ5z6wecHuXBuOMkYGhY22tuQsLFg==, SHA-256 7b5ecf689c2a4a79a8101aad296b8872d478e875107a10a0d24eb75da1763494;
  • fixed ceilings remain 102 / 165,000 / 640,000, leaving 161 unpacked bytes of headroom;
  • the sole build-config delta is /compilerOptions/removeComments=true; tsconfig.json and tsconfig.eval.json are blob-identical to base;
  • source comment sentinel remains, emitted JS/declaration sentinel is absent, and the CLI shebang remains;
  • package.json, lockfile, CI/release workflows, dependencies, scripts, and version are unchanged;
  • exact production receipt is 43 TypeScript files / 12,147 LOC, +163/-24/net +139, only rank.ts, traverse.ts, and types.ts, inside the unchanged +164/-21/net +143 allowance;
  • published beta.2 manifest.current is preserved; the fresh artifact is recorded separately as an unpublished #622 candidate;
  • typecheck, 23 governance/baseline tests, both builds, isolation, and pack parity passed;
  • PR #623 targets next; publication, tags, Registry publication, releases, and main remain forbidden.

Non-blocking caution: the unpacked ceiling has only 161 bytes of remaining headroom. This review is independent from CodeRabbit.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (4)
src/domain/query/rank.ts (1)

745-748: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Magic anchor limit.

anchorLimit = 4 when a bridge exists is an unexplained constant next to MAX_RANKED_ANCHORS. Name it (e.g. BRIDGE_ANCHOR_LIMIT) so the bounded-selection contract stays auditable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/domain/query/rank.ts` around lines 745 - 748, Replace the unexplained
literal in the bridge-handling branch near `bridgePair` and `anchorLimit` with a
clearly named constant such as `BRIDGE_ANCHOR_LIMIT`, defined alongside
`MAX_RANKED_ANCHORS`, and use that constant when a bridge exists.
tests/unit/core-reset-governance.test.ts (1)

1414-1418: 📐 Maintainability & Code Quality | 🔵 Trivial

Tight npm package budget margin.

npm_package_budget.unpacked_bytes_max is 640,000 while the candidate receipt's npm_unpacked_bytes is 639,839 — only 161 bytes of headroom (~0.03%). Any small unrelated addition to production source elsewhere in the "evaluation-tooling" surface will likely trip this budget check even without touching #622's scope.

Also applies to: 2743-2752

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/core-reset-governance.test.ts` around lines 1414 - 1418, Increase
npm_package_budget.unpacked_bytes_max in the relevant budget configuration to
provide meaningful headroom above the candidate receipt's npm_unpacked_bytes,
while preserving the existing files_max and packed_bytes_max limits.
tests/unit/retrieve-context.test.ts (1)

466-599: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider splitting this into focused it blocks.

This single test asserts six distinct scenarios (short control, full flow, paraphrases, MasterAgent follow-up + its paraphrases, focused-queue prompts) inside one it. A failure in any sub-scenario reports under the same test name, making CI failures harder to triage. Sharing the reportGenerationFixture() setup via beforeAll/beforeEach and splitting into separate its per scenario would preserve coverage while improving isolation and readability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/retrieve-context.test.ts` around lines 466 - 599, Split the single
report-pipeline test into focused it blocks for short control, full flow,
full-flow paraphrases, MasterAgent follow-up prompts, and focused-queue prompts.
Share reportGenerationFixture setup through beforeAll or beforeEach, while
preserving each scenario’s existing assertions and coverage so failures identify
the specific scenario.
docs/core-reset/removal-manifest.yml (1)

1373-1398: 🚀 Performance & Scalability | 🔵 Trivial

Very tight package-size margin on the #622 candidate.

candidate_package.npm_unpacked_bytes (639,839) leaves only 161 bytes of headroom under the item's npm_package_budget.unpacked_bytes_max (640,000). Any trivial future change to the moved evaluation tooling output risks tripping this ceiling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/core-reset/removal-manifest.yml` around lines 1373 - 1398, Reduce the
`#622` candidate package footprint so candidate_package.npm_unpacked_bytes has
meaningful headroom below the 640,000-byte npm_package_budget.unpacked_bytes_max
limit. Remove or exclude unnecessary moved evaluation-tooling output, then
regenerate the candidate package size and artifact metadata consistently without
changing the protected budget or forbidden configuration fields in
post_completion_build_output_amendment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/core-reset/removal-manifest.yml`:
- Around line 1865-1920: Update the retrieval-regression-622 verification list
to include tools/eval/core-reset/verify-isolation.mjs and
tests/unit/core-reset-baseline.test.ts, which directly validate the
build_output_exception compilerOptions.removeComments behavior. Keep all
existing verification entries and scope constraints unchanged.

In `@src/domain/query/rank.ts`:
- Around line 700-704: Remove the non-null assertion in the stageEntry
outgoing-id lookup and guard unresolved nodes before calling flowCoverage.
Update the filter around stageEntry so missing corpus.nodeById entries are
skipped while preserving the existing coverage and ranking behavior for resolved
nodes.

In `@src/domain/query/traverse.ts`:
- Around line 127-140: Align the coverage checks with the `sources`/`chain`
index space in the traversal logic: update the loop that accesses
`paths[sourceIndex + offset]` so it cannot treat `sourceIndex` as an `anchors`
index when side branches are present. Prefer carrying each source’s
corresponding anchor position or otherwise deriving consistent positions, while
preserving the existing flow and coverage behavior.

---

Nitpick comments:
In `@docs/core-reset/removal-manifest.yml`:
- Around line 1373-1398: Reduce the `#622` candidate package footprint so
candidate_package.npm_unpacked_bytes has meaningful headroom below the
640,000-byte npm_package_budget.unpacked_bytes_max limit. Remove or exclude
unnecessary moved evaluation-tooling output, then regenerate the candidate
package size and artifact metadata consistently without changing the protected
budget or forbidden configuration fields in
post_completion_build_output_amendment.

In `@src/domain/query/rank.ts`:
- Around line 745-748: Replace the unexplained literal in the bridge-handling
branch near `bridgePair` and `anchorLimit` with a clearly named constant such as
`BRIDGE_ANCHOR_LIMIT`, defined alongside `MAX_RANKED_ANCHORS`, and use that
constant when a bridge exists.

In `@tests/unit/core-reset-governance.test.ts`:
- Around line 1414-1418: Increase npm_package_budget.unpacked_bytes_max in the
relevant budget configuration to provide meaningful headroom above the candidate
receipt's npm_unpacked_bytes, while preserving the existing files_max and
packed_bytes_max limits.

In `@tests/unit/retrieve-context.test.ts`:
- Around line 466-599: Split the single report-pipeline test into focused it
blocks for short control, full flow, full-flow paraphrases, MasterAgent
follow-up prompts, and focused-queue prompts. Share reportGenerationFixture
setup through beforeAll or beforeEach, while preserving each scenario’s existing
assertions and coverage so failures identify the specific scenario.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 28156029-d622-4e6a-b3bc-109d9830100e

📥 Commits

Reviewing files that changed from the base of the PR and between 5df5988 and 9b17c6c.

📒 Files selected for processing (24)
  • .github/scripts/verify-packed-retrieval-parity.mjs
  • docs/core-reset/removal-manifest.yml
  • docs/core-reset/scorecard.md
  • docs/designs/2026-07-19-core-reset.md
  • docs/roadmap.md
  • src/domain/query/rank.ts
  • src/domain/query/traverse.ts
  • src/domain/query/types.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/fixture.json
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/platform/src/components/InProgressIdeasDropdown.tsx
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/pipeline/agent/master-agent.service.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/pipeline/api/queue-registry.service.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/pipeline/assembly/assembly.worker.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/pipeline/workers/db-sync.worker.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/pipeline/workers/orchestrator.worker.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/planning/planner.service.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/reports/assembly.service.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/research/research-agent.service.ts
  • tests/fixtures/pack-quality/runtime-generation-explain-report-flow/workspace/src/modules/research/workers/section-research.worker.ts
  • tests/unit/core-reset-baseline.test.ts
  • tests/unit/core-reset-governance.test.ts
  • tests/unit/retrieve-context.test.ts
  • tools/eval/core-reset/verify-isolation.mjs
  • tsconfig.build.json

Comment thread docs/core-reset/removal-manifest.yml Resolved
Comment thread src/domain/query/rank.ts Resolved
Comment thread src/domain/query/traverse.ts Resolved

@mohanagy mohanagy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent exact-head semantic review — NO BLOCKER. Reviewed head 3b3fb9d, tree d43d9d3cb7cf7d566bcb35eca7df2564f0d9ff8c, against next base 5df5988. Missing corpus nodes now score zero without throwing; flow side branches no longer mix index spaces; the focused regression returns all four authenticated edges with zero boundaries. Real GoValidate probes remain exact: full flow 10 nodes/5 edges/4 honest handoffs/3669 tokens, MasterAgent 10/6/3/3849, focused locators 2 nodes and 1 node, all untruncated. Production remains limited to rank/traverse/types with frozen retrieval, graph/index, dependency, CLI, MCP, and semantic constraints. CodeRabbit is not counted as this independent review.

@mohanagy mohanagy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent exact-head governance/package review — NO BLOCKER. Reviewed head 3b3fb9d, tree d43d9d3cb7cf7d566bcb35eca7df2564f0d9ff8c, against next base 5df5988. Live PR body, manifest, and tests agree on 43 source files/12147 LOC/+164/-25/net+139 and an unpublished package of 102 files/158295 packed/639867 unpacked/SHA-256 89971e2c2df3f698f48ee066b08923c0ca28853a547d1aaab2d0bd64fdacf005. Only compilerOptions.removeComments=true changed in build config; package, lockfile, dependencies, other tsconfigs, workflows, ceilings, publication, tags, release, Registry, and main remain frozen. Caution is non-blocking: 133 unpacked bytes remain. CodeRabbit is not counted as this independent review.

@mohanagy

Copy link
Copy Markdown
Owner Author

Final exact-head merge gate receipt

  • target: protected next (never main)
  • exact head: 3b3fb9d404864e725305dc491b75e82006c2371f
  • exact tree: d43d9d3cb7cf7d566bcb35eca7df2564f0d9ff8c
  • protected base reviewed: 5df59886190a65ba80e07339203aeba013c94ef2
  • source receipt: 43 TypeScript files / 12,147 LOC / +164/-25, net +139
  • unpublished package receipt: 102 files / 158,295 packed bytes / 639,867 unpacked bytes / SHA-256 89971e2c2df3f698f48ee066b08923c0ca28853a547d1aaab2d0bd64fdacf005
  • CI: all six matrix jobs green in run 30452883659
  • independent semantic review: NO BLOCKER (review 4808337508)
  • independent governance/package review: NO BLOCKER (review 4808337677)
  • review threads: 3 total / 3 resolved / 0 unresolved by fresh GraphQL query
  • mergeability: MERGEABLE / CLEAN

CodeRabbit did not skip this non-default-base PR. It completed an initial review with three actionable threads; after the exact-head fixes, its rerun reached PASS with no new actionable comments while reusing prior analysis for four unchanged/similar files. CodeRabbit is not counted as either independent review.

No npm publication, GitHub Release, Registry publication, tag, or main action is authorized or performed.

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