refactor: unify resolve_session_id() + wire pytest-gate recording (#904, #802)#1020
Open
akaszubski wants to merge 4 commits into
Open
refactor: unify resolve_session_id() + wire pytest-gate recording (#904, #802)#1020akaszubski wants to merge 4 commits into
akaszubski wants to merge 4 commits into
Conversation
…cording (#904, #802) Eliminates 3 inline copies of the session-id fallback chain in implement.md (STEP 0 ordering check, STEP 0 pipeline state init, STEP 2 alignment-gate state update) by extracting them into pipeline_completion_state.resolve_session_id(). Wires Issue #802's pytest-gate completion recording into stop_quality_gate.py so end-of-turn pytest passes auto-record under the resolved session_id (with a guard that excludes 'unknown' sessions to avoid polluting state from non- pipeline runs). Files: - lib/pipeline_completion_state.py: +46 LOC adding resolve_session_id() + module constants _IMPLEMENT_STATE_SENTINEL + _SESSION_SENTINEL_TTL_SECONDS. Docstring cites Issue #904 with the divergence example. - commands/implement.md: -49 net LOC; 3 inline copies replaced with one import. - hooks/stop_quality_gate.py: +15 LOC auto-record on pytest pass (Issue #802 wiring). - tests/test_pipeline_completion_state.py: 5 tests (env-var precedence, sentinel fallback, stale sentinel ignored, no-signal returns 'unknown', env 'unknown' treated as no signal). - tests/test_stop_quality_gate.py: 3 tests (records under real session_id, skips on 'unknown' session, skips when pytest failed). All 8 new tests pass. Provenance disclosure: this work appeared in the working tree during session b6970545 (W0 implementation, issue #1012) without being authored by the session coordinator. The most likely cause is the symlinked plugin sharing between autonomous-dev and the realign repo (verified: pytest output shows test files resolving via '<- ../../../realign/plugins/autonomous-dev/tests/...'). A session running on realign's plugin copy wrote these files; they appeared here through the symlink. Filed as #1019 for investigation + defense-in-depth (PreToolUse gate on plugin source-tree writes by ALL actors, not just the coordinator). The work is committed because: 1. It's correct (all tests pass, addresses tracked issues #904 and #802) 2. It directly addresses one mechanism of #1018 (silent enforcement bypass via session-id divergence) 3. Discarding good work that fixes real bugs because of *how* it arrived would throw the baby out with the bathwater Issues: - #904 — session-id propagation contract (this commit unifies the fallback chain) - #802 — agent completeness gate (this commit wires the pytest-gate recording) - #1019 — provenance investigation (filed in this same session) Refs: #1017 (CLAUDE.md hook deadlock protocol), #1018 (user-gated bypass), #1019 (silent agent/hook source-tree writes audit) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…1017) Adds two Critical Rules and two harness-philosophy sections: - **Hook deadlock protocol** (#1017): When a hook blocks legitimate work, surface the block to the user with the proposed bypass and wait for approval. Do NOT autonomously create .claude/.bypass or set AUTONOMOUS_DEV_BYPASS=1 — those are user-authorized signals, not model-invokable. Replicated into ~/.claude/CLAUDE.md so foreign-repo sessions see the same rule. - **Process applies WHEN doing software development**: Replaces the older "Don't simplify, redesign, or consolidate agents" rule. Codifies the intent-aware-enforcement direction from PROJECT.md — gates apply on real feature work for repos, not on testing/exploration/scratch edits. - **Documentation Alignment** + **Maintaining Core Philosophy** sections: Document the validate_claude_alignment.py pipeline and the priority order for keeping PROJECT.md / orchestrator.md / settings in sync. Closes #1017. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
commands/implement.mdintopipeline_completion_state.resolve_session_id()— single source of truth for subshell session-id resolution (Issue [ROOT-CAUSE] Pipeline state + session-ID propagation contract is undocumented infra (#898 #902 #875) #904).pytest_gate_passedauto-recording intostop_quality_gate.pyso end-of-turn pytest passes are visible to the agent-completeness gate (Issue [INCOMPLETE] researcher-local, researcher, security-auditor absent in full-mode pipeline for #1040 (TemplateEvaluator) #802 wiring).Net diff: +196 / -64.
Provenance disclosure
This work appeared in the working tree during session
b6970545(W0 implementation, issue #1012) without being authored by the session coordinator. Most likely cause: the autonomous-dev plugin source is symlinked from the realign repo (verified — pytest output shows test files resolving via<- ../../../realign/plugins/autonomous-dev/tests/...). A session running on realign's copy of the plugin wrote these files; they appeared here through the symlink during this session's runtime.Filed as #1019 with acceptance: identify root cause (this PR's symlink hypothesis is the leading candidate) + add a defense-in-depth PreToolUse gate that blocks plugin source-tree writes from any actor, not just the coordinator.
The work is being merged because:
Test plan
pytest plugins/autonomous-dev/tests/test_pipeline_completion_state.py plugins/autonomous-dev/tests/test_stop_quality_gate.py -vcommands/implement.mdSTEP 0 / STEP 2 still resolve session_id correctly (manual review of the 3 replaced call sites)record_pytest_gate_passedexists atpipeline_completion_state.py:732(referenced by newstop_quality_gate.pyauto-record path) — ✅ confirmedRelated issues
Branch
refactor/unify-resolve-session-id←master🤖 Generated with Claude Code