Skip to content

fix(prism): respect active descendants before stale notices - #342

Merged
lukemaj merged 2 commits into
mainfrom
fix/341-descendant-activity
Oct 15, 2026
Merged

lukemaj merged 2 commits into
mainfrom
fix/341-descendant-activity

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What: Quiet parent runs no longer send stale-child notices while a descendant has an active provider attempt.
Why: The silence detector only saw the parent's own provider events, so a parent waiting on healthy nested work looked stalled.
So what: Merged as e2aff187811ad0e0691bb927ddc3a07a0d973018 into main after both exact-head reviews and green CI; #341 is closed.

Closes #341. Supports Drafters and Spectrum in the Objective by keeping healthy delegated work from being cancelled on a misleading notice.

The existing monitor now checks the other live attempts only when a silence is suspected. It validates persisted running status and attempt identity, then follows canonical parent links, including deleted intermediates, to distinguish descendants from siblings. Active descendants renew the watched silence allowance. Completed/replaced attempts cannot suppress notices, and notices resume once descendant work ends. Provider timing samples, thresholds, notification delivery and notice text stay unchanged.

Upstream search and the red-first diagnosis: #341 (comment). Current upstream main has no fork stale detector or same-cause fix to port. This is an existing-component fix, with no new design round, versions or protocol changes. SN remains #269's Child notices part in the feature map.

Delivery: merged at 2026-10-15T00:46:10Z. Reviewed head 1f7e1a453d319ed069a5c7ed4d9ab30e5ffd986a; Sol PASS and Grok PASS each preceded their authenticated exact-head success status. Aggregate review also succeeds. Admission and current-base inspection records green CI, the disjoint #340 main advance and proof limits. Verified merged parent 2ba387388074ac4ee09cc256f9800cdd9ce2b520 and tree e10b459dfdbbabb6436982efc7e1afc08122fc40, exactly matching the pre-merge result. Own clean worktree and local/remote branch are removed; completed reviewer children retired, no persistent process or watch. Proof logs remain outside the repository. No restart or deployment.

Validation:

  • Regression first failed on origin/main 9ab53882e87a9e0a6413f74d8b313ce516721d40: idle parent, quiet delegated child, grandchild streaming every second, unexpected persisted notice at 151 seconds.
  • npx -y pnpm@11.10.0 install succeeded.
  • npx -y pnpm@11.10.0 exec vp test run apps/server/src/prism/staleTurnMonitor.integration.test.ts apps/server/src/prism/staleTurnDetector.test.ts apps/server/src/prism/streamClock.test.ts: 24 passed across three files.
  • Five new scenarios cover active and deeper descendants, completed runs, replaced attempts and sibling activity; active cases also prove notices return after descendants end.
  • Changed-file lint and git diff --check pass. Full-suite proof belongs to CI.

Tests use memory-only V2 persistence, deterministic TestClock sweeps and real StreamClock observations. Providers are faked at the external boundary. No browser, server, native client or live-provider session was started; no live userdata access. This server-owned guard applies before the existing shared notice path for all clients and local provider drivers. Remote-environment activity is outside this local StreamClock correction. Website/SEO impact: none, no public site or URL changes.

Requirements and who asked: The user's #341 brief requires descendant-aware stale notices, failing-before focused proof, Sol gpt-6.1-sol and Grok grok-4.7 child reviews with exact-head statuses after comments, green CI and delegated merge.
Deleted: Threshold tuning, new clocks/schemas/messages, UI changes, a design round, version bumps, restart/deployment and blanket hasPendingChildRuns suppression.
Bottleneck: The final notice guard ignored other live attempts; the focused persisted-state reproduction isolates that seam.
Checked myself: Read #341, #269 and PR #279 with their complete discussion, inspected the owning clock/detector/monitor/lineage code and upstream search, observed the red notice and 24 passing focused cases, reviewed the complete task diff.

Implementation: Codex gpt-6.1-sol, medium reasoning, Codex harness.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Oct 15, 2026
@lukemaj

lukemaj commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

What: Independent Sol review PASS, with no supported blocking findings at 1f7e1a453d319ed069a5c7ed4d9ab30e5ffd986a.
Why: The existing monitor now recognizes persisted, current descendant attempts before sending a silence advisory, while preserving provider measurements, thresholds and notification delivery.
So what: Record success only for review/independent-sol; the planner still owns the separate Grok verdict, CI admission and merge.

Reviewed the complete three-file diff against main base 9ab53882e87a9e0a6413f74d8b313ce516721d40. Live PR head/base/main target and clean source HEAD were rechecked immediately before publication. This is an independent reviewer role, Codex gpt-6.1-sol, high reasoning effort, Codex harness. No implementation or subdelegation was performed.

