Add a test-only invariance gate that locks the pre-existing four-test red
baseline so IMP-35 cannot silently grow the red surface while in-flight.
u11 does NOT fix the four reds — Stage 2 follow_up_candidates tracks the
actual repair as a separate issue. u1~u10 production work remains in the
worktree and is explicitly out of this commit per Stage 3 R7 carve-out.
Frozen registry (IMP35_BASELINE_RED_NODE_IDS, set semantics):
1. tests/test_imp47b_step12_ai_wiring.py
::test_mixed_units_classified_by_route_and_provisional_flag
2. tests/test_imp47b_step12_ai_wiring.py
::test_reject_provisional_unit_reaches_router_short_circuit
3. tests/test_imp47b_step12_ai_wiring.py
::test_step12_ai_repair_artifact_writes_json_serialisable_records
4. tests/test_phase_z2_ai_fallback_config.py
::test_ai_fallback_master_flag_default_off
Gate semantics (subprocess pytest, set comparison):
- All 4 node ids resolve to collectible pytest items
(rename / delete is caught up front).
- Broader baseline-area sweep across the two registry files yields
EXACTLY 4 FAILED and 0 ERROR, with FAILED set ≡ registry.
- A new red in the baseline area flips count above 4 OR introduces a
FAILED id outside the registry; either branch fails the gate.
- Cross-lock test ensures registry node ids cannot point outside the
declared area-files inventory.
AI isolation contract (feedback_ai_isolation_contract):
Gate body uses stdlib only (subprocess + re + ast). An AST self-verify
test rejects `anthropic` imports and `route_ai_fallback` references in
this file, structurally preventing AI routing inside the gate.
Stage 4 verification (HEAD c1df656 pre-commit):
pytest -q tests/phase_z2/test_imp35_baseline_red_invariance.py
→ 7 passed in 15.26s.
Baseline area sweep
(tests/test_imp47b_step12_ai_wiring.py +
tests/test_phase_z2_ai_fallback_config.py)
→ 4 failed / 6 passed / 0 errors; FAILED set ≡ registry (identity).
pytest --collect-only on the 4 registered node ids → all 4 resolve.
py_compile clean. Codex R1 = YES (independent verify).
Guardrails honored:
- Scope-locked: test-only file; zero production code in this commit.
- 1 commit = 1 decision unit (u11 only).
- No hardcoding: registry = Stage 2 contract frozen tuple, not
sample-specific literal; gate body has zero magic constants.
- AI isolation: stdlib-only gate, AST self-verify locks isolation.
- baseline-red 4 body repair = separate follow-up issue, not u11 scope.
source_comment_ids: Stage 1 problem-review; Stage 2 plan R2 + Codex R2
YES; Stage 3 Claude #30 + Codex #31 R7 YES; Stage 4 Claude #32 + Codex
#33 R1 YES.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add resplit_all_reject_merges() helper in phase_z2_composition.py that
detects parent_merged / parent_merged_inferred units with label=reject
and rebuilds them as per-section single units using each section's own
rank-1 V4 evidence (no frame swap, MDX raw_content preserved).
Pipeline hook fires once after Step 6 settling chain (u12/u4/empty-shell)
and section_assignment_plan resolution, before Step 6 artifact write.
Guards: beneficial-split rule (>=1 non-reject), coverage equality, layout
cap (>4 abort), max_retry=1, section_assignment_override short-circuit.
Audit: comp_debug["imp48_resplit"] additive payload (applied, split_units,
skipped_units, post_split_unit_count, post_split_layout_preset);
selection_path="resplit_from_merge" telemetry on rebuilt singles;
layout_preset re-derived via select_layout_preset(new_units).
Tests: 39/39 PASS (composition u1~u6: 14 cases; pipeline u7~u9: 25 cases).
Scoped regression 720/6 with 6 failures isolated as pre-existing on
baseline 79f9ea5 (independent of IMP-48). mdx03 golden lock preserved.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bound donor capacity in plan_zone_ratio_retry by min(static_slack,
max(0, clientHeight-scrollHeight)) when both Step 14 measured fields
are present; fall back to static contract slack when absent. Prevents
the donor from being over-allocated when full-but-not-overflowing,
avoiding a wasted Selenium rerender before cascade falls to
cross_zone_redistribute.
- src/phase_z2_retry.py: planner block L122-157 only; donor filter
(L107-112), slack<=0 gate, base_plan, greedy aggregation untouched.
Adds measured_empty_px + slack_bound_source telemetry to
donor_candidates_considered (additive only).
- tests/phase_z2/test_phase_z2_retry_measured_bound.py: 5-axis
regression (static_fallback / measured<static / measured>=static /
measured==0 excludes / filter+bool guard).
Guardrails honored: V4 rank-1 frame lock preserved, no frame_swap,
no spacing/padding/gap/line-height/font shrink, no content drop,
no MDX 03/04/05 branching, no Step 14 schema mutation. Static
fallback idempotent when measured fields absent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BACKLOG line 93 + INSIGHT-MAP line 150 (verbatim mirror per anchor sync
rule). Trigger axis now requires both Phase R' archive trigger AND
§2.1/§2.2 SoT signature unification to keep guardrail = code-removal-only.
No source files touched.
Bug discovered during #24 IMP-24 K6 Stage 2 (2026-05-20):
- Codex r1, r2, r3 started with '=== IMPLEMENTATION_UNITS ===' on first line
(not '[Codex #N] ...'), so detect_agent (P0-1 strict, first-line only)
returned None.
- For non-audit issues, the P5 supplement guard was audit-only gated → silent
loop until Codex r4 happened to use correct format. 4 rounds wasted.
Verified that #21 Stage 4 had the same latent silent loop pattern
('## [Codex #1]' first line) — orchestrator looped through ~10 Claude rounds
before random recovery. P5b fix addresses this long-standing bug.
Patch (defensive parser-contract hardening; does not assume single root cause):
1. RULES global gets explicit "FIRST non-empty line MUST be [Claude #N] /
[Codex #N]" rule that OVERRIDES any stage-specific "body MUST contain"
constraint.
2. COMPACT_PLAN_RULE wording clarified: "body" begins AFTER the first-line
agent header. The 'body MUST contain ONLY' set no longer accidentally
permits '=== IMPLEMENTATION_UNITS ===' on line 1.
3. is_codex None supplement guard:
- audit-only gate REMOVED → fires for all issues (#24 latent loop fixed)
- Throttle: max 2 supplements per stage; on 3rd violation, orchestrator
hard-stops the issue with explicit "user action required" message
and exits run_stage cleanly
- Supplement message names both Claude AND Codex (Claude's first-line
violation also breaks downstream via Codex mimicry)
- Body-head 80 chars logged on detection failure (debugging aid)
4. Regression tests (+5 cases in test_orchestrator_core.py):
- TestDetectAgent: '=== IMPLEMENTATION_UNITS ===' first line → None
- TestDetectAgent: [Codex #N] first line + units after → 'codex' OK
- TestDetectAgent: '## ', '📌 **', '**' prefix all → None
- TestRulesAndCompactPlanFirstLineContract: RULES wording has FIRST/OVERRIDES
- TestRulesAndCompactPlanFirstLineContract: COMPACT_PLAN_RULE has carve-out
Cosmetic side effect (accepted): Claude's '📌 **[Claude #N] ...**' or
'## [Codex #N] ...' decoration prefixes will fail detect_agent. Agents
will drop decorations from line 1; line 2+ can still use them.
Out of scope (NOT included to keep regression risk low):
- detect_agent function logic UNCHANGED (P0-1 strict preserved)
- consensus parser UNCHANGED
- stage loop structure UNCHANGED
- git/Gitea retrieval logic UNCHANGED
- audit-only mode P4/P4a guards UNCHANGED
- pre-post comment validation (future axis, larger refactor)
Total: 131/131 pytest pass (126 prior + 5 new).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bug discovered during #56 INTEGRATION-AUDIT-02 execution (2026-05-20):
- Both Claude and Codex put "Audit anchor: ..." as the FIRST line of every
Gitea comment per the #56 issue body instruction "cite anchor at start
of every stage".
- detect_agent (P0-1 strict, first-line only) then returns None for these
comments because the first line is "Audit anchor:..." not "[Codex #N]"
or "[Claude #N]".
- Result: orchestrator's "is_codex" check (line ~1288) flips false →
"Codex 응답 미감지 — continuing" → infinite Stage 4 loop. #56 reached
Round #14 (>300 comments, ~2 hours wasted token).
Fix path (NOT relaxing detect_agent — that would revive the original #45
pre-P0-1 bug where [Claude #N] citations inside Codex bodies caused
mis-detection):
1. AUDIT_ONLY_NOTE updated to enforce comment format:
- FIRST non-empty line MUST be `[Claude #N] <stage>` or `[Codex #N] <stage>`
- Audit anchor / banners / prefaces MUST appear line 2 or later
- Concrete CORRECT example included
- Explicit warning that violation breaks stage advance
2. is_codex None guard auto-supplements:
- When _audit_mode(title) AND detect_agent returns None, orchestrator
posts a Gitea supplement comment requesting the correct format
- Next round's Claude/Codex see the supplement and correct
- Breaks the infinite loop automatically (no manual ctrl-C needed)
3. Regression tests in TestDetectAgent (test_orchestrator_core.py):
- test_audit_anchor_preface_breaks_detection: confirms P0-1 strict
correctly returns None when anchor is first line
- test_audit_anchor_after_header_works: correct format passes
Total: 96/96 pytest pass (94 prior + 2 P5 regression).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
프로젝트의 왜 / 무엇을 위해 / 어떻게 라는 질문에 대한 master 답.
이 문서가 있으면 매번 처음부터 framing 설명할 필요 없음.
구조:
1. Destination — Phase Z 22-step + AI zone-fit frame generation
2. Q~Y 검토 = 이미 완료 (과거형). 결과 = INSIGHT-MAP + 28 초기 이슈.
3. INSIGHT-MAP catalog 구조 (§0~§5)
4. IMP 이슈 좌표 체계 (관련 step + source + priority + scope + guardrails)
5. orchestrator 의 disciplined executor 역할 (Claude + Codex 합의)
6. Audit cycle (meta-governance) — 발견은 follow-up 이슈로 분리
7. 도착점 도달 기준 5 항목
8. 자주 헷갈리는 anti-patterns (heritage 보존 X, MDX 최적화 X 등)
9. 핵심 참조 문서 인덱스
10. 한 줄 요약
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Audit follow-up F-2 (INTEGRATION-AUDIT-01 §10.2). Phase Z families surface
showed 11 tracked / 11 contracted / 13 on disk. The 2 untracked WIP files
(app_sw_package_vs_solution.html, pre_construction_model_info_stacked.html)
are now declared in _WIP_FILES.md as uncontracted and out-of-scope for the
runtime matcher; promote/remove is gated on #42. The 11/11 tracked +
contracted baseline is unchanged. A new pytest enforces tracked families ↔
frame_contracts.yaml set-equality modulo the WIP allowlist parsed from
_WIP_FILES.md, so future drift fails fast in CI before #42 expands to 32
frames.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Append IMP-50 audit completion row referencing INTEGRATION-AUDIT-01-REPORT
(commit 8c7d693) with CONDITIONAL GO for #19 decision.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
P4 had two production issues blocking #50 integration audit deployment:
1. Stage 3 guard had no baseline awareness — flagged ALL forbidden-path
changes including pre-existing dirty WIP. Empirical: 328 such files
already in current working tree (tests/matching/ artifacts etc).
#50 would have hit reject loops immediately without Claude doing
anything wrong.
2. Stage 5 had no commit-scope guard — if Claude ran `git add -A` and
committed user's existing WIP, audit commit would be polluted with
unrelated production changes.
P4a additions:
- _audit_baseline_path / _ensure_audit_baseline / _load_audit_baseline:
snapshot working-tree dirty paths at run_issue entry for audit issues.
Resumed runs preserve existing baseline (no overwrite).
- _check_audit_only_violations(baseline=None): accept baseline set,
subtract from violations — only flags NEW forbidden changes introduced
after audit start.
- _check_audit_commit_scope: verify HEAD commit's file list matches
AUDIT_ALLOWED_COMMIT_GLOBS (INTEGRATION-AUDIT-*.md, BACKLOG.md).
- run_issue: save baseline on audit-mode entry only — no impact on
normal issues.
- Stage 5 (commit-push) YES gate: new guard rejects on out-of-scope
files with remediation prompt (git reset --soft + force-with-lease).
19 new tests:
- baseline subtraction (5): pre-existing removed, None=keep-all,
empty-set=catch-all, full-coverage filter, Windows path normalize.
- baseline persist (5): roundtrip, no-overwrite on resume, missing
fallback, corrupt JSON fallback, non-list fallback.
- commit scope detection (7): report-only allowed, backlog allowed,
src/ rejected, unrelated docs rejected, git error fail-open,
Windows backslash, empty commit pass.
- allowed globs sanity (2): every glob has audit marker, all under
docs/architecture/.
Total: 94/94 pytest pass (75 prior + 19 new).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Issue: #48 (IMP-15 실행-4, axis 4: debug.json + spec doc trace).
Parent: #15. Depends on 실행-1/2/3 (events + classifier outputs).
Surfaces the image/table event streams that 실행-1/2/3 already produced
and consumed, mirroring the existing `zone_geometries_px` top-level
precedent (no new pattern introduced). Adds the matching taxonomy row
to the Phase Z fit-classifier/router spec.
src/phase_z2_pipeline.py (+3):
- write_debug_json now lifts `image_events` and `table_events` to
top-level of `debug.json` via `(visual_runtime_check or {}).get(<k>, [])`,
exactly mirroring the immediately preceding `zone_geometries_px`
surfacing line. Defaults to `[]` when `visual_runtime_check` is None
— additive, no consumer-visible breakage.
docs/architecture/PHASE-Z-FIT-CLASSIFIER-ROUTER-SPEC.md (+1):
- §3.1 taxonomy adds `image_aspect_mismatch` row. Row text explicitly
marks the signal as post-render `fail_reasons` from Step 14
visual_runtime_check (rendered vs declared aspect ratio mismatch),
NOT a router-routed fit_classifier output, and notes the separate
`image_events` stream surface. Prevents future readers from wiring
this taxonomy into §3.2 priority list or §4 router action map.
tests/phase_z2/test_debug_json_event_surfacing.py (new, 2 tests):
- `test_write_debug_json_surfaces_image_and_table_events` invokes
write_debug_json with synthetic visual_runtime_check containing
both event lists; reads back the on-disk debug.json and asserts
both keys are present at top level with the exact payloads.
- `test_write_debug_json_defaults_when_visual_runtime_check_none`
asserts both new keys default to `[]` when visual_runtime_check
is None — guards the defensive `(… or {})` pattern.
tests/phase_z2/test_spec_taxonomy_image_aspect_mismatch.py (new, 2 tests):
- `test_spec_has_image_aspect_mismatch_row` opens the spec file and
asserts exactly one `^\| image_aspect_mismatch \|` row exists
inside the §3.1 table block (no markdown-parser dependency).
- `test_spec_row_marks_post_render_fail_reasons_semantic` asserts the
row text carries both "Post-render" and "fail_reasons" tokens —
enforces the Stage 1 guardrail wording.
Verification (Stage 4 PASS, Claude + Codex independent):
- pytest -q tests/phase_z2/test_debug_json_event_surfacing.py \
tests/phase_z2/test_spec_taxonomy_image_aspect_mismatch.py
→ 4 passed in 0.07s.
- git diff scope: 4 files, +148 insertions / 0 deletions.
Scope-locked: no edits to classifier (실행-3), event generation
(실행-1/2), Step 21 viewer, §3.2 priority list, §4 router action
mapping, or `table_self_overflow` taxonomy row. Pre-existing
dirty/untracked working-tree files left untouched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>