Repository navigation
Correlate cleanup retention evidence: the origin's own recording time, and every candidate - #362
Conversation
Three post-merge review findings on PR #336, all reproduced against the merged code before being fixed. The fail-open one first. Cleanup correlated retention evidence by asking when the whole CHANGE FOLDER was last committed, while the evidence it actually cited was the folder's `.openspec.yaml` staged-origin declaration. A change folder is edited for reasons that have nothing to do with its staged origin — a task checked off, a delta revised — and any such commit re-dated historical custody as post-abandonment evidence. A test that archives custody before the session, abandons, then edits `tasks.md` inside that folder deleted the abandoned branch (status 200); the exploration the branch was the only record of was preserved by nothing. `recorded_at` is now the recording time of the cited origin evidence itself, so an undated declaration has no durable recording time and the correlation refuses. Second, the machine-evidence reader answered with ONE candidate and the route correlated only that one. A tile can carry several exact-origin records; when the deterministic first predated the abandonment, cleanup refused even though a later archived change, active proposal, or executed demotion independently satisfied the retention requirement, and the operator was pushed into an explicit release they did not need. `retention_release_candidates` returns every matching record in acceptance order and the route takes the first that CORRELATES — a candidate that fails disqualifies only itself. The refusal still reports the first candidate's error, so it names the nearest miss. Nothing new is admitted: each candidate clears the same evidence bar as before, and when every candidate predates the abandonment the refusal is unchanged (pinned by its own test). Third, `git update-ref -d <ref> <old>` cannot lock a ref that is already gone, so a concurrently removed branch fails the delete rather than succeeding it. Both compare sites read the missing head back as an object id and said the branch "is at None now", describing an absence as a value. They now say it NO LONGER EXISTS and that this process deleted nothing — the prepared record still unwinds, so no artifact claims a deletion that did not happen. Tests: 4181 passed, 13 skipped across tests/ideation-dashboard (plus the five new regressions); openspec validate --all --strict 77/0; validate-ideation-dashboard-contracts 0 errors. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Hi @brettheap! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
There was a problem hiding this comment.
Pull request overview
This PR fixes three post-merge review findings from #336 in the abandoned-session cleanup flow by (1) correlating retention evidence against the origin declaration’s own recording time, (2) evaluating all matching retention candidates until one correlates, and (3) treating missing refs as an absence (not the stringified None) in refusal messaging.
Changes:
- Update retention-evidence collection to return all proposal/demotion candidates and timestamp proposal custody using the
.openspec.yamlcommit time (not the containing folder’s last edit). - Update abandoned-branch cleanup routing to iterate candidates and accept the first one that correlates with abandonment + head (without letting one failure disqualify the whole set).
- Improve
SessionGitrefusal messages for concurrently/missing refs and add regression tests covering these cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/ideation-dashboard/test_session_git.py | Adds regression tests ensuring missing-ref cases are reported as “absent” (not “None”) for delete + restore paths. |
| tests/ideation-dashboard/test_session_gates.py | Adds regression tests for origin-evidence timestamp correlation and for correlating across multiple matching retention candidates. |
| scripts/ideation_dashboard/session_git.py | Refines refusal messaging when update-ref fails due to missing refs; improves restore messaging to distinguish “still absent”. |
| scripts/ideation_dashboard/gate_routes.py | Switches cleanup to use retention_release_candidates() and correlate each candidate until one qualifies. |
| scripts/ideation_dashboard/branch_session.py | Replaces single-answer retention readers with candidate enumerators; introduces retention_release_candidates() and keeps retention_release_for() as a “first-only” helper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # EVERY candidate is correlated, not just the first: a tile can carry | ||
| # several exact-origin records, and one that predates the abandonment | ||
| # disqualifies only itself (PR #336 review finding 2). The reported | ||
| # error is the FIRST candidate's, so a refusal still names the | ||
| # nearest-miss evidence rather than whichever was tried last. |
…esolves Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
…1/5.2 ticked on the D-2 evidence) (#832) Path A PR-5, the last of the 2026-09-06 plan memo's sequence, on Brett Heap's word "merge pr-5 when green" (2026-09-09). Authority: his ruling of 2026-09-05T23:38Z "rule path A, 4.5 is a deferred successor" (#656) and ruling D-2 (the live exercise). - tasks.md: § 4.4 / § 5.1 / § 5.2 ticked on the D-2 evidence (three `- [ ]` heads removed, every ratified sentence kept byte-identical); § 4.5 untouched as a DEFERRED SUCCESSOR (#714 → 3d1b8cc). - Archived WITH promotion via `scripts/proposal-support.py . archive --date 2026-09-09` under the pinned @fission-ai/[email protected] (never a bare `openspec archive`); origin retained (declaration unchanged since da1b0e9); six frozen files R100. - Promoted: `openspec/specs/ideation-intent-plane/spec.md` NEW (7 requirements / 11 scenarios, every block byte-identical to the archived delta) and `openspec/specs/document-lifecycle/spec.md` 18 → 19 requirements ("Gates happen on main"); the new capability's `## Purpose` written by this act (no SHALL; replaces the CLI's TBD stub). openspec/specs 60 → 61; floor regeneration OWED (GRACED covered-pending 1, `created_by_candidate`), `contracts/review-lane-floor-snapshot.yaml` deliberately not edited here. - README OpenSpec Records row → archived; sweep-ledger row re-seeded with the tool (`--seed-ledger --moved-by '#832'`, one line moved); no thirteenth archive-date disposition. - Evidence (merged + green): #718 d179cc0, #727 07624d5, #735 6d3237e, xFactory #304 b2db7e47, #313 ddd19650, #345 90435875, #781 450bb60, #808 2ef7d8c, #814 c991c0f, #816 8924230, xFactory #362 119280a8, #830 202c170, xFactory #369 c2313277; D-2 live exercise: act B refusal 36d07ec, act A apply e970dfe, first autonomous merge #176 → 7681e40 (codexfactory[bot] APPROVED 2026-09-09T06:37:22Z). - Copilot round 1: one factual finding taken (a missing "where" in Purpose); two wording findings answered and resolved. Refs #656 (stays OPEN). Rule 6 LANDING window observed. Lane: openxfactory-4-opendox-extraction Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_012LiNG5Ume1boEfxSNeCmpu
Summary
The three bot-review findings on #336 arrived nine minutes before that PR merged, so they were never addressed on its branch. All three are real, all three were reproduced against the merged code, and this is the follow-up that fixes them.
maincurrently carries every defect below.Finding 1 (Codex P1) — correlate the origin evidence, not any folder edit
VERIFIED, and it was fail-OPEN.
_proposal_retention_evidencecited a change's.openspec.yamlstaged-origin declaration as its evidence but timestamped it with_path_recorded_at(root, folder)— the newest commit touching the entire change directory. A change folder is edited for reasons unrelated to its staged origin, and any such commit re-dated historical custody as post-abandonment evidence.Reproduction (now
test_a_later_edit_elsewhere_in_the_change_folder_does_not_freshen_the_origin): archive exact-origin custody before the session, abandon the session, then commit an unrelatedtasks.mdinside that archived folder. On the merged code cleanup answered200and deleted the abandoned branch — the newer exploration the branch was the only record of was preserved by nothing. The same test also proves the legitimate case still works: a later commit to the origin declaration ITSELF releases cleanup.Fix:
recorded_atis the recording time of the cited origin evidence, so evidence and timestamp cannot drift. An origin declaration with no commit of its own now has no durable recording time, which the correlation already treats as a refusal — the tightening runs in the fail-closed direction.Finding 2 (Codex P2) — evaluate every matching retention candidate
VERIFIED, fail-closed (operator friction, not a safety hole). The reader answered with ONE candidate and the route correlated only that one; when the deterministic first record predated the abandonment, cleanup refused even though a later exact-origin record independently satisfied the retention requirement.
Reproduction (now
test_a_second_matching_record_recorded_after_abandonment_releases_cleanup): two archived changes carrying the same staged origin, the first-sorted one older than the abandonment and a successor archived after it. Merged code refused with "the retention evidence was recorded ... before the session was abandoned"; the operator's only way through was an explicit human release they should not have needed.Fix:
retention_release_candidatesreturns every matching record in acceptance order (active custody, archived custody, pick fallback, receipt-proved demotion, corroborated legacy demotion) and the route takes the first that CORRELATES — a candidate that fails disqualifies only itself. The refusal still reports the FIRST candidate's error so it names the nearest miss. No candidate clears a lower evidence bar than before, and when every candidate predates the abandonment the refusal is unchanged (test_no_matching_record_after_abandonment_still_refuses_cleanuppins that half).Finding 3 (Copilot) — the missing-ref case reads as an absence
VERIFIED.
git update-ref -d <ref> <old>cannot lock a ref that is already gone (measured:error: cannot lock ref ..., rc=1), so a concurrently removed branch fails the delete rather than succeeding it — and both compare sites read the missing head back withbranch_sha()and said the branch "is at None now", describing an absence as an object id. The pre-flight compare indelete_branchhas the same defect and is the likelier site to observe it.Fix: both refusals now say the ref NO LONGER EXISTS and that this process deleted nothing, and the restore refusal distinguishes "still absent" from a value. Behaviour is unchanged and deliberately so: the transaction still refuses, the prepared cleanup record still unwinds, and no durable artifact claims a deletion that did not happen.
Validation
tests/ideation-dashboard: 4181 passed, 13 skipped (exit 0, no pipe masking the code)test_session_gates.py+test_session_git.py+test_gate_console.py— 278 passedOPENSPEC_TELEMETRY=0 openspec validate --all --strict: 77 passed, 0 failedscripts/validate-ideation-dashboard-contracts.py: 0 errors, 4 pre-existing deprecation warningsgit diff --check: cleanNotes for review
fix-abandoned-session-cleanup-terminal-statesrequirement already says historical evidence "MUST NOT release retention for the newer abandoned work"; finding 1 was code that did not honour it, and finding 2's fix is what "cleanup MUST require a fresh machine disposition" means when a fresh one exists. No ratified text becomes false, so nothing here needed one. Flagging it rather than deciding it.openspec/specs/ideation-dashboard/spec.md. This branch deliberately touches neither the packet nor the canonical spec, so the two do not conflict — but they should land in a sensible order.retention_release_forsurvives as the single-answer reader with a docstring saying what it cannot express; nothing in the tree calls it any more.Follow-up to #336 (merged). 🤖 Generated with Claude Code