Findings: none requiring correction in the inspected scope.

Checked paths and cleared concerns:

  • apps/server/src/prism/staleTurnMonitor.ts:49-77: suppression requires a local StreamClock entry whose persisted run is running and whose activeAttemptId matches. Completed/replaced attempts and archived/deleted candidates are excluded. Matching roots alone cannot suppress a notice: canonical parent traversal must reach the watched child. Siblings therefore fail the ancestry test; deleted intermediate records remain readable through ProjectionStore.getThread. The visited set bounds cycles. Missing projection reads take the existing caught warning/retry path rather than fabricating descendant activity; malformed/missing ancestry was inspected in source, not exercised.
  • staleTurnMonitor.ts:85-123: descendant reads occur after suspected silence and the existing watched-run, pending-input, retirement and parent visibility guards. Existing readRetirementState still rejects incomplete/retired watched ancestry. This avoids SQL in token observation and on healthy sweeps. Work per eligible suspicion is bounded by the other local live attempts and traversed ancestry; no performance benchmark is claimed.
  • staleTurnDetector.ts:62-99 and streamClock.ts:215-240: pause only renews detector silenceFrom. It does not alter event timestamps, first-token/gap samples, attempt ownership or notification identity. Terminal turns and endAttempt remove descendant liveness. The new running/deep scenarios assert no parent advisory during streaming and an advisory after descendant liveness ends; completed/replaced/sibling controls assert a notice remains possible.
  • Threshold and delivery preservation: the detector and StreamClock have no diff. The 120000/90000 ms floors, measured maximum multiplier 1.5 and strict confirmation multiplier 1.25 remain. Notice text, V2 metadata, queued dispatch, deduplication and terminal bookkeeping remain unchanged. The shared server guard applies before the existing delivery consumers for web, desktop, mobile and locally observed provider drivers. Remote-environment activity remains outside this fix.

Evidence inspected:

  • Authoritative Stale-child notice fires while the child is waiting on its own active children #341 and diagnosis comment 6181497222, Deliver child notices and ancestor updates through V2 notifications #269's outcome and per-alert diagnosis 6164552455, and PR fix(orchestration): child updates use queued V2 notifications #279's stale-detector/threshold decisions. The earlier alerts had unsupported newer-run/tool hypotheses; this change addresses the distinct nested-work reproduction and does not retune them.
  • /home/luke/scratch/chromeria-341/red.log: original single regression fails with an unexpected persisted notice at epoch+151000 while the grandchild streams.
  • focused.log: 3 test files and 24 tests passed. Recorded command: npx -y pnpm@11.10.0 exec vp test run apps/server/src/prism/staleTurnMonitor.integration.test.ts apps/server/src/prism/staleTurnDetector.test.ts apps/server/src/prism/streamClock.test.ts. Inspected the memory-only persistence, fake provider boundary, deterministic TestClock sweeps, persisted message assertions and existing guard tests. No added sleep/polling proof.
  • lint.log is empty; exit 0 is reported in the task/PR record, not independently recoverable from that file. Final commit inspection confirms it changes only two comments and the map PR reference, leaving the previously tested functional source unchanged.

Commands actually executed for this review were read-only Git identity/status/diff/show/remotes/divergence commands, gh issue view, gh pr view, gh pr diff, read-only gh api requests, and rg/sed/cat source and log inspection. I did not rerun tests, lint, typechecks or experiments. CI owns complete proof; no browser, server, native client, live provider, live userdata or memory access was used. No tracked files were edited. This verdict is not an aggregate review or merge authorization.

Requirements and who asked: The #341 review brief requires an independent exact-head Sol verdict for descendant-aware stale notices, preserving #269/#279 thresholds and delivery; this protects delegated Drafters/Spectrum work in the Objective.
Deleted: Threshold tuning, new detector/schema/delivery/UI work, design rounds, duplicate test execution, versions, browser/server use, restart/deployment and unrelated findings.
Bottleneck: Exact-candidate review of lifecycle identity, canonical ancestry and eventual advisory behavior; separate Grok coverage and CI remain the planner's admission gates.
Checked myself: Complete base/head diff and owning consumers, authoritative task/history, actual red/focused logs, final nonfunctional commit, clean source identity and live PR target before publication.

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 4.9 KiB 4.9 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.8 KiB 20.8 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB −24 B (−0.5%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −24 B (−2.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB −41 B (−0.2%) 29.3 KiB ✅
Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅

Baseline: 9ab5388 · PR result: 1f7e1a4 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj

lukemaj commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

What: Independent Grok review passes 1f7e1a453d319ed069a5c7ed4d9ab30e5ffd986a with no supported blocking finding.
Why: At a suspected silence, the monitor now treats a persisted running descendant attempt as activity and renews that silence window, leaving thresholds and V2 notice delivery as they are.
So what: This status is only review/independent-grok. The planner still owns the Sol verdict, CI, and merge.

Reviewed head 1f7e1a453d319ed069a5c7ed4d9ab30e5ffd986a. Live PR base main at 9ab53882e87a9e0a6413f74d8b313ce516721d40. Local HEAD matches origin and the worktree is clean. Verdict: PASS. No verdict is transferred from any other SHA or reviewer.

Findings

No required correction in the inspected scope.

Cleared concerns

  • Lifecycle identity. hasActiveDescendant (staleTurnMonitor.ts) counts another StreamClock entry only when that thread's persisted run is running and activeAttemptId equals the clock attempt. Completed and replaced attempts fail this check. The clock keeps one attempt per thread; endAttempt and a terminal turn drop liveness (streamClock.ts). The new completed and replaced cases expect a notice.
  • Ancestry. Same rootThreadId is required, then parent links must reach the watched child. A shared root alone does not suppress. Siblings stop at the common parent. Soft-deleted intermediates remain readable through ProjectionStore.getThread, which does not filter deletedAt. The deep case walks a deleted middle thread. The visited set stops cycles and then keeps scanning; a cycle is not treated as a descendant. This matches the local parent walk used for ancestor sends, including fork links. Normal subagent creation copies the top-level root, so the walk is what recognizes a grandchild. The send path's "target is the recorded root" shortcut does not apply to this watched subagent.
  • Unknown ancestry. A missing or unreadable projection during the scan fails that watched thread's check. The existing sweep catch logs prism.stale-turn.notice-failed and retries on the next sweep, without pause or notified. It does not invent descendant activity. Soft-deleted rows still resolve. I found no production lineage writer that points a live attempt at a missing parent. This path is inspected, not exercised.
  • Isolation. A different root is skipped before the walk. The sibling case reparents the streaming thread onto the watched child's parent and expects a notice. The candidate's own thread is skipped. Archived or deleted candidates do not suppress.
  • Performance. Descendant reads run only after detector.check reports suspected silence, and after the existing run, attempt, archive, delete, pending-input, retirement, and parent-visibility guards. pause sets silenceFrom to now (staleTurnDetector.ts), so a still-active descendant is scanned again only after another full allowance, not on every one-second sweep. No benchmark is claimed. Token observation and healthy samples are unchanged.
  • Eventual notice. While a qualifying descendant attempt stays live, the watched thread's advisory waits. Ending that attempt removes it from liveness. The running and deep cases then observe one notice after a fresh silence window, and no notice on the sweep immediately after endAttempt. A descendant that remains live continues to hold its ancestors; that descendant's own silence can still notify its parent. That is the selected behavior.
  • Guards and thresholds. Detector and StreamClock have no diff. Floors stay 120000 ms and 90000 ms, the measured maximum multiplier stays 1.5, and the strict confirmation multiplier stays 1.25. pause does not write timing samples. Notice text, command key, queue_after_active, agent/server notification metadata, and the absence of delegatedCompletion are unchanged. The map comment still names Deliver child notices and ancestor updates through V2 notifications #269 and PR fix(orchestration): child updates use queued V2 notifications #279, and adds PR fix(prism): respect active descendants before stale notices #342 and Stale-child notice fires while the child is waiting on its own active children #341.

Evidence

Inspected #341, diagnosis comment 6181497222, #269, and PR #279. The earlier no-nested-suppressor note covered two first-reply alerts with no newer work. This patch answers the separate idle-parent, streaming-grandchild case and does not retune those thresholds.

  • red.log: the filtered monitor run fails as intended, 1 failed and 7 skipped. The extra persisted message is an agent/server stale notification at epoch+151000, last event attempt.started at epoch, threshold 120000 ms default.
  • focused.log: vitest summary reports 3 files and 24 passed at 02:26:46. It records no exit code and no per-test names. An earlier green.log reports 20 passed. The source's five scenarios account for the difference if they replaced that one red case. The log does not stamp a SHA.
  • lint.log is empty. The claimed lint exit 0 is not in that file.
  • Final commit 1f7e1a453d differs from 60ae46b592 only by the map reference and two comments. The tested decision logic is the same text.

Commands I ran were read-only: git identity, status, log, merge-base, diff, and show; gh issue view, gh pr view, and gh api for the issue, diagnosis comment, and PR. I did not rerun tests, lint, typecheck, or a discriminating experiment. I did not start a browser, server, native client, or live provider, and I did not open live userdata. CI remains the complete-suite gate. This review is not an aggregate status and does not authorize merge.

Requirements and who asked: The user's #341 review brief requires one independent Grok verdict on this exact head, for descendant-aware stale notices that keep the #269/#279 thresholds and delivery.
Deleted: Threshold tuning, delivery or UI changes, a new clock or schema, another design round, version bumps, re-running tests, and unrelated findings.
Bottleneck: Confirming that only a current persisted descendant attempt renews the silence window, and that the advisory still arrives after that attempt ends.
Checked myself: The full base/head diff, the monitor, detector, clock, projection read, and ancestor-send walk, the issue history, the red and focused logs, the comment-only final commit, and the live PR head and base immediately before this comment.

Reviewer: Grok grok-4.7, high reasoning effort.

@lukemaj

lukemaj commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

What: PR #342 passes both required independent reviews and current CI on exact head 1f7e1a453d319ed069a5c7ed4d9ab30e5ffd986a.
Why: The descendant guard prevents the reproduced false notice while completed/replaced attempts and siblings remain valid negative controls; thresholds and V2 delivery are unchanged.
So what: Perform the delegated squash merge into main, verify #341 closes and retire only this task's resources; no restart or deployment.

Reviewed source base is 9ab53882e87a9e0a6413f74d8b313ce516721d40. Main advanced to 2ba387388074ac4ee09cc256f9800cdd9ce2b520 through #340 while review completed. I inspected its complete two-file diff: ContextmdServing.moment scopes reads to the existing WAL reader and adds contention tests; no stale monitor, clock, detector, lineage or projection code changes. The harness imports this service, but the changed method is not used by the stale sweep. Current main CI Check and all applicable jobs pass. The unchanged PR head remains mergeable and CLEAN. git merge-tree --write-tree origin/main HEAD succeeds with expected tree e10b459dfdbbabb6436982efc7e1afc08122fc40; its differences from this head are exactly those two ContextMD files. No new head, transferred verdict or combined-runtime test is claimed. Source worktree is clean. This corrects the initial claim that the reviewed source base was still current, caught by the pre-merge fetch before any merge.

  • Sol PASS, then review/independent-sol=success at 00:32:08Z, after its 00:32:00Z findings comment.
  • Grok PASS, then review/independent-grok=success at 00:42:43Z, after its 00:42:35Z findings comment.
  • Both statuses are on this exact SHA, creator lukemaj, with no supported blocking findings. Both independent tasks are complete with no pending child runs; no verdict is transferred from another candidate.
  • Fresh CI Check, all six server shards, web/tests, build, lint, typecheck, release smoke, Rust and Fork Stack Model succeed on this head. Native analysis/preview/size-sync skips are intentional unexecuted coverage, not failures. CI owns complete-suite proof; no repo-wide local command ran.
  • Local reproduction first failed with a persisted stale notice at 151 seconds despite grandchild streaming. The three-file focused suite then passed 24 cases, and changed-file lint/diff checks passed. Final commit changes only map linkage and two comments, preserving tested functional source. Reviewers inspected the source/proof and did not rerun tests; bare local logs lack SHA/exit metadata. Current exact-head CI independently covers the candidate.
  • No browser, native client, live provider, live userdata write, version bump or deployment is claimed. Remote-environment activity remains outside this local clock correction. A live but silent descendant can still notify its own parent; its ancestors continue waiting. Missing/read-failed ancestry follows the existing warning/retry path. Website/SEO impact none.

Requirements and who asked: User delegated #341 through merge, requiring red-first focused proof, Sol gpt-6.1-sol and Grok grok-4.7 child reviews with exact-head success after comments, current green CI and the map's Child notices linkage.
Deleted: Threshold tuning, new clock/schema/delivery/UI, a design round, versions, deployment/restart and unrelated work.
Bottleneck: Required reviews and CI are clear; exact-target merge verification and owned-resource cleanup complete this outcome.
Checked myself: Full current diff and history, actual red/focused proof, both full review findings and task results, status creators and comment/status timestamp order, clean source and unchanged live PR head/base/target, all current CI checks.

@lukemaj
lukemaj merged commit e2aff18 into main Oct 15, 2026
29 checks passed
@lukemaj
lukemaj deleted the fix/341-descendant-activity branch October 15, 2026 00:47
lukemaj added a commit that referenced this pull request Oct 29, 2026
* fix(prism): respect active descendants before stale notices

* docs(map): link descendant activity fix to Child notices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale-child notice fires while the child is waiting on its own active children

1 participant