Skip to content

fix: close the four review blockers (transcript surfaces, lookup deadline, teardown disposers) - #165

Closed
triagmas wants to merge 5 commits into
omdsh-dev:mainfrom
triagmas:fix/review-blockers
Closed

triagmas wants to merge 5 commits into
omdsh-dev:mainfrom
triagmas:fix/review-blockers

Conversation

@triagmas

@triagmas triagmas commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Three fix commits (one per blocker class from a full code review of 0.7.3), plus two follow-ups from the review of this PR (a single-sourced timeout verdict and corrected disposer notes):

  • Transcript surfaces — renderMessage only branches on tool/user, so the loop's system/message (system prompt) and developer/message fell through to the assistant arm and reached the reviewer as **agent**: work: mis-attributed review input, extra tokens, and a prompt leak into the next-prompt prediction. Both roles are now filtered at ingestion — append and post-compaction rebuild alike.
  • Lookup deadline — resolveModelInfo was awaited without a race, so an adapter whose lookup ignores cancellation held draining past the call deadline and every later delta of the session was refused (silent advisor death). The lookup is now raced against the deadline signal, and an aborted attempt is classified as a timeout before a provider stream opens.
  • Owner teardown — the commands inject child dropped the registry disposer, so /advisor survived the fiber and a re-apply hit the swallowed already registered error, leaving the command bound to a disposed controller. The reviewer-claim teardown also left per-session runtimes (in-flight calls, deadline timers) running after unload; it now disposes every runtime with the claim.

Tests

Tests: pnpm test — pass (776 tests, 28 files, exit 0)

pnpm typecheck — exit 0.

Five regression tests added; each was asserted red without its own fix (source stashed, test failed, restored), and the existing capability-resolution test now pins the "no stream queued past an already-fired deadline" behavior.

…script

renderMessage only branches on tool/user, so a system/message (the loop's system prompt) or a developer/message fell through to the assistant arm and reached the reviewer as **agent**: work — mis-attributed, duplicated into the next-prompt predictor, and a prompt leak into a second request. Filter both roles at ingestion (append and rebuild).
resolveModelInfo was awaited without a race, so an adapter whose lookup ignores cancellation held the drain past the deadline (draining stays true; every later delta is refused). Race it like the stream iterator and classify an aborted attempt as a timeout before opening a provider stream.
…down

The commands inject child dropped the registry disposer, so /advisor survived the fiber and a re-apply hit the swallowed already-registered error, leaving the command bound to a disposed controller. The reviewer-claim teardown also left per-session runtimes (in-flight calls, deadline timers) running after unload; dispose them with the claim.
@m-inspector

m-inspector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Verdict: ship it · Score 94% (mergeable)

Findings Count
🔴 must-fix 0
🟠 should-fix 0
🟡 may-fix 1
🔵 nit 0

📋 Review

What this PR does: This PR is a three-fix batch for advisor-runtime blockers found in a full review of 0.7.3: filtering system/message and developer/message out of the reviewer transcript (both on append and on post-compaction rebuild), racing resolveModelInfo against the call deadline so a non-cancellable adapter lookup can no longer hold draining past it, and restoring owner teardown so the /advisor command and per-session runtimes are disposed with the fiber. Two follow-up commits from this PR's own review fold the timeout verdict into a single raise site (timedOut()) and correct disposer notes. The settled review grades it ship it · 94% with no must-fix or should-fix items; the only open item is a comment-only inaccuracy in the new helper's docstring.

Findings

🟡 New helper docstring asserts a classifyFailure/TIMEOUT dependency that does not exist

  • Evidence:

    [DOCS-01] timedOut() docstring states a control-flow contract classifyFailure does not implement

    • Evidence: src/advisor-runtime.ts:808-811 — the new docstring says "classifyFailure keys the transient retry on that code, so a divergent copy at any raise site would silently stop the retry."
    • Evidence: src/advisor-runtime.ts:364-388 — classifyFailure has no 'TIMEOUT' branch at all: it checks EMPTY_RESPONSE, the quota codes, the permanent codes and PERMANENT_FAILURE_PATTERN, then falls through to return 'transient' (line 388).
    • Evidence: src/advisor-runtime.ts:815 — the only producer of the literal is the helper itself; a repo-wide search shows no other 'TIMEOUT' producer or consumer in src/.
    • Impact: both halves of the stated rationale are false against the code it cites. (a) No key exists — TIMEOUT is classified transient only via the catch-all, which classifies every unrecognized code as transient. (b) Therefore a "divergent copy at any raise site" would not "silently stop the retry": a different code such as ADVISOR_CALL_TIMEOUT or TIMEOUT_MS, with the same message, also matches no permanent/quota/empty branch and still returns transient. A maintainer who trusts the comment (e.g. while converting classifyFailure to an explicit transient allowlist, or while renaming the code) is reasoning from a dependency the code never encodes, and the wrong belief is stated as the justification for keeping the helper the single raise site.
    • Effort: XS — one comment paragraph; no behavior change.
    • Risk: LOW — comment-only edit; the speculative fear is that a stricter rewrite of the rationale invites may-fix re-review.
    • Confidence: HIGH (opened the docstring, classifyFailure, and the sole literal producer myself; the retry path is src/advisor-runtime.ts:769-796).
    • Fix sketch: Restate the motivation without claiming a keyed branch — e.g. "one literal keeps the failure code stable for logs/`/…
  • Location: repo-wide

  • Merge class: may-fix

Revalidated findings

Reassessed 3/3 prior finding(s) this round · 0 invalid-output · 0 omitted · 0 over cap · 3 recheckable · context coverage: complete

finding disposition evidence thread
B1 post-compaction replay test never establishes the rebuild path ran, so the replay filter is unpinned unverifiable (no-evidence) current-code -
Third verbatim copy of the signal-race helper (raceSignal) added in advisor-runtime unverifiable (no-evidence) current-code -
B1 instruction-surface tests cannot fail if the new event fixture never derives a message unverifiable (no-evidence) current-code -

Linked-issue AC

none

✅ Verified

- ✔ Read src/advisor-runtime.ts:808-811: the new timedOut() docstring states that classifyFailure keys the transient retry on the TIMEOUT code, and that a divergent copy at a raise site would silently stop the retry.
- ✔ Read src/advisor-runtime.ts:364-388: classifyFailure has no 'TIMEOUT' branch — it tests EMPTY_RESPONSE, the quota codes, the permanent codes and PERMANENT_FAILURE_PATTERN, then falls through to return 'transient' at :388.
- ✔ Read src/advisor-runtime.ts:815: the helper is the sole producer of the 'TIMEOUT' literal; a repo-wide search of src/ found no other producer or consumer.
- ✔ Read the retry path src/advisor-runtime.ts:769-796 and the three replacement call sites :845, :856, :876: the timedOut() extraction is behavior-preserving.
- ✔ Read src/index.ts:1245-1252: the hunk is comment-only.
- ❓ Cordis claims at cordis/src/fiber.ts:373 and :695 (cited in the src/index.ts comment) — not checkable statically: no node_modules/cordis source exists in the review worktree and @deepseek-ai/cordis is a consumer-side peer, so no finding was raised either way.
- ❓ PR body claims pnpm test pass (776 tests, 28 files, exit 0) and pnpm typecheck exit 0 — author-reported only; this review did not re-run them.
- ❓ Prior findings stay unresolved from available evidence: B1 replay test never establishes the rebuild path ran, the third verbatim raceSignal copy, and the B1 instruction-surface fixture that cannot fail if no message is derived — all recorded as unverifiable in the revalidation table.
- ❓ Full-file reads of src/advisor-runtime.ts and src/index.ts beyond the cited regions were not performed (tier budget).

🗑️ Considered & rejected

- "The missing keyed TIMEOUT branch in classifyFailure is a runtime defect" — rejected: TIMEOUT reaches transient through the catch-all fallthrough at :388, so retry behavior is correct; only the docstring's stated justification is wrong.
- "The timedOut() extraction altered behavior at one of its three call sites" — rejected: :845, :856 and :876 were all read and the extraction is behavior-preserving.
- "Raise a finding on the src/index.ts disposer/cordis notes" — rejected: the hunk is comment-only and the cited cordis internals are absent from the worktree, so the claim is neither confirmable nor refutable here; kept as a lead instead.

🛠️ Plan to fix

Expand fix plan
1. **Rewrite the `timedOut()` docstring** — `src/advisor-runtime.ts:808-811`. Remove the sentence claiming `classifyFailure` "keys the transient retry on that code", and the corollary that a divergent copy "would silently stop the retry". Keep the single-raise-site rationale, but ground it in what the code actually does: one literal keeps the failure code stable for logs and `/advisor status` diagnostics, and keeps the message text uniform across all three raise sites.
2. **State the real retry path once, unambiguously** — same block. Either write that `TIMEOUT` reaches the retry via `classifyFailure`'s transient fallthrough (no dedicated branch; `:388`), or drop the classification claim entirely. Do not leave both readings available.
3. **Do not touch behavior** — no edits to `classifyFailure` (`:364-388`), the helper body (`:815`), its three call sites (`:845`, `:856`, `:876`), or the retry path (`:769-796`). This is a comment-only change by design.
4. **Optional, separate change** — if a keyed `TIMEOUT` branch is actually wanted, that is a behavioral change: add the branch explicitly plus a test pinning that a near-miss code (e.g. `ADVISOR_CALL_TIMEOUT`) still classifies as expected. Not required to close [DOCS-01] and not a merge condition for this PR.
5. **Verification gates** — `pnpm typecheck` exit 0; `pnpm test` expected at the unchanged baseline (comment-only diff); then re-read the final docstring hunk against `:364-388` to confirm no sentence asserts a branch or consumer that does not exist.
6. **Carry the open lead forward** — the cordis line references in the `src/index.ts` comment (`cordis/src/fiber.ts:373`, `:695`) remain unverified because cordis is not vendored in the worktree; check them against cordis source at the next opportunity and soften the wording if they cannot be confirmed.

Review 2 · commit 48f3c3f · since 2b34c04

@m-inspector m-inspector 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.

mstar-inspector line comments · round 1 · 2b34c04

Comment thread tests/transcript.test.ts
const delta = renderer.update(events)
expect(delta).toBeDefined()
expect(delta!.markdown).not.toContain('careful coding agent')
expect(delta!.markdown).not.toContain('**agent**: You are')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

B1 instruction-surface tests cannot fail if the new event fixture never derives a message · 🟡 may-fix

  • Evidence: tests/transcript.test.ts:425-443 — every assertion that protects the new filter is negative (not.toContain('careful coding agent'), not.toContain('**agent**: You are')); the only positive assertions are **user**: fix the bug / **agent**: Done., which do not depend on the systemMessage fixture at all. The fixtures are introduced at tests/transcript.test.ts:155-196 (type: 'system/message' / type: 'developer/message' with data: { turn, step, message }), and deriveEventMessage comes from @deepseek-ai/dsh-session (src/transcript.ts:58-62).
  • Impact: The regression this diff fixes (the system prompt rendered as **agent**: … and shipped to the reviewer/next-prompt request) is only pinned if the fixture actually produces a derivable message. If the new event type or its data shape does not match the dependency's derivation, or the dependency later stops deriving it, the renderer drops the event before the reviewability filter and every assertion still passes — the suite reports green while the exact defect is unfixed/unpinned. This is a test that passes for the wrong reason, not merely thin coverage. I could not open @deepseek-ai/dsh-session (dependency sources are not present in this worktree) to confirm the fixture shape, which is precisely the gap the test leaves unasserted.
  • Effort: XS — one positive control (e.g. assert the pre-fix rendering path would have shown the instruction content, or assert the derived message exists/role is system) makes the fixture failure observable.
  • Risk: LOW — adding an assertion cannot change product behavior.
  • Confidence: MED — the assertion structure is read directly and is certain; whether the fixture itself is currently mis-shaped needs the dependency source.
  • Fix sketch: Add a positive control tying the instruction fixture to the filter (assert the deriv…

Comment thread tests/transcript.test.ts
expect(delta!.markdown).toContain('**agent**: Continuing.')
})
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

B1 post-compaction replay test never establishes the rebuild path ran, so the replay filter is unpinned · 🟡 may-fix

  • Evidence: tests/transcript.test.ts:448-475 — the second case renders the compaction sequence through a replace op ({ op: 'replace', startSeq: 1, endSeq: 3 }, sourceEventSeqs: [1, 3]) and asserts only not.toContain('System preamble.'), not.toContain('Tool addition: shell.'), toContain('**user**: continue'), toContain('**agent**: Continuing.'). The instruction fixtures exist only in the pre-compaction prefix; the plain append path renders just the turn-2 tail.
  • Impact: The test's stated contract (comment: "A compact rewrite forces the rebuild path — the same ingestion filter must hold there, or a replay re-sends the instructions") is not pinned: every assertion is satisfied identically whether update() performed the prefix rebuild (src/transcript.ts:364-370) or only appended the new events. A regression that specifically re-admits system/developer content only on the rebuilt foldSurface path would leave this test green. The test also never asserts that the replacement actually took effect (e.g. the Summary of earlier work. user line entering the delta), so a fixture range that never triggers the rebuild degrades the case to a duplicate of the first one.
  • Effort: XS — one assertion that only the rebuild path can produce (the post-compaction summary line) plus the existing negative assertions.
  • Risk: LOW — assertion-only change.
  • Confidence: MED — the assertion set was read in full and cannot distinguish the paths; the actual path chosen by update() is internal to the renderer.
  • Fix sketch: Assert a rebuild-only artifact (the compacted summary user message) alongside the instruction-exclusion assertions, so the replay ingestion filter is genuinely exercised.

Comment thread src/advisor-runtime.ts
}

// ---------------------------------------------------------------------------
// AdvisorRuntime

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Third verbatim copy of the signal-race helper (raceSignal) added in advisor-runtime · 🟡 may-fix

  • Evidence: src/advisor-runtime.ts:446 — the diff adds function raceSignal<T>(promise, signal), and its own doc comment names the duplicates: "same shape as the per-chunk raceIteratorNext, and the copy the gateway/index faces carry". The pre-existing copies are src/index.ts:162 and src/gateway.ts:236 — I opened all three: the bodies are byte-for-byte the same shape (if (signal.aborted) return Promise.resolve('aborted'); new Promise; addEventListener('abort', onAbort, { once: true }); promise.then removing the listener and forwarding value/rejection).
  • Impact: Maintenance cost, not a behaviour defect: the advisor now carries three independent copies of one abort-race invariant that each bound a different capability lookup (index.ts model validation, gateway.ts reasoning query, advisor-runtime.ts per-call effort resolution). A correction to the race — e.g. abort-source discrimination, listener cleanup on the abort branch, or a change to the 'aborted' sentinel — has to be found and applied in three places; the diff already had to re-derive the reasoning about it in a fourth comment block. The divergence risk is concrete because each copy is paired with a different sentinel consumer (callModel's new pre-check at src/advisor-runtime.ts:832, index.ts's 'failed' mapping at :977).
  • Effort: XS — delete one copy and import the shared helper; no test changes needed (behaviour identical).
  • Risk: LOW — pure extraction of an already-identical function; the only risk is choosing which module owns it (the helper currently lives in index.ts, the wiring layer, which is the wrong owner for advisor-runtime/gateway to import from).
  • Confidence: HIGH — read all three implementations and the call sites myself.
  • Merge class: may-fix
  • Seat coverage (changeset-2-src): read the full diff snapshot (`/workspace/pr.…

The KD-5 timeout failure (message + TIMEOUT code) was written out at three raise sites, and classifyFailure keys the transient retry on that code — a divergent literal at any site would silently disable the retry. timedOut() is now the single source.
…k line

The commands seam has no try/catch: a duplicate registration fails the child fiber, which cordis logs and contains, so apply keeps running. Also point the effect citation at fiber.ts:373 (the collect site, not the inject() declaration) and stop the B4 test comment from promising a delivery suppression it does not assert.
@triagmas

Copy link
Copy Markdown
Contributor Author

Closing: this pull request was opened against the wrong repository by mistake. The branch and commits stay in the fork (triagmas/dsh-advisor); no review is expected here.

@triagmas triagmas closed this Nov 18, 2026
@triagmas
triagmas deleted the fix/review-blockers branch November 18, 2026 05:11
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