fix(context): #62 lifecycle/cache/selection correctness - #86
Merged
Conversation
Addresses the #62 correctness findings from the external review of PR #81. - **lifecycle** — a required-PR-remaining check from MergedPendingDelivery no longer transitions backward to Reviewing (that reopened review after merge and broke monotonicity); it preserves the current state. - **cache mergeCache** — progressive same-work enrichment (issue → PR → phase) now merges in place instead of returning needs-reconciliation, so the cache can evolve through the delivery lifecycle; reconciliation is reserved for a contradictory shared value or a changed work_id. - **cache acquireLock** — a broken stale lock now retries the acquire ONCE and persists the current write, rather than dropping it to memory-only and letting only the next call benefit. - **managed-block selectCurrentManagedRevision** — selection is bound to the expected workId (and issue for plans); a foreign block with a higher revision in a comment can no longer win. The CLI passes these through. - 4 regression tests (backward-transition guard, foreign-block filtering, progressive enrichment, stale-lock persistence). Relates to #62. Resolves the PR #81 lifecycle, cache, and managed-block threads. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KwyFyRC6pepaK6DuMK7YeT
5 tasks
huiyu
added a commit
that referenced
this pull request
Aug 24, 2026
…F4) (#90) Independent re-verification found the #86 "worktree writer" wired to nothing: cli.mjs's deep camelizeKeys recursed into the update-cache `entry`/`attempt` payloads, mangling work_id/pull_request/pipeline_phase/updated_at into keys the snake_case cache validator rejects → mergeCache returned invalid-update and persisted nothing; active_pr/pipeline_phase were permanently null. - C1: camelizeKeys takes an opaque-key set; `entry`/`attempt` values pass through verbatim (key camelized, value untouched) so the schema keys survive. - F4: inject the repository-resolved projectId LAST so a caller-supplied project_id cannot override it. - F3: mergeCache treats an explicit `null` on the existing side as absent, so enriching `pull_request: null` -> a real PR is progressive enhancement, not a contradiction. - F2: the old UC-G8/G9 tests called mergeCache directly and bypassed the exact camelize break. Added tests/project-context/cli-update-cache.test.mjs — a real end-to-end drive of the CLI over stdin with snake_case, asserting the writer persists the pointer keys, round-trips a recovery attempt, and enforces F4. Adapters regenerated (the codex mirrors carried the identical bug). Claude-Session: https://claude.ai/code/session_01KwyFyRC6pepaK6DuMK7YeT Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourth fix off the 3.0 audit — #62 correctness bugs from the external review.
4 regression tests; full suite + generated-drift green. Base
3.0. Resolves the PR #81 lifecycle, cache (×2), and managed-block threads.Relates to #62