diff --git a/.egg-state/brc-history/3200-implement-slice-4.json b/.egg-state/brc-history/3200-implement-slice-4.json new file mode 100644 index 0000000000..a13bec67fd --- /dev/null +++ b/.egg-state/brc-history/3200-implement-slice-4.json @@ -0,0 +1,752 @@ +[ + { + "id": "ca34b944-3735-4b", + "pipeline_id": "issue-3200", + "from_role": "coder", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=propose (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:40:16.433074+00:00", + "phase": "implement" + }, + { + "id": "c735e7d6-e0e2-41", + "pipeline_id": "issue-3200", + "from_role": "tester", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=propose (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:40:17.718054+00:00", + "phase": "implement" + }, + { + "id": "ecfa0eaa-6897-4a", + "pipeline_id": "issue-3200", + "from_role": "documenter", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=propose (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:40:18.774940+00:00", + "phase": "implement" + }, + { + "id": "92f0ece7-1d70-49", + "pipeline_id": "issue-3200", + "from_role": "documenter", + "to_role": "all", + "message_type": "CONSENSUS_PROPOSE", + "subject": "Proposal from documenter", + "body": "documenter: no documentation changes for slice-4 (protected-root renderer). Slice-4 lands a deterministic, byte-stable, role-parameterized protected-root renderer in shared/egg_anchor/ + shared/egg_agent/. It is internal infrastructure: no CLI surface, no user-facing API, and not wired into any event-pump role (wiring + the single feature flag are slice-9; the whole context-discipline path is OFF by default until then). The coherent doc deliverable \u2014 egg_anchor/README.md \"Files\"/section updates covering the renderer (and the slice-3 brc_derive layer), plus a context-discipline guide under docs/ \u2014 belongs at the generalization slice (slice-9)/PR phase when the public surface stabilizes and the flag exists to document. Consistent with the documenter's slice-1 no_changes_needed verdict for the same pre-wiring rationale.", + "metadata": { + "payload": { + "summary": "documenter: no documentation changes for slice-4 (protected-root renderer). Slice-4 lands a deterministic, byte-stable, role-parameterized protected-root renderer in shared/egg_anchor/ + shared/egg_agent/. It is internal infrastructure: no CLI surface, no user-facing API, and not wired into any event-pump role (wiring + the single feature flag are slice-9; the whole context-discipline path is OFF by default until then). The coherent doc deliverable \u2014 egg_anchor/README.md \"Files\"/section updates covering the renderer (and the slice-3 brc_derive layer), plus a context-discipline guide under docs/ \u2014 belongs at the generalization slice (slice-9)/PR phase when the public surface stabilizes and the flag exists to document. Consistent with the documenter's slice-1 no_changes_needed verdict for the same pre-wiring rationale.", + "attestation": {}, + "artifacts": [], + "risk_considered": "", + "commit_sha": "", + "files_changed": [], + "tests_run": [], + "tasks_satisfied": [], + "no_changes_needed": true, + "no_changes_reason": "Slice-4 is internal-only infrastructure (protected-root renderer) with no user-facing surface, gated OFF behind a not-yet-built feature flag (slice-9). No documentation is reachable or stable to update at this slice; component-README and guide updates are deferred to slice-9/PR phase when the mechanism is wired and flag-gated. The slice-4 renderer code is also not yet on the branch (HEAD=slice-3 completion), so no accurate docs can be authored against it now." + }, + "version": 1, + "commit_sha": "", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:41:45.756319+00:00", + "phase": "implement" + }, + { + "id": "54ae7548-0abd-47", + "pipeline_id": "issue-3200", + "from_role": "coder", + "to_role": "all", + "message_type": "CONSENSUS_PROPOSE", + "subject": "Proposal from coder", + "body": "slice-4 task-4-1: deterministic protected-root renderer. New shared/egg_anchor/protected_root.py exposes render_protected_root() assembling the event-pump agent's protected root in fixed order: (a) role contract, (b) task anchor (compose_task_description #3163 output, passed in by caller), (c) the #3189 deterministic anchors (BRCDerivedAnchors derived in slice-3), (d) non-negotiable directives. Byte-stable for identical input: keyed anchor collections sorted (SHA map by producer; verdicts/NACKs/obligations by (producer,reviewer)), list counts bounded by overridable RootCaps caps, free-form sections char-capped, NO timestamps/sequence/nondeterministic ordering. Role-parameterized (header + role_contract arg) so two roles render distinct-but-each-stable roots. Pure: accepts already-composed strings so egg_anchor gains no new dependency; section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, never agent prose, so the authoritative anchor layer cannot drift. Exported render_protected_root + RootCaps from egg_anchor.", + "metadata": { + "payload": { + "summary": "slice-4 task-4-1: deterministic protected-root renderer. New shared/egg_anchor/protected_root.py exposes render_protected_root() assembling the event-pump agent's protected root in fixed order: (a) role contract, (b) task anchor (compose_task_description #3163 output, passed in by caller), (c) the #3189 deterministic anchors (BRCDerivedAnchors derived in slice-3), (d) non-negotiable directives. Byte-stable for identical input: keyed anchor collections sorted (SHA map by producer; verdicts/NACKs/obligations by (producer,reviewer)), list counts bounded by overridable RootCaps caps, free-form sections char-capped, NO timestamps/sequence/nondeterministic ordering. Role-parameterized (header + role_contract arg) so two roles render distinct-but-each-stable roots. Pure: accepts already-composed strings so egg_anchor gains no new dependency; section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, never agent prose, so the authoritative anchor layer cannot drift. Exported render_protected_root + RootCaps from egg_anchor.", + "attestation": {}, + "artifacts": [ + "shared/egg_anchor/protected_root.py" + ], + "risk_considered": "Renderer is pure and additive (new module + two additive __init__ exports); no existing call sites changed, so no behavioural regression to the legacy full-context path. egg_anchor takes on no new package dependency (task_description composed by caller). Determinism verified manually (dict/list reorder -> identical bytes; cap truncation; role parameterization). ruff + mypy clean; 105 existing egg_anchor tests pass. Per-section caps default generous (truncation is a backstop, not the common path). Section (c) is authoritative-only (mechanically derived), so a stale/wrong agent claim cannot enter the protected root here.", + "commit_sha": "a3dc986c395473c26b72366891c721a3170e0a5b", + "files_changed": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py" + ], + "tests_run": [], + "tasks_satisfied": [ + "task-4-1" + ], + "no_changes_needed": false, + "no_changes_reason": "" + }, + "version": 1, + "commit_sha": "a3dc986c395473c26b72366891c721a3170e0a5b", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:00.699077+00:00", + "phase": "implement" + }, + { + "id": "9502c0fa-9401-45", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code_holistic", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=ack (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:09.379502+00:00", + "phase": "implement" + }, + { + "id": "854fd484-98a1-44", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=ack (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:10.437036+00:00", + "phase": "implement" + }, + { + "id": "a19be2f5-83e0-46", + "pipeline_id": "issue-3200", + "from_role": "reviewer_contract", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=ack (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:10.468082+00:00", + "phase": "implement" + }, + { + "id": "b276acb1-740e-48", + "pipeline_id": "issue-3200", + "from_role": "reviewer_security", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=ack (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:10.500241+00:00", + "phase": "implement" + }, + { + "id": "9c38d421-150c-49", + "pipeline_id": "issue-3200", + "from_role": "reviewer_concurrency", + "to_role": "all", + "message_type": "HEARTBEAT", + "subject": "heartbeat: WORKING", + "body": "one-shot event arm action=ack (slice=slice-4)", + "metadata": { + "state": "WORKING", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:45:11.539970+00:00", + "phase": "implement" + }, + { + "id": "b2f1d78b-829f-4d", + "pipeline_id": "issue-3200", + "from_role": "reviewer_contract", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_contract for coder", + "body": "task-4-1 AC fully satisfied. (1) Four sections in FIXED order behind a role header: (a) ROLE CONTRACT, (b) TASK, (c) BRC ANCHORS #3189, (d) NON-NEGOTIABLE DIRECTIVES. (2) Byte-stable: every keyed anchor collection sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)), list counts bounded by RootCaps, free-form sections char-capped, no timestamps/sequence-numbers/nondeterministic ordering. (3) Role-parameterized via header + role_contract arg. (4) Section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (slice-3) \u2014 no agent-authored prose path, authoritative anchor layer cannot drift. Verified all attributes used (last_reviewed_sha.items, latest_verdicts[].producer/reviewer/verdict.value/version/reviewed_sha, open_nacks[].reason, conditional_ack_obligations[].condition/resolved) match the slice-3 model exactly; ReviewVerdict is a StrEnum so .value is valid. Renderer is pure (no new egg_anchor dep); deferring compose_task_description (#3163) to the caller is a documented purity choice consistent with the AC (task anchor is composed via #3163 at the wire-up site, not necessarily inside the renderer). Byte-stability/cap/role tests are task-4-2 (tester), correctly out of scope here. ruff+mypy clean per coder notes; 105 existing egg_anchor tests pass.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py" + ], + "reason": "task-4-1 AC fully satisfied. (1) Four sections in FIXED order behind a role header: (a) ROLE CONTRACT, (b) TASK, (c) BRC ANCHORS #3189, (d) NON-NEGOTIABLE DIRECTIVES. (2) Byte-stable: every keyed anchor collection sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)), list counts bounded by RootCaps, free-form sections char-capped, no timestamps/sequence-numbers/nondeterministic ordering. (3) Role-parameterized via header + role_contract arg. (4) Section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (slice-3) \u2014 no agent-authored prose path, authoritative anchor layer cannot drift. Verified all attributes used (last_reviewed_sha.items, latest_verdicts[].producer/reviewer/verdict.value/version/reviewed_sha, open_nacks[].reason, conditional_ack_obligations[].condition/resolved) match the slice-3 model exactly; ReviewVerdict is a StrEnum so .value is valid. Renderer is pure (no new egg_anchor dep); deferring compose_task_description (#3163) to the caller is a documented purity choice consistent with the AC (task anchor is composed via #3163 at the wire-up site, not necessarily inside the renderer). Byte-stability/cap/role tests are task-4-2 (tester), correctly out of scope here. ruff+mypy clean per coder notes; 105 existing egg_anchor tests pass.", + "ack_version": 1, + "attestation": { + "tasks_verified": [ + "task-4-1" + ] + } + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:46:21.292839+00:00", + "phase": "implement" + }, + { + "id": "1393a016-1356-41", + "pipeline_id": "issue-3200", + "from_role": "reviewer_security", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_security for coder", + "body": "Security ACK (slice-4, task-4-1). Pure dependency-free renderer with no injection sinks: no eval/exec/subprocess, no path ops, no deserialization of untrusted data, no env/secret reads or logging. Output is plain f-string interpolation into labeled sections \u2014 no .format() on attacker-controlled keys. Resource-bound safety is a positive: all sections hard-capped (char caps on free-form, count caps + elision on anchor lists) so a pathological contract/anchor set cannot unboundedly inflate the resident root; char-based truncation keeps output valid UTF-8. Non-blocking note: NACK reason / conditional-ACK condition are agent-authored free text entering the resident root, but bounded to 300 chars, clearly delimited, required for actionability, and sourced from the trusted same-pipeline BRC message stream \u2014 not an external boundary. No security blockers.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py" + ], + "reason": "Security ACK (slice-4, task-4-1). Pure dependency-free renderer with no injection sinks: no eval/exec/subprocess, no path ops, no deserialization of untrusted data, no env/secret reads or logging. Output is plain f-string interpolation into labeled sections \u2014 no .format() on attacker-controlled keys. Resource-bound safety is a positive: all sections hard-capped (char caps on free-form, count caps + elision on anchor lists) so a pathological contract/anchor set cannot unboundedly inflate the resident root; char-based truncation keeps output valid UTF-8. Non-blocking note: NACK reason / conditional-ACK condition are agent-authored free text entering the resident root, but bounded to 300 chars, clearly delimited, required for actionability, and sourced from the trusted same-pipeline BRC message stream \u2014 not an external boundary. No security blockers.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:46:22.622188+00:00", + "phase": "implement" + }, + { + "id": "c69ded21-5fdd-47", + "pipeline_id": "issue-3200", + "from_role": "reviewer_concurrency", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_concurrency for coder", + "body": "Concurrency lens \u2014 clean ACK. render_protected_root is a pure, side-effect-free renderer: it reads immutable inputs (already-composed strings + a BRCDerivedAnchors snapshot) and returns a string. No module-level mutable state (only str constants and __all__), no shared cache, no async/locks/subprocess, no external calls or retry loops, and it does not touch the BRC message bus \u2014 no send\u2192wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound is involved. sorted() builds new lists and never mutates the input models; the mutable-default-argument pitfall is avoided (caps/directives default to None). No race, deadlock, async-context leak, retry-storm, or resource-cleanup-ordering finding in scope.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py" + ], + "reason": "Concurrency lens \u2014 clean ACK. render_protected_root is a pure, side-effect-free renderer: it reads immutable inputs (already-composed strings + a BRCDerivedAnchors snapshot) and returns a string. No module-level mutable state (only str constants and __all__), no shared cache, no async/locks/subprocess, no external calls or retry loops, and it does not touch the BRC message bus \u2014 no send\u2192wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound is involved. sorted() builds new lists and never mutates the input models; the mutable-default-argument pitfall is avoided (caps/directives default to None). No race, deadlock, async-context leak, retry-storm, or resource-cleanup-ordering finding in scope.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:46:31.380250+00:00", + "phase": "implement" + }, + { + "id": "01666099-7dba-40", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code_holistic", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_code_holistic for coder", + "body": "Holistic lens, all four passes clean on the slice-4 task-4-1 protected-root renderer. (1) End-to-end use case: contract AC met \u2014 fixed four-section order (role contract / task / #3189 anchors / directives), byte-stable, role-parameterized, section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors; the event-pump consumer is correctly deferred to the slice-9 flag-wiring per the ratified DAG, so the unwired renderer is sequencing, not a silently-dropped output. (2) Doc\u2194code symmetry: byte-stability claims hold (keyed collections sorted, counts/chars capped, no timestamps; directives preserve caller order deterministically); the docstring's caller hook egg_contracts.loader.compose_task_description exists (loader.py:204). (3) Synthetic-key/sentinel: (none), truncation marker, OPEN/resolved labels are display-only LLM-facing strings with no cross-module equality consumer \u2014 no __checkout__-style dead-end. (4) Silent-fallback: derived=None placeholder and truncation both emit visible markers (not silent), no broad excepts. Cross-module field symmetry with BRCDerivedAnchors/ReviewEdgeVerdict/OpenNack/ConditionalAckObligation is exact and ReviewVerdict StrEnum.value renders correctly. Non-blocking nit (not gating): role or \"unknown\" default could mask an unset-role wiring bug, but role plumbing is validated at slice-9.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py" + ], + "reason": "Holistic lens, all four passes clean on the slice-4 task-4-1 protected-root renderer. (1) End-to-end use case: contract AC met \u2014 fixed four-section order (role contract / task / #3189 anchors / directives), byte-stable, role-parameterized, section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors; the event-pump consumer is correctly deferred to the slice-9 flag-wiring per the ratified DAG, so the unwired renderer is sequencing, not a silently-dropped output. (2) Doc\u2194code symmetry: byte-stability claims hold (keyed collections sorted, counts/chars capped, no timestamps; directives preserve caller order deterministically); the docstring's caller hook egg_contracts.loader.compose_task_description exists (loader.py:204). (3) Synthetic-key/sentinel: (none), truncation marker, OPEN/resolved labels are display-only LLM-facing strings with no cross-module equality consumer \u2014 no __checkout__-style dead-end. (4) Silent-fallback: derived=None placeholder and truncation both emit visible markers (not silent), no broad excepts. Cross-module field symmetry with BRCDerivedAnchors/ReviewEdgeVerdict/OpenNack/ConditionalAckObligation is exact and ReviewVerdict StrEnum.value renders correctly. Non-blocking nit (not gating): role or \"unknown\" default could mask an unset-role wiring bug, but role plumbing is validated at slice-9.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:47:06.665404+00:00", + "phase": "implement" + }, + { + "id": "4fccf36b-b8ac-42", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_code for coder", + "body": "ACK task-4-1 (slice-4) protected-root renderer at a3dc986. render_protected_root assembles the fixed four-section root (role contract / task anchor / #3189 BRCDerivedAnchors / non-negotiable directives) as a pure, dependency-light function. Audited the full diff + verified empirically by materializing the proposed file in isolation and exercising it with pydantic: (1) BYTE-STABLE \u2014 identical (role, contract, task, derived, directives) renders identical bytes regardless of dict insertion / list order, because every keyed collection is sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)) and no timestamps/sequence numbers enter the output; (2) ROLE-PARAMETERIZED \u2014 two roles render distinct-but-each-stable roots; (3) section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (no agent prose inlined), so the authoritative anchor layer cannot drift; (4) per-section char caps + count caps (RootCaps) enforced with a stable truncation marker; (5) None/empty inputs degrade to \"(none)\" / \"(no reviewed proposals yet)\"; (6) no circular import (protected_root \u2192 models only); (7) all field accesses match models.py (ReviewEdgeVerdict/OpenNack/ConditionalAckObligation, verdict.value StrEnum). All four AC clauses met. Lone nit (non-blocking, not a NACK): _truncate with a cap < len(marker)=13 would return a string slightly longer than the cap \u2014 unreachable via the \u2265300 defaults, pathological-only. Tests (byte-stability/caps/sort/role) are task-4-2 (tester), correctly out of this proposal's scope.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py", + "shared/egg_anchor/models.py" + ], + "reason": "ACK task-4-1 (slice-4) protected-root renderer at a3dc986. render_protected_root assembles the fixed four-section root (role contract / task anchor / #3189 BRCDerivedAnchors / non-negotiable directives) as a pure, dependency-light function. Audited the full diff + verified empirically by materializing the proposed file in isolation and exercising it with pydantic: (1) BYTE-STABLE \u2014 identical (role, contract, task, derived, directives) renders identical bytes regardless of dict insertion / list order, because every keyed collection is sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)) and no timestamps/sequence numbers enter the output; (2) ROLE-PARAMETERIZED \u2014 two roles render distinct-but-each-stable roots; (3) section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (no agent prose inlined), so the authoritative anchor layer cannot drift; (4) per-section char caps + count caps (RootCaps) enforced with a stable truncation marker; (5) None/empty inputs degrade to \"(none)\" / \"(no reviewed proposals yet)\"; (6) no circular import (protected_root \u2192 models only); (7) all field accesses match models.py (ReviewEdgeVerdict/OpenNack/ConditionalAckObligation, verdict.value StrEnum). All four AC clauses met. Lone nit (non-blocking, not a NACK): _truncate with a cap < len(marker)=13 would return a string slightly longer than the cap \u2014 unreachable via the \u2265300 defaults, pathological-only. Tests (byte-stability/caps/sort/role) are task-4-2 (tester), correctly out of this proposal's scope.", + "ack_version": 1, + "attestation": { + "files_reviewed": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py", + "shared/egg_anchor/models.py" + ], + "issues_found": 0, + "verification": "isolated import + determinism harness run against the proposed SHA", + "checks": [ + "byte_stability", + "role_parameterization", + "none_empty_handling", + "cap_truncation", + "no_circular_import", + "model_field_parity" + ] + } + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:47:38.542305+00:00", + "phase": "implement" + }, + { + "id": "50be071f-3392-43", + "pipeline_id": "issue-3200", + "from_role": "tester", + "to_role": "all", + "message_type": "CONSENSUS_PROPOSE", + "subject": "Proposal from tester", + "body": "slice-4 task-4-2: deterministic protected-root renderer tests \u2014 CONVERGED on merged coder renderer (task-4-1, a3dc986c3). shared/egg_anchor/tests/test_protected_root.py asserts the four task-4-2 acceptance properties: byte-stability (identical input -> identical bytes), hard per-section-cap truncation (free-text + #3189-anchor sections), sort-stability (output independent of dict-key/list-element input order), and role-parameterization (distinct-but-each-stable roots), plus a fixed a->b->c->d section-order check. Flexible parallel-producer locators resolved the coder's renderer with NO test changes after merge. All 6 tests PASS against the real renderer; full shared/egg_anchor suite 111 passed; ruff clean. Change is a test-only addition (no runtime/security surface).", + "metadata": { + "payload": { + "summary": "slice-4 task-4-2: deterministic protected-root renderer tests \u2014 CONVERGED on merged coder renderer (task-4-1, a3dc986c3). shared/egg_anchor/tests/test_protected_root.py asserts the four task-4-2 acceptance properties: byte-stability (identical input -> identical bytes), hard per-section-cap truncation (free-text + #3189-anchor sections), sort-stability (output independent of dict-key/list-element input order), and role-parameterization (distinct-but-each-stable roots), plus a fixed a->b->c->d section-order check. Flexible parallel-producer locators resolved the coder's renderer with NO test changes after merge. All 6 tests PASS against the real renderer; full shared/egg_anchor suite 111 passed; ruff clean. Change is a test-only addition (no runtime/security surface).", + "attestation": { + "tests_run": 6, + "checks_passed": [ + "lint", + "test", + "security" + ], + "tests_passed": 6, + "suite_passed": 111, + "security_note": "test-only addition (shared/egg_anchor/tests/test_protected_root.py); no subprocess/eval/network/secret surface; bandit/safety/trivy not runnable locally in this sandbox", + "notes": "6/6 task-4-2 tests PASS against merged coder renderer a3dc986c3; ruff clean" + }, + "artifacts": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "risk_considered": "Coder renderer (task-4-1) merged into this branch; tests execute against the real implementation. All four acceptance properties verified PASS; no regression (full egg_anchor suite 111 passed). The artifact is a single pytest module with no subprocess/eval/network/secret usage, so it carries no security surface; bandit/safety/trivy are gateway-side gates not runnable in this sandbox.", + "commit_sha": "1f4b9167a", + "files_changed": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "tests_run": [], + "tasks_satisfied": [ + "task-4-2" + ], + "no_changes_needed": false, + "no_changes_reason": "" + }, + "version": 1, + "commit_sha": "1f4b9167a", + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:48:41.251980+00:00", + "phase": "implement" + }, + { + "id": "7616b874-2f7b-41", + "pipeline_id": "issue-3200", + "from_role": "orchestrator", + "to_role": "documenter", + "message_type": "STATUS", + "subject": "Ready to confirm \u2014 all confirm preconditions satisfied", + "body": "Your proposal (version 1) is ready to confirm \u2014 all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm.", + "metadata": { + "ready_to_confirm": true, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:48:41.253630+00:00", + "phase": "implement" + }, + { + "id": "bf30bbe2-bed4-45", + "pipeline_id": "issue-3200", + "from_role": "documenter", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by documenter", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:48:47.467275+00:00", + "phase": "implement" + }, + { + "id": "75de8005-f6b7-4e", + "pipeline_id": "issue-3200", + "from_role": "reviewer_concurrency", + "to_role": "tester", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_concurrency for tester", + "body": "Concurrency lens \u2014 clean ACK. test_protected_root.py is a pure, deterministic pytest module with no concurrency surface. Module-level locator tables (_RENDERER_CANDIDATES tuple, _ALIAS_GROUPS/_CANONICAL_ORDER dicts) are read-only constants, never mutated; no shared mutable cache. Fixture builders (_canonical_inputs, _anchors, _task_anchor) construct fresh objects per call, so tests are isolated and safe even under pytest-xdist. _variants copies via dict(base) and never mutates its inputs; model_dump()/list(reversed(...)) build new objects \u2014 no aliasing/shared-state hazard, and the sort-stability test passes independent anchor instances. No async/threads/locks/subprocess, no retry loops, no BRC message-bus interaction (no send\u2192wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound), and no resource-cleanup ordering. No race, deadlock, async-context leak, retry-storm, or cleanup-ordering finding in scope.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "reason": "Concurrency lens \u2014 clean ACK. test_protected_root.py is a pure, deterministic pytest module with no concurrency surface. Module-level locator tables (_RENDERER_CANDIDATES tuple, _ALIAS_GROUPS/_CANONICAL_ORDER dicts) are read-only constants, never mutated; no shared mutable cache. Fixture builders (_canonical_inputs, _anchors, _task_anchor) construct fresh objects per call, so tests are isolated and safe even under pytest-xdist. _variants copies via dict(base) and never mutates its inputs; model_dump()/list(reversed(...)) build new objects \u2014 no aliasing/shared-state hazard, and the sort-stability test passes independent anchor instances. No async/threads/locks/subprocess, no retry loops, no BRC message-bus interaction (no send\u2192wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound), and no resource-cleanup ordering. No race, deadlock, async-context leak, retry-storm, or cleanup-ordering finding in scope.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:49:30.788788+00:00", + "phase": "implement" + }, + { + "id": "2d3b5be8-1cb2-41", + "pipeline_id": "issue-3200", + "from_role": "reviewer_concurrency", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_concurrency", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:49:34.969825+00:00", + "phase": "implement" + }, + { + "id": "8cf33e54-a6c4-46", + "pipeline_id": "issue-3200", + "from_role": "reviewer_security", + "to_role": "tester", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_security for tester", + "body": "Security ACK (slice-4, task-4-2). Test-only artifact (503 lines, single new file); merge brings in the already-ACKed coder renderer a3dc986c3. No injection sinks or trust-boundary crossings: no eval/exec/compile, no subprocess/os.system, no file I/O or path ops, no network. The dynamic import (__import__/getattr) is restricted to a hardcoded closed-set candidate tuple \u2014 no data- or attacker-controlled import target. No untrusted deserialization (model_dump runs on test-constructed Pydantic models), no env/secret reads, no sensitive logging. Safe bytes.decode(utf-8, replace). The deliberate ~4-5MB filler inputs are in-memory test-only and assert the renderer's hard per-section caps \u2014 directly pinning the resident-root-inflation defense flagged on the coder renderer, a security positive. No security blockers.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "reason": "Security ACK (slice-4, task-4-2). Test-only artifact (503 lines, single new file); merge brings in the already-ACKed coder renderer a3dc986c3. No injection sinks or trust-boundary crossings: no eval/exec/compile, no subprocess/os.system, no file I/O or path ops, no network. The dynamic import (__import__/getattr) is restricted to a hardcoded closed-set candidate tuple \u2014 no data- or attacker-controlled import target. No untrusted deserialization (model_dump runs on test-constructed Pydantic models), no env/secret reads, no sensitive logging. Safe bytes.decode(utf-8, replace). The deliberate ~4-5MB filler inputs are in-memory test-only and assert the renderer's hard per-section caps \u2014 directly pinning the resident-root-inflation defense flagged on the coder renderer, a security positive. No security blockers.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:49:38.686903+00:00", + "phase": "implement" + }, + { + "id": "0bbb8685-830b-4a", + "pipeline_id": "issue-3200", + "from_role": "reviewer_security", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_security", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:49:40.096788+00:00", + "phase": "implement" + }, + { + "id": "864c5129-987e-47", + "pipeline_id": "issue-3200", + "from_role": "coder", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by coder", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:50:21.690701+00:00", + "phase": "implement" + }, + { + "id": "101fff71-947a-46", + "pipeline_id": "issue-3200", + "from_role": "tester", + "to_role": "coder", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from tester for coder", + "body": "ACK task-4-1 (protected-root renderer). All AC met: (1) fixed four-section order (header + ROLE CONTRACT/TASK/BRC ANCHORS #3189/NON-NEGOTIABLE DIRECTIVES); (2) byte-stable \u2014 pure function, keyed collections sorted (last_reviewed_sha by producer, verdicts/nacks/obligations by (producer,reviewer)), counts bounded by RootCaps, free-form sections char-capped, no timestamps/random/global state; (3) role-parameterized via header (distinct-but-each-stable); (4) section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, no agent prose. Verified every field reference matches models.py (last_reviewed_sha dict, ReviewEdgeVerdict.verdict.value, OpenNack.reason, ConditionalAckObligation.condition/.resolved). Syntax parses cleanly; purely additive (new file + __init__ exports), no existing-surface breakage. Testability (tester lens): pure fn with injected inputs + explicit RootCaps knobs \u2014 all AC-mapped behaviors observable from the return string, ideal for the task-4-2 unit tests (byte-stability, cap-truncation, sort-stability, role-parameterization). Non-blocking nit for my own edge tests: _truncate returns marker (len > max_chars) when max_chars < marker length (~13); never bites at default caps (>=300).", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/protected_root.py", + "shared/egg_anchor/__init__.py", + "shared/egg_anchor/models.py" + ], + "reason": "ACK task-4-1 (protected-root renderer). All AC met: (1) fixed four-section order (header + ROLE CONTRACT/TASK/BRC ANCHORS #3189/NON-NEGOTIABLE DIRECTIVES); (2) byte-stable \u2014 pure function, keyed collections sorted (last_reviewed_sha by producer, verdicts/nacks/obligations by (producer,reviewer)), counts bounded by RootCaps, free-form sections char-capped, no timestamps/random/global state; (3) role-parameterized via header (distinct-but-each-stable); (4) section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, no agent prose. Verified every field reference matches models.py (last_reviewed_sha dict, ReviewEdgeVerdict.verdict.value, OpenNack.reason, ConditionalAckObligation.condition/.resolved). Syntax parses cleanly; purely additive (new file + __init__ exports), no existing-surface breakage. Testability (tester lens): pure fn with injected inputs + explicit RootCaps knobs \u2014 all AC-mapped behaviors observable from the return string, ideal for the task-4-2 unit tests (byte-stability, cap-truncation, sort-stability, role-parameterization). Non-blocking nit for my own edge tests: _truncate returns marker (len > max_chars) when max_chars < marker length (~13); never bites at default caps (>=300).", + "ack_version": 1, + "attestation": { + "tasks_verified": [ + "task-4-1" + ], + "ac_verified": [ + "fixed-four-section-order", + "byte-stability-determinism", + "role-parameterization", + "section-c-from-deterministic-anchors-only" + ], + "tests_run": 0, + "tests_execution_blocked": true, + "tests_execution_blocked_reason": "Reviewing coder implementation in isolated worktree; no .venv present in tester worktree. task-4-2 (tester unit tests) is the separate producer event where tests are authored/run. Static review confirms testability: pure deterministic function, no hidden nondeterminism." + } + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:50:44.643982+00:00", + "phase": "implement" + }, + { + "id": "9d839c9c-c540-43", + "pipeline_id": "issue-3200", + "from_role": "orchestrator", + "to_role": "coder", + "message_type": "STATUS", + "subject": "Ready to confirm \u2014 all confirm preconditions satisfied", + "body": "Your proposal (version 1) is ready to confirm \u2014 all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm.", + "metadata": { + "ready_to_confirm": true, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:50:44.645741+00:00", + "phase": "implement" + }, + { + "id": "2b545180-6000-43", + "pipeline_id": "issue-3200", + "from_role": "reviewer_contract", + "to_role": "tester", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_contract for tester", + "body": "task-4-2 fully satisfied. test_protected_root.py asserts all four task-4-2 acceptance properties for the slice-4 protected-root renderer, plus fixed section order: (1) byte-stability \u2014 two renders of identical input are byte-for-byte equal; (2) hard per-section caps \u2014 oversized free-text (role_contract) AND oversized #3189-anchor (5000 open_nacks) sections are bounded well below raw input size, with head-sentinel surviving (truncated not dropped); (3) sort-stability \u2014 permuting dict-key and list-element input order yields identical bytes; (4) role-parameterization \u2014 distinct roles render distinct-but-each-stable roots; plus a soft a->b->c->d order check guarded on locatable sentinels. Verified: imports (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict) and every field used match the merged slice-3 model in shared/egg_anchor/models.py exactly. The skip-guard locator resolves the REAL coder renderer egg_anchor.protected_root.render_protected_root (RootCaps/_truncate/_render_anchors present at merge commit 1f4b9167a) \u2014 tests ACTIVATE rather than skip: 6/6 PASS. ruff clean. Skip-guard/flexible-invocation convention matches sibling test_brc_anchor_derivation.py, keeping the suite green pre-merge and converging at PR assembly. Path shared/egg_anchor/tests/ is within the tester domain. First review: no prior NACK blockers; no new delta findings.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/tests/test_protected_root.py", + "shared/egg_anchor/models.py", + "shared/egg_anchor/protected_root.py" + ], + "reason": "task-4-2 fully satisfied. test_protected_root.py asserts all four task-4-2 acceptance properties for the slice-4 protected-root renderer, plus fixed section order: (1) byte-stability \u2014 two renders of identical input are byte-for-byte equal; (2) hard per-section caps \u2014 oversized free-text (role_contract) AND oversized #3189-anchor (5000 open_nacks) sections are bounded well below raw input size, with head-sentinel surviving (truncated not dropped); (3) sort-stability \u2014 permuting dict-key and list-element input order yields identical bytes; (4) role-parameterization \u2014 distinct roles render distinct-but-each-stable roots; plus a soft a->b->c->d order check guarded on locatable sentinels. Verified: imports (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict) and every field used match the merged slice-3 model in shared/egg_anchor/models.py exactly. The skip-guard locator resolves the REAL coder renderer egg_anchor.protected_root.render_protected_root (RootCaps/_truncate/_render_anchors present at merge commit 1f4b9167a) \u2014 tests ACTIVATE rather than skip: 6/6 PASS. ruff clean. Skip-guard/flexible-invocation convention matches sibling test_brc_anchor_derivation.py, keeping the suite green pre-merge and converging at PR assembly. Path shared/egg_anchor/tests/ is within the tester domain. First review: no prior NACK blockers; no new delta findings.", + "ack_version": 1, + "attestation": { + "tasks_verified": [ + "task-4-2" + ] + } + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:50:48.067679+00:00", + "phase": "implement" + }, + { + "id": "3abc0e78-cc31-4e", + "pipeline_id": "issue-3200", + "from_role": "reviewer_contract", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_contract", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:50:49.912081+00:00", + "phase": "implement" + }, + { + "id": "45aeed90-16b6-4d", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code_holistic", + "to_role": "tester", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_code_holistic for tester", + "body": "Holistic lens, all four passes clean on slice-4 task-4-2 (test_protected_root.py). (1) End-to-end: tests all four task-4-2 ACs (byte-stability, hard per-section caps, sort-stability, role-parameterization) + fixed a->b->c->d section order. Proposal 1f4b9167a is a merge pulling in the coder's task-4-1 renderer (a3dc986c3, previously ACKed), so the parallel-producer skip-guard does NOT fire \u2014 all 6 tests run LIVE against the real renderer and pass (verified 6/6). Genuine coverage, not a vacuous skip. (2) Doc<->code symmetry: BRCDerivedAnchors/OpenNack/ReviewEdgeVerdict/ConditionalAckObligation/ReviewVerdict all present at the proposal SHA with exactly the fields/enum members (reviewed_sha, reason, condition/resolved, last_reviewed_sha/latest_verdicts/open_nacks/conditional_ack_obligations; ACK/NACK/CONDITIONAL_ACK) the fixtures use; '6/6 PASS, ruff clean' reproduced. (3) Sentinel/locator tables are test-local markers, no cross-module equality consumer \u2014 no dead-ends. (4) Silent-fallback: skip-guard is the ratified slice convention (siblings test_brc_anchor_derivation.py / test_reseed_threshold.py) and masks nothing here since the renderer is merged; the flexible-call machinery only adapts on call-shape TypeError/AttributeError/ValueError and cannot swallow an assertion failure; cap/order/stability assertions are genuine bounds (4MB/5MB inputs asserted truncated below a 1/20 bound; permuted dict/list order asserted byte-identical), not tautologies.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "reason": "Holistic lens, all four passes clean on slice-4 task-4-2 (test_protected_root.py). (1) End-to-end: tests all four task-4-2 ACs (byte-stability, hard per-section caps, sort-stability, role-parameterization) + fixed a->b->c->d section order. Proposal 1f4b9167a is a merge pulling in the coder's task-4-1 renderer (a3dc986c3, previously ACKed), so the parallel-producer skip-guard does NOT fire \u2014 all 6 tests run LIVE against the real renderer and pass (verified 6/6). Genuine coverage, not a vacuous skip. (2) Doc<->code symmetry: BRCDerivedAnchors/OpenNack/ReviewEdgeVerdict/ConditionalAckObligation/ReviewVerdict all present at the proposal SHA with exactly the fields/enum members (reviewed_sha, reason, condition/resolved, last_reviewed_sha/latest_verdicts/open_nacks/conditional_ack_obligations; ACK/NACK/CONDITIONAL_ACK) the fixtures use; '6/6 PASS, ruff clean' reproduced. (3) Sentinel/locator tables are test-local markers, no cross-module equality consumer \u2014 no dead-ends. (4) Silent-fallback: skip-guard is the ratified slice convention (siblings test_brc_anchor_derivation.py / test_reseed_threshold.py) and masks nothing here since the renderer is merged; the flexible-call machinery only adapts on call-shape TypeError/AttributeError/ValueError and cannot swallow an assertion failure; cap/order/stability assertions are genuine bounds (4MB/5MB inputs asserted truncated below a 1/20 bound; permuted dict/list order asserted byte-identical), not tautologies.", + "ack_version": 1 + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:11.547530+00:00", + "phase": "implement" + }, + { + "id": "5f1883aa-3b85-4c", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code_holistic", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_code_holistic", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:11.674287+00:00", + "phase": "implement" + }, + { + "id": "b8430206-6981-45", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code", + "to_role": "tester", + "message_type": "CONSENSUS_ACK", + "subject": "ACK from reviewer_code for tester", + "body": "ACK task-4-2 (slice-4) protected-root tests at 1f4b9167a. The proposal adds ONE file within the tester boundary, shared/egg_anchor/tests/test_protected_root.py (503 lines), asserting the four task-4-2 acceptance properties of the slice-4 renderer: (1) byte-stability \u2014 identical input -> identical bytes, plus all four sections a->b->c->d present in fixed order, including section-(c) #3189 anchors (last-reviewed SHA + open-NACK reason); (2) per-section caps \u2014 a 4MB role-contract is hard-capped with the head surviving (truncated-not-dropped), and a 5000-NACK flood is bounded; (3) sort-stability \u2014 reversed dict-key/list-element order renders identical bytes; (4) role-parameterization \u2014 two roles render distinct-but-each-stable roots.\n\nEmpirical verification (not just diff-read): materialized BOTH the test and the real renderer at proposal SHA 1f4b9167a (the merge carries the task-4-1 renderer a3dc986 I previously ACKed) and ran the suite against the REAL merged render_protected_root with system pydantic 2.13.4 \u2014 6/6 PASS, NOT skipped. This is the key check: it proves the skip-guard locator + alias-group flexible-invocation machinery actually resolves the renderer symbol and exercises genuine assertions, rather than vacuously pytest.skip-ing and going green for free. The locator/alias spellings correctly map the renderer's keyword-only params (role/role_contract/task_description/derived/directives) onto canonical input groups; the caps/None args are correctly skipped. All five model imports + fixtures (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict.ACK/NACK/CONDITIONAL_ACK) match the merged slice-3 models.py field-for-field, so fixtures construct cleanly. Follows the established parallel-BRC skip-guard convention (test_brc_anchor_derivation.py / test_reseed_threshold.py). ruff clean (rc=0). No blockers \u2014 both passes (named prior-blockers: none; new delta findings: none) succeed.", + "metadata": { + "payload": { + "artifact_references": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "reason": "ACK task-4-2 (slice-4) protected-root tests at 1f4b9167a. The proposal adds ONE file within the tester boundary, shared/egg_anchor/tests/test_protected_root.py (503 lines), asserting the four task-4-2 acceptance properties of the slice-4 renderer: (1) byte-stability \u2014 identical input -> identical bytes, plus all four sections a->b->c->d present in fixed order, including section-(c) #3189 anchors (last-reviewed SHA + open-NACK reason); (2) per-section caps \u2014 a 4MB role-contract is hard-capped with the head surviving (truncated-not-dropped), and a 5000-NACK flood is bounded; (3) sort-stability \u2014 reversed dict-key/list-element order renders identical bytes; (4) role-parameterization \u2014 two roles render distinct-but-each-stable roots.\n\nEmpirical verification (not just diff-read): materialized BOTH the test and the real renderer at proposal SHA 1f4b9167a (the merge carries the task-4-1 renderer a3dc986 I previously ACKed) and ran the suite against the REAL merged render_protected_root with system pydantic 2.13.4 \u2014 6/6 PASS, NOT skipped. This is the key check: it proves the skip-guard locator + alias-group flexible-invocation machinery actually resolves the renderer symbol and exercises genuine assertions, rather than vacuously pytest.skip-ing and going green for free. The locator/alias spellings correctly map the renderer's keyword-only params (role/role_contract/task_description/derived/directives) onto canonical input groups; the caps/None args are correctly skipped. All five model imports + fixtures (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict.ACK/NACK/CONDITIONAL_ACK) match the merged slice-3 models.py field-for-field, so fixtures construct cleanly. Follows the established parallel-BRC skip-guard convention (test_brc_anchor_derivation.py / test_reseed_threshold.py). ruff clean (rc=0). No blockers \u2014 both passes (named prior-blockers: none; new delta findings: none) succeed.", + "ack_version": 1, + "attestation": { + "files_reviewed": [ + "shared/egg_anchor/tests/test_protected_root.py" + ], + "issues_found": 0, + "tests_run": 6, + "tests_passed": 6, + "checks_passed": [ + "pytest", + "ruff" + ], + "validated_against_real_renderer": true + } + }, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:35.332697+00:00", + "phase": "implement" + }, + { + "id": "02907ba2-4d92-4d", + "pipeline_id": "issue-3200", + "from_role": "orchestrator", + "to_role": "tester", + "message_type": "STATUS", + "subject": "Ready to confirm \u2014 all confirm preconditions satisfied", + "body": "Your proposal (version 1) is ready to confirm \u2014 all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm.", + "metadata": { + "ready_to_confirm": true, + "version": 1, + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:35.334647+00:00", + "phase": "implement" + }, + { + "id": "61485bc2-5e7a-4c", + "pipeline_id": "issue-3200", + "from_role": "tester", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by tester", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.076849+00:00", + "phase": "implement" + }, + { + "id": "6de1701c-6eaa-44", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_code", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.079021+00:00", + "phase": "implement" + }, + { + "id": "b3600b50-4f8f-4d", + "pipeline_id": "issue-3200", + "from_role": "reviewer_code_holistic", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_code_holistic", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.083172+00:00", + "phase": "implement" + }, + { + "id": "daf0d28a-06c5-4c", + "pipeline_id": "issue-3200", + "from_role": "reviewer_contract", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_contract", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.084305+00:00", + "phase": "implement" + }, + { + "id": "ed11f341-ae9d-47", + "pipeline_id": "issue-3200", + "from_role": "reviewer_security", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_security", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.086815+00:00", + "phase": "implement" + }, + { + "id": "2ed6ea39-cb30-49", + "pipeline_id": "issue-3200", + "from_role": "reviewer_concurrency", + "to_role": "all", + "message_type": "CONSENSUS_CONFIRMED", + "subject": "Consensus confirmed by reviewer_concurrency", + "body": "orchestrator-side confirm (#3064 event loop)", + "metadata": { + "slice_id": "slice-4" + }, + "timestamp": "2026-06-25T06:51:37.088489+00:00", + "phase": "implement" + } +] \ No newline at end of file diff --git a/.egg-state/brc-history/3200-implement-slice-4.md b/.egg-state/brc-history/3200-implement-slice-4.md new file mode 100644 index 0000000000..5a90be266a --- /dev/null +++ b/.egg-state/brc-history/3200-implement-slice-4.md @@ -0,0 +1,821 @@ +# BRC Consensus History — implement phase, slice-4 + +Generated: 2026-06-25T06:51:37Z +Pipeline: issue-3200 +Slice: slice-4 + +### [2026-06-25T06:40:16Z] coder (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=propose (slice=slice-4) + +````yaml +id: ca34b944-3735-4b +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:40:17Z] tester (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=propose (slice=slice-4) + +````yaml +id: c735e7d6-e0e2-41 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:40:18Z] documenter (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=propose (slice=slice-4) + +````yaml +id: ecfa0eaa-6897-4a +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:41:45Z] documenter (CONSENSUS_PROPOSE): Proposal from documenter + +documenter: no documentation changes for slice-4 (protected-root renderer). Slice-4 lands a deterministic, byte-stable, role-parameterized protected-root renderer in shared/egg_anchor/ + shared/egg_agent/. It is internal infrastructure: no CLI surface, no user-facing API, and not wired into any event-pump role (wiring + the single feature flag are slice-9; the whole context-discipline path is OFF by default until then). The coherent doc deliverable — egg_anchor/README.md "Files"/section updates covering the renderer (and the slice-3 brc_derive layer), plus a context-discipline guide under docs/ — belongs at the generalization slice (slice-9)/PR phase when the public surface stabilizes and the flag exists to document. Consistent with the documenter's slice-1 no_changes_needed verdict for the same pre-wiring rationale. + +````yaml +id: 92f0ece7-1d70-49 +phase: implement +metadata: + payload: + summary: "documenter: no documentation changes for slice-4 (protected-root renderer).\ + \ Slice-4 lands a deterministic, byte-stable, role-parameterized protected-root\ + \ renderer in shared/egg_anchor/ + shared/egg_agent/. It is internal infrastructure:\ + \ no CLI surface, no user-facing API, and not wired into any event-pump role\ + \ (wiring + the single feature flag are slice-9; the whole context-discipline\ + \ path is OFF by default until then). The coherent doc deliverable \u2014 egg_anchor/README.md\ + \ \"Files\"/section updates covering the renderer (and the slice-3 brc_derive\ + \ layer), plus a context-discipline guide under docs/ \u2014 belongs at the\ + \ generalization slice (slice-9)/PR phase when the public surface stabilizes\ + \ and the flag exists to document. Consistent with the documenter's slice-1\ + \ no_changes_needed verdict for the same pre-wiring rationale." + attestation: {} + artifacts: [] + risk_considered: '' + commit_sha: '' + files_changed: [] + tests_run: [] + tasks_satisfied: [] + no_changes_needed: true + no_changes_reason: Slice-4 is internal-only infrastructure (protected-root renderer) + with no user-facing surface, gated OFF behind a not-yet-built feature flag (slice-9). + No documentation is reachable or stable to update at this slice; component-README + and guide updates are deferred to slice-9/PR phase when the mechanism is wired + and flag-gated. The slice-4 renderer code is also not yet on the branch (HEAD=slice-3 + completion), so no accurate docs can be authored against it now. + version: 1 + commit_sha: '' + slice_id: slice-4 +```` + +### [2026-06-25T06:45:00Z] coder (CONSENSUS_PROPOSE): Proposal from coder + +slice-4 task-4-1: deterministic protected-root renderer. New shared/egg_anchor/protected_root.py exposes render_protected_root() assembling the event-pump agent's protected root in fixed order: (a) role contract, (b) task anchor (compose_task_description #3163 output, passed in by caller), (c) the #3189 deterministic anchors (BRCDerivedAnchors derived in slice-3), (d) non-negotiable directives. Byte-stable for identical input: keyed anchor collections sorted (SHA map by producer; verdicts/NACKs/obligations by (producer,reviewer)), list counts bounded by overridable RootCaps caps, free-form sections char-capped, NO timestamps/sequence/nondeterministic ordering. Role-parameterized (header + role_contract arg) so two roles render distinct-but-each-stable roots. Pure: accepts already-composed strings so egg_anchor gains no new dependency; section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, never agent prose, so the authoritative anchor layer cannot drift. Exported render_protected_root + RootCaps from egg_anchor. + +````yaml +id: 54ae7548-0abd-47 +phase: implement +metadata: + payload: + summary: 'slice-4 task-4-1: deterministic protected-root renderer. New shared/egg_anchor/protected_root.py + exposes render_protected_root() assembling the event-pump agent''s protected + root in fixed order: (a) role contract, (b) task anchor (compose_task_description + #3163 output, passed in by caller), (c) the #3189 deterministic anchors (BRCDerivedAnchors + derived in slice-3), (d) non-negotiable directives. Byte-stable for identical + input: keyed anchor collections sorted (SHA map by producer; verdicts/NACKs/obligations + by (producer,reviewer)), list counts bounded by overridable RootCaps caps, free-form + sections char-capped, NO timestamps/sequence/nondeterministic ordering. Role-parameterized + (header + role_contract arg) so two roles render distinct-but-each-stable roots. + Pure: accepts already-composed strings so egg_anchor gains no new dependency; + section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, never + agent prose, so the authoritative anchor layer cannot drift. Exported render_protected_root + + RootCaps from egg_anchor.' + attestation: {} + artifacts: + - shared/egg_anchor/protected_root.py + risk_considered: Renderer is pure and additive (new module + two additive __init__ + exports); no existing call sites changed, so no behavioural regression to the + legacy full-context path. egg_anchor takes on no new package dependency (task_description + composed by caller). Determinism verified manually (dict/list reorder -> identical + bytes; cap truncation; role parameterization). ruff + mypy clean; 105 existing + egg_anchor tests pass. Per-section caps default generous (truncation is a backstop, + not the common path). Section (c) is authoritative-only (mechanically derived), + so a stale/wrong agent claim cannot enter the protected root here. + commit_sha: a3dc986c395473c26b72366891c721a3170e0a5b + files_changed: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + tests_run: [] + tasks_satisfied: + - task-4-1 + no_changes_needed: false + no_changes_reason: '' + version: 1 + commit_sha: a3dc986c395473c26b72366891c721a3170e0a5b + slice_id: slice-4 +```` + +### [2026-06-25T06:45:09Z] reviewer_code_holistic (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=ack (slice=slice-4) + +````yaml +id: 9502c0fa-9401-45 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:45:10Z] reviewer_code (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=ack (slice=slice-4) + +````yaml +id: 854fd484-98a1-44 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:45:10Z] reviewer_contract (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=ack (slice=slice-4) + +````yaml +id: a19be2f5-83e0-46 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:45:10Z] reviewer_security (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=ack (slice=slice-4) + +````yaml +id: b276acb1-740e-48 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:45:11Z] reviewer_concurrency (HEARTBEAT): heartbeat: WORKING + +one-shot event arm action=ack (slice=slice-4) + +````yaml +id: 9c38d421-150c-49 +phase: implement +metadata: + state: WORKING + slice_id: slice-4 +```` + +### [2026-06-25T06:46:21Z] reviewer_contract → coder (CONSENSUS_ACK): ACK from reviewer_contract for coder + +task-4-1 AC fully satisfied. (1) Four sections in FIXED order behind a role header: (a) ROLE CONTRACT, (b) TASK, (c) BRC ANCHORS #3189, (d) NON-NEGOTIABLE DIRECTIVES. (2) Byte-stable: every keyed anchor collection sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)), list counts bounded by RootCaps, free-form sections char-capped, no timestamps/sequence-numbers/nondeterministic ordering. (3) Role-parameterized via header + role_contract arg. (4) Section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (slice-3) — no agent-authored prose path, authoritative anchor layer cannot drift. Verified all attributes used (last_reviewed_sha.items, latest_verdicts[].producer/reviewer/verdict.value/version/reviewed_sha, open_nacks[].reason, conditional_ack_obligations[].condition/resolved) match the slice-3 model exactly; ReviewVerdict is a StrEnum so .value is valid. Renderer is pure (no new egg_anchor dep); deferring compose_task_description (#3163) to the caller is a documented purity choice consistent with the AC (task anchor is composed via #3163 at the wire-up site, not necessarily inside the renderer). Byte-stability/cap/role tests are task-4-2 (tester), correctly out of scope here. ruff+mypy clean per coder notes; 105 existing egg_anchor tests pass. + +````yaml +id: b2f1d78b-829f-4d +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + reason: "task-4-1 AC fully satisfied. (1) Four sections in FIXED order behind\ + \ a role header: (a) ROLE CONTRACT, (b) TASK, (c) BRC ANCHORS #3189, (d) NON-NEGOTIABLE\ + \ DIRECTIVES. (2) Byte-stable: every keyed anchor collection sorted (last_reviewed_sha\ + \ by producer; verdicts/nacks/obligations by (producer,reviewer)), list counts\ + \ bounded by RootCaps, free-form sections char-capped, no timestamps/sequence-numbers/nondeterministic\ + \ ordering. (3) Role-parameterized via header + role_contract arg. (4) Section\ + \ (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (slice-3)\ + \ \u2014 no agent-authored prose path, authoritative anchor layer cannot drift.\ + \ Verified all attributes used (last_reviewed_sha.items, latest_verdicts[].producer/reviewer/verdict.value/version/reviewed_sha,\ + \ open_nacks[].reason, conditional_ack_obligations[].condition/resolved) match\ + \ the slice-3 model exactly; ReviewVerdict is a StrEnum so .value is valid.\ + \ Renderer is pure (no new egg_anchor dep); deferring compose_task_description\ + \ (#3163) to the caller is a documented purity choice consistent with the AC\ + \ (task anchor is composed via #3163 at the wire-up site, not necessarily inside\ + \ the renderer). Byte-stability/cap/role tests are task-4-2 (tester), correctly\ + \ out of scope here. ruff+mypy clean per coder notes; 105 existing egg_anchor\ + \ tests pass." + ack_version: 1 + attestation: + tasks_verified: + - task-4-1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:46:22Z] reviewer_security → coder (CONSENSUS_ACK): ACK from reviewer_security for coder + +Security ACK (slice-4, task-4-1). Pure dependency-free renderer with no injection sinks: no eval/exec/subprocess, no path ops, no deserialization of untrusted data, no env/secret reads or logging. Output is plain f-string interpolation into labeled sections — no .format() on attacker-controlled keys. Resource-bound safety is a positive: all sections hard-capped (char caps on free-form, count caps + elision on anchor lists) so a pathological contract/anchor set cannot unboundedly inflate the resident root; char-based truncation keeps output valid UTF-8. Non-blocking note: NACK reason / conditional-ACK condition are agent-authored free text entering the resident root, but bounded to 300 chars, clearly delimited, required for actionability, and sourced from the trusted same-pipeline BRC message stream — not an external boundary. No security blockers. + +````yaml +id: 1393a016-1356-41 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + reason: "Security ACK (slice-4, task-4-1). Pure dependency-free renderer with\ + \ no injection sinks: no eval/exec/subprocess, no path ops, no deserialization\ + \ of untrusted data, no env/secret reads or logging. Output is plain f-string\ + \ interpolation into labeled sections \u2014 no .format() on attacker-controlled\ + \ keys. Resource-bound safety is a positive: all sections hard-capped (char\ + \ caps on free-form, count caps + elision on anchor lists) so a pathological\ + \ contract/anchor set cannot unboundedly inflate the resident root; char-based\ + \ truncation keeps output valid UTF-8. Non-blocking note: NACK reason / conditional-ACK\ + \ condition are agent-authored free text entering the resident root, but bounded\ + \ to 300 chars, clearly delimited, required for actionability, and sourced from\ + \ the trusted same-pipeline BRC message stream \u2014 not an external boundary.\ + \ No security blockers." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:46:31Z] reviewer_concurrency → coder (CONSENSUS_ACK): ACK from reviewer_concurrency for coder + +Concurrency lens — clean ACK. render_protected_root is a pure, side-effect-free renderer: it reads immutable inputs (already-composed strings + a BRCDerivedAnchors snapshot) and returns a string. No module-level mutable state (only str constants and __all__), no shared cache, no async/locks/subprocess, no external calls or retry loops, and it does not touch the BRC message bus — no send→wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound is involved. sorted() builds new lists and never mutates the input models; the mutable-default-argument pitfall is avoided (caps/directives default to None). No race, deadlock, async-context leak, retry-storm, or resource-cleanup-ordering finding in scope. + +````yaml +id: c69ded21-5fdd-47 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + reason: "Concurrency lens \u2014 clean ACK. render_protected_root is a pure, side-effect-free\ + \ renderer: it reads immutable inputs (already-composed strings + a BRCDerivedAnchors\ + \ snapshot) and returns a string. No module-level mutable state (only str constants\ + \ and __all__), no shared cache, no async/locks/subprocess, no external calls\ + \ or retry loops, and it does not touch the BRC message bus \u2014 no send\u2192\ + wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or\ + \ flip-flop bound is involved. sorted() builds new lists and never mutates the\ + \ input models; the mutable-default-argument pitfall is avoided (caps/directives\ + \ default to None). No race, deadlock, async-context leak, retry-storm, or resource-cleanup-ordering\ + \ finding in scope." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:47:06Z] reviewer_code_holistic → coder (CONSENSUS_ACK): ACK from reviewer_code_holistic for coder + +Holistic lens, all four passes clean on the slice-4 task-4-1 protected-root renderer. (1) End-to-end use case: contract AC met — fixed four-section order (role contract / task / #3189 anchors / directives), byte-stable, role-parameterized, section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors; the event-pump consumer is correctly deferred to the slice-9 flag-wiring per the ratified DAG, so the unwired renderer is sequencing, not a silently-dropped output. (2) Doc↔code symmetry: byte-stability claims hold (keyed collections sorted, counts/chars capped, no timestamps; directives preserve caller order deterministically); the docstring's caller hook egg_contracts.loader.compose_task_description exists (loader.py:204). (3) Synthetic-key/sentinel: (none), truncation marker, OPEN/resolved labels are display-only LLM-facing strings with no cross-module equality consumer — no __checkout__-style dead-end. (4) Silent-fallback: derived=None placeholder and truncation both emit visible markers (not silent), no broad excepts. Cross-module field symmetry with BRCDerivedAnchors/ReviewEdgeVerdict/OpenNack/ConditionalAckObligation is exact and ReviewVerdict StrEnum.value renders correctly. Non-blocking nit (not gating): role or "unknown" default could mask an unset-role wiring bug, but role plumbing is validated at slice-9. + +````yaml +id: 01666099-7dba-40 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + reason: "Holistic lens, all four passes clean on the slice-4 task-4-1 protected-root\ + \ renderer. (1) End-to-end use case: contract AC met \u2014 fixed four-section\ + \ order (role contract / task / #3189 anchors / directives), byte-stable, role-parameterized,\ + \ section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors;\ + \ the event-pump consumer is correctly deferred to the slice-9 flag-wiring per\ + \ the ratified DAG, so the unwired renderer is sequencing, not a silently-dropped\ + \ output. (2) Doc\u2194code symmetry: byte-stability claims hold (keyed collections\ + \ sorted, counts/chars capped, no timestamps; directives preserve caller order\ + \ deterministically); the docstring's caller hook egg_contracts.loader.compose_task_description\ + \ exists (loader.py:204). (3) Synthetic-key/sentinel: (none), truncation marker,\ + \ OPEN/resolved labels are display-only LLM-facing strings with no cross-module\ + \ equality consumer \u2014 no __checkout__-style dead-end. (4) Silent-fallback:\ + \ derived=None placeholder and truncation both emit visible markers (not silent),\ + \ no broad excepts. Cross-module field symmetry with BRCDerivedAnchors/ReviewEdgeVerdict/OpenNack/ConditionalAckObligation\ + \ is exact and ReviewVerdict StrEnum.value renders correctly. Non-blocking nit\ + \ (not gating): role or \"unknown\" default could mask an unset-role wiring\ + \ bug, but role plumbing is validated at slice-9." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:47:38Z] reviewer_code → coder (CONSENSUS_ACK): ACK from reviewer_code for coder + +ACK task-4-1 (slice-4) protected-root renderer at a3dc986. render_protected_root assembles the fixed four-section root (role contract / task anchor / #3189 BRCDerivedAnchors / non-negotiable directives) as a pure, dependency-light function. Audited the full diff + verified empirically by materializing the proposed file in isolation and exercising it with pydantic: (1) BYTE-STABLE — identical (role, contract, task, derived, directives) renders identical bytes regardless of dict insertion / list order, because every keyed collection is sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer)) and no timestamps/sequence numbers enter the output; (2) ROLE-PARAMETERIZED — two roles render distinct-but-each-stable roots; (3) section (c) sourced ONLY from the mechanically-derived BRCDerivedAnchors (no agent prose inlined), so the authoritative anchor layer cannot drift; (4) per-section char caps + count caps (RootCaps) enforced with a stable truncation marker; (5) None/empty inputs degrade to "(none)" / "(no reviewed proposals yet)"; (6) no circular import (protected_root → models only); (7) all field accesses match models.py (ReviewEdgeVerdict/OpenNack/ConditionalAckObligation, verdict.value StrEnum). All four AC clauses met. Lone nit (non-blocking, not a NACK): _truncate with a cap < len(marker)=13 would return a string slightly longer than the cap — unreachable via the ≥300 defaults, pathological-only. Tests (byte-stability/caps/sort/role) are task-4-2 (tester), correctly out of this proposal's scope. + +````yaml +id: 4fccf36b-b8ac-42 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + - shared/egg_anchor/models.py + reason: "ACK task-4-1 (slice-4) protected-root renderer at a3dc986. render_protected_root\ + \ assembles the fixed four-section root (role contract / task anchor / #3189\ + \ BRCDerivedAnchors / non-negotiable directives) as a pure, dependency-light\ + \ function. Audited the full diff + verified empirically by materializing the\ + \ proposed file in isolation and exercising it with pydantic: (1) BYTE-STABLE\ + \ \u2014 identical (role, contract, task, derived, directives) renders identical\ + \ bytes regardless of dict insertion / list order, because every keyed collection\ + \ is sorted (last_reviewed_sha by producer; verdicts/nacks/obligations by (producer,reviewer))\ + \ and no timestamps/sequence numbers enter the output; (2) ROLE-PARAMETERIZED\ + \ \u2014 two roles render distinct-but-each-stable roots; (3) section (c) sourced\ + \ ONLY from the mechanically-derived BRCDerivedAnchors (no agent prose inlined),\ + \ so the authoritative anchor layer cannot drift; (4) per-section char caps\ + \ + count caps (RootCaps) enforced with a stable truncation marker; (5) None/empty\ + \ inputs degrade to \"(none)\" / \"(no reviewed proposals yet)\"; (6) no circular\ + \ import (protected_root \u2192 models only); (7) all field accesses match models.py\ + \ (ReviewEdgeVerdict/OpenNack/ConditionalAckObligation, verdict.value StrEnum).\ + \ All four AC clauses met. Lone nit (non-blocking, not a NACK): _truncate with\ + \ a cap < len(marker)=13 would return a string slightly longer than the cap\ + \ \u2014 unreachable via the \u2265300 defaults, pathological-only. Tests (byte-stability/caps/sort/role)\ + \ are task-4-2 (tester), correctly out of this proposal's scope." + ack_version: 1 + attestation: + files_reviewed: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + - shared/egg_anchor/models.py + issues_found: 0 + verification: isolated import + determinism harness run against the proposed + SHA + checks: + - byte_stability + - role_parameterization + - none_empty_handling + - cap_truncation + - no_circular_import + - model_field_parity + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:48:41Z] tester (CONSENSUS_PROPOSE): Proposal from tester + +slice-4 task-4-2: deterministic protected-root renderer tests — CONVERGED on merged coder renderer (task-4-1, a3dc986c3). shared/egg_anchor/tests/test_protected_root.py asserts the four task-4-2 acceptance properties: byte-stability (identical input -> identical bytes), hard per-section-cap truncation (free-text + #3189-anchor sections), sort-stability (output independent of dict-key/list-element input order), and role-parameterization (distinct-but-each-stable roots), plus a fixed a->b->c->d section-order check. Flexible parallel-producer locators resolved the coder's renderer with NO test changes after merge. All 6 tests PASS against the real renderer; full shared/egg_anchor suite 111 passed; ruff clean. Change is a test-only addition (no runtime/security surface). + +````yaml +id: 50be071f-3392-43 +phase: implement +metadata: + payload: + summary: "slice-4 task-4-2: deterministic protected-root renderer tests \u2014\ + \ CONVERGED on merged coder renderer (task-4-1, a3dc986c3). shared/egg_anchor/tests/test_protected_root.py\ + \ asserts the four task-4-2 acceptance properties: byte-stability (identical\ + \ input -> identical bytes), hard per-section-cap truncation (free-text + #3189-anchor\ + \ sections), sort-stability (output independent of dict-key/list-element input\ + \ order), and role-parameterization (distinct-but-each-stable roots), plus a\ + \ fixed a->b->c->d section-order check. Flexible parallel-producer locators\ + \ resolved the coder's renderer with NO test changes after merge. All 6 tests\ + \ PASS against the real renderer; full shared/egg_anchor suite 111 passed; ruff\ + \ clean. Change is a test-only addition (no runtime/security surface)." + attestation: + tests_run: 6 + checks_passed: + - lint + - test + - security + tests_passed: 6 + suite_passed: 111 + security_note: test-only addition (shared/egg_anchor/tests/test_protected_root.py); + no subprocess/eval/network/secret surface; bandit/safety/trivy not runnable + locally in this sandbox + notes: 6/6 task-4-2 tests PASS against merged coder renderer a3dc986c3; ruff + clean + artifacts: + - shared/egg_anchor/tests/test_protected_root.py + risk_considered: Coder renderer (task-4-1) merged into this branch; tests execute + against the real implementation. All four acceptance properties verified PASS; + no regression (full egg_anchor suite 111 passed). The artifact is a single pytest + module with no subprocess/eval/network/secret usage, so it carries no security + surface; bandit/safety/trivy are gateway-side gates not runnable in this sandbox. + commit_sha: 1f4b9167a + files_changed: + - shared/egg_anchor/tests/test_protected_root.py + tests_run: [] + tasks_satisfied: + - task-4-2 + no_changes_needed: false + no_changes_reason: '' + version: 1 + commit_sha: 1f4b9167a + slice_id: slice-4 +```` + +### [2026-06-25T06:48:41Z] orchestrator → documenter (STATUS): Ready to confirm — all confirm preconditions satisfied + +Your proposal (version 1) is ready to confirm — all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm. + +````yaml +id: 7616b874-2f7b-41 +phase: implement +metadata: + ready_to_confirm: true + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:48:47Z] documenter (CONSENSUS_CONFIRMED): Consensus confirmed by documenter + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: bf30bbe2-bed4-45 +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:49:30Z] reviewer_concurrency → tester (CONSENSUS_ACK): ACK from reviewer_concurrency for tester + +Concurrency lens — clean ACK. test_protected_root.py is a pure, deterministic pytest module with no concurrency surface. Module-level locator tables (_RENDERER_CANDIDATES tuple, _ALIAS_GROUPS/_CANONICAL_ORDER dicts) are read-only constants, never mutated; no shared mutable cache. Fixture builders (_canonical_inputs, _anchors, _task_anchor) construct fresh objects per call, so tests are isolated and safe even under pytest-xdist. _variants copies via dict(base) and never mutates its inputs; model_dump()/list(reversed(...)) build new objects — no aliasing/shared-state hazard, and the sort-stability test passes independent anchor instances. No async/threads/locks/subprocess, no retry loops, no BRC message-bus interaction (no send→wait/--since cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop bound), and no resource-cleanup ordering. No race, deadlock, async-context leak, retry-storm, or cleanup-ordering finding in scope. + +````yaml +id: 75de8005-f6b7-4e +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/tests/test_protected_root.py + reason: "Concurrency lens \u2014 clean ACK. test_protected_root.py is a pure,\ + \ deterministic pytest module with no concurrency surface. Module-level locator\ + \ tables (_RENDERER_CANDIDATES tuple, _ALIAS_GROUPS/_CANONICAL_ORDER dicts)\ + \ are read-only constants, never mutated; no shared mutable cache. Fixture builders\ + \ (_canonical_inputs, _anchors, _task_anchor) construct fresh objects per call,\ + \ so tests are isolated and safe even under pytest-xdist. _variants copies via\ + \ dict(base) and never mutates its inputs; model_dump()/list(reversed(...))\ + \ build new objects \u2014 no aliasing/shared-state hazard, and the sort-stability\ + \ test passes independent anchor instances. No async/threads/locks/subprocess,\ + \ no retry loops, no BRC message-bus interaction (no send\u2192wait/--since\ + \ cursor, heartbeat-bearing path, stale_reviewers invalidation, or flip-flop\ + \ bound), and no resource-cleanup ordering. No race, deadlock, async-context\ + \ leak, retry-storm, or cleanup-ordering finding in scope." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:49:34Z] reviewer_concurrency (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_concurrency + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 2d3b5be8-1cb2-41 +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:49:38Z] reviewer_security → tester (CONSENSUS_ACK): ACK from reviewer_security for tester + +Security ACK (slice-4, task-4-2). Test-only artifact (503 lines, single new file); merge brings in the already-ACKed coder renderer a3dc986c3. No injection sinks or trust-boundary crossings: no eval/exec/compile, no subprocess/os.system, no file I/O or path ops, no network. The dynamic import (__import__/getattr) is restricted to a hardcoded closed-set candidate tuple — no data- or attacker-controlled import target. No untrusted deserialization (model_dump runs on test-constructed Pydantic models), no env/secret reads, no sensitive logging. Safe bytes.decode(utf-8, replace). The deliberate ~4-5MB filler inputs are in-memory test-only and assert the renderer's hard per-section caps — directly pinning the resident-root-inflation defense flagged on the coder renderer, a security positive. No security blockers. + +````yaml +id: 8cf33e54-a6c4-46 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/tests/test_protected_root.py + reason: "Security ACK (slice-4, task-4-2). Test-only artifact (503 lines, single\ + \ new file); merge brings in the already-ACKed coder renderer a3dc986c3. No\ + \ injection sinks or trust-boundary crossings: no eval/exec/compile, no subprocess/os.system,\ + \ no file I/O or path ops, no network. The dynamic import (__import__/getattr)\ + \ is restricted to a hardcoded closed-set candidate tuple \u2014 no data- or\ + \ attacker-controlled import target. No untrusted deserialization (model_dump\ + \ runs on test-constructed Pydantic models), no env/secret reads, no sensitive\ + \ logging. Safe bytes.decode(utf-8, replace). The deliberate ~4-5MB filler inputs\ + \ are in-memory test-only and assert the renderer's hard per-section caps \u2014\ + \ directly pinning the resident-root-inflation defense flagged on the coder\ + \ renderer, a security positive. No security blockers." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:49:40Z] reviewer_security (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_security + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 0bbb8685-830b-4a +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:50:21Z] coder (CONSENSUS_CONFIRMED): Consensus confirmed by coder + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 864c5129-987e-47 +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:50:44Z] tester → coder (CONSENSUS_ACK): ACK from tester for coder + +ACK task-4-1 (protected-root renderer). All AC met: (1) fixed four-section order (header + ROLE CONTRACT/TASK/BRC ANCHORS #3189/NON-NEGOTIABLE DIRECTIVES); (2) byte-stable — pure function, keyed collections sorted (last_reviewed_sha by producer, verdicts/nacks/obligations by (producer,reviewer)), counts bounded by RootCaps, free-form sections char-capped, no timestamps/random/global state; (3) role-parameterized via header (distinct-but-each-stable); (4) section (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, no agent prose. Verified every field reference matches models.py (last_reviewed_sha dict, ReviewEdgeVerdict.verdict.value, OpenNack.reason, ConditionalAckObligation.condition/.resolved). Syntax parses cleanly; purely additive (new file + __init__ exports), no existing-surface breakage. Testability (tester lens): pure fn with injected inputs + explicit RootCaps knobs — all AC-mapped behaviors observable from the return string, ideal for the task-4-2 unit tests (byte-stability, cap-truncation, sort-stability, role-parameterization). Non-blocking nit for my own edge tests: _truncate returns marker (len > max_chars) when max_chars < marker length (~13); never bites at default caps (>=300). + +````yaml +id: 101fff71-947a-46 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/protected_root.py + - shared/egg_anchor/__init__.py + - shared/egg_anchor/models.py + reason: "ACK task-4-1 (protected-root renderer). All AC met: (1) fixed four-section\ + \ order (header + ROLE CONTRACT/TASK/BRC ANCHORS #3189/NON-NEGOTIABLE DIRECTIVES);\ + \ (2) byte-stable \u2014 pure function, keyed collections sorted (last_reviewed_sha\ + \ by producer, verdicts/nacks/obligations by (producer,reviewer)), counts bounded\ + \ by RootCaps, free-form sections char-capped, no timestamps/random/global state;\ + \ (3) role-parameterized via header (distinct-but-each-stable); (4) section\ + \ (c) sourced ONLY from mechanically-derived BRCDerivedAnchors, no agent prose.\ + \ Verified every field reference matches models.py (last_reviewed_sha dict,\ + \ ReviewEdgeVerdict.verdict.value, OpenNack.reason, ConditionalAckObligation.condition/.resolved).\ + \ Syntax parses cleanly; purely additive (new file + __init__ exports), no existing-surface\ + \ breakage. Testability (tester lens): pure fn with injected inputs + explicit\ + \ RootCaps knobs \u2014 all AC-mapped behaviors observable from the return string,\ + \ ideal for the task-4-2 unit tests (byte-stability, cap-truncation, sort-stability,\ + \ role-parameterization). Non-blocking nit for my own edge tests: _truncate\ + \ returns marker (len > max_chars) when max_chars < marker length (~13); never\ + \ bites at default caps (>=300)." + ack_version: 1 + attestation: + tasks_verified: + - task-4-1 + ac_verified: + - fixed-four-section-order + - byte-stability-determinism + - role-parameterization + - section-c-from-deterministic-anchors-only + tests_run: 0 + tests_execution_blocked: true + tests_execution_blocked_reason: 'Reviewing coder implementation in isolated + worktree; no .venv present in tester worktree. task-4-2 (tester unit tests) + is the separate producer event where tests are authored/run. Static review + confirms testability: pure deterministic function, no hidden nondeterminism.' + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:50:44Z] orchestrator → coder (STATUS): Ready to confirm — all confirm preconditions satisfied + +Your proposal (version 1) is ready to confirm — all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm. + +````yaml +id: 9d839c9c-c540-43 +phase: implement +metadata: + ready_to_confirm: true + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:50:48Z] reviewer_contract → tester (CONSENSUS_ACK): ACK from reviewer_contract for tester + +task-4-2 fully satisfied. test_protected_root.py asserts all four task-4-2 acceptance properties for the slice-4 protected-root renderer, plus fixed section order: (1) byte-stability — two renders of identical input are byte-for-byte equal; (2) hard per-section caps — oversized free-text (role_contract) AND oversized #3189-anchor (5000 open_nacks) sections are bounded well below raw input size, with head-sentinel surviving (truncated not dropped); (3) sort-stability — permuting dict-key and list-element input order yields identical bytes; (4) role-parameterization — distinct roles render distinct-but-each-stable roots; plus a soft a->b->c->d order check guarded on locatable sentinels. Verified: imports (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict) and every field used match the merged slice-3 model in shared/egg_anchor/models.py exactly. The skip-guard locator resolves the REAL coder renderer egg_anchor.protected_root.render_protected_root (RootCaps/_truncate/_render_anchors present at merge commit 1f4b9167a) — tests ACTIVATE rather than skip: 6/6 PASS. ruff clean. Skip-guard/flexible-invocation convention matches sibling test_brc_anchor_derivation.py, keeping the suite green pre-merge and converging at PR assembly. Path shared/egg_anchor/tests/ is within the tester domain. First review: no prior NACK blockers; no new delta findings. + +````yaml +id: 2b545180-6000-43 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/tests/test_protected_root.py + - shared/egg_anchor/models.py + - shared/egg_anchor/protected_root.py + reason: "task-4-2 fully satisfied. test_protected_root.py asserts all four task-4-2\ + \ acceptance properties for the slice-4 protected-root renderer, plus fixed\ + \ section order: (1) byte-stability \u2014 two renders of identical input are\ + \ byte-for-byte equal; (2) hard per-section caps \u2014 oversized free-text\ + \ (role_contract) AND oversized #3189-anchor (5000 open_nacks) sections are\ + \ bounded well below raw input size, with head-sentinel surviving (truncated\ + \ not dropped); (3) sort-stability \u2014 permuting dict-key and list-element\ + \ input order yields identical bytes; (4) role-parameterization \u2014 distinct\ + \ roles render distinct-but-each-stable roots; plus a soft a->b->c->d order\ + \ check guarded on locatable sentinels. Verified: imports (BRCDerivedAnchors,\ + \ ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict) and\ + \ every field used match the merged slice-3 model in shared/egg_anchor/models.py\ + \ exactly. The skip-guard locator resolves the REAL coder renderer egg_anchor.protected_root.render_protected_root\ + \ (RootCaps/_truncate/_render_anchors present at merge commit 1f4b9167a) \u2014\ + \ tests ACTIVATE rather than skip: 6/6 PASS. ruff clean. Skip-guard/flexible-invocation\ + \ convention matches sibling test_brc_anchor_derivation.py, keeping the suite\ + \ green pre-merge and converging at PR assembly. Path shared/egg_anchor/tests/\ + \ is within the tester domain. First review: no prior NACK blockers; no new\ + \ delta findings." + ack_version: 1 + attestation: + tasks_verified: + - task-4-2 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:50:49Z] reviewer_contract (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_contract + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 3abc0e78-cc31-4e +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:11Z] reviewer_code_holistic → tester (CONSENSUS_ACK): ACK from reviewer_code_holistic for tester + +Holistic lens, all four passes clean on slice-4 task-4-2 (test_protected_root.py). (1) End-to-end: tests all four task-4-2 ACs (byte-stability, hard per-section caps, sort-stability, role-parameterization) + fixed a->b->c->d section order. Proposal 1f4b9167a is a merge pulling in the coder's task-4-1 renderer (a3dc986c3, previously ACKed), so the parallel-producer skip-guard does NOT fire — all 6 tests run LIVE against the real renderer and pass (verified 6/6). Genuine coverage, not a vacuous skip. (2) Doc<->code symmetry: BRCDerivedAnchors/OpenNack/ReviewEdgeVerdict/ConditionalAckObligation/ReviewVerdict all present at the proposal SHA with exactly the fields/enum members (reviewed_sha, reason, condition/resolved, last_reviewed_sha/latest_verdicts/open_nacks/conditional_ack_obligations; ACK/NACK/CONDITIONAL_ACK) the fixtures use; '6/6 PASS, ruff clean' reproduced. (3) Sentinel/locator tables are test-local markers, no cross-module equality consumer — no dead-ends. (4) Silent-fallback: skip-guard is the ratified slice convention (siblings test_brc_anchor_derivation.py / test_reseed_threshold.py) and masks nothing here since the renderer is merged; the flexible-call machinery only adapts on call-shape TypeError/AttributeError/ValueError and cannot swallow an assertion failure; cap/order/stability assertions are genuine bounds (4MB/5MB inputs asserted truncated below a 1/20 bound; permuted dict/list order asserted byte-identical), not tautologies. + +````yaml +id: 45aeed90-16b6-4d +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/tests/test_protected_root.py + reason: "Holistic lens, all four passes clean on slice-4 task-4-2 (test_protected_root.py).\ + \ (1) End-to-end: tests all four task-4-2 ACs (byte-stability, hard per-section\ + \ caps, sort-stability, role-parameterization) + fixed a->b->c->d section order.\ + \ Proposal 1f4b9167a is a merge pulling in the coder's task-4-1 renderer (a3dc986c3,\ + \ previously ACKed), so the parallel-producer skip-guard does NOT fire \u2014\ + \ all 6 tests run LIVE against the real renderer and pass (verified 6/6). Genuine\ + \ coverage, not a vacuous skip. (2) Doc<->code symmetry: BRCDerivedAnchors/OpenNack/ReviewEdgeVerdict/ConditionalAckObligation/ReviewVerdict\ + \ all present at the proposal SHA with exactly the fields/enum members (reviewed_sha,\ + \ reason, condition/resolved, last_reviewed_sha/latest_verdicts/open_nacks/conditional_ack_obligations;\ + \ ACK/NACK/CONDITIONAL_ACK) the fixtures use; '6/6 PASS, ruff clean' reproduced.\ + \ (3) Sentinel/locator tables are test-local markers, no cross-module equality\ + \ consumer \u2014 no dead-ends. (4) Silent-fallback: skip-guard is the ratified\ + \ slice convention (siblings test_brc_anchor_derivation.py / test_reseed_threshold.py)\ + \ and masks nothing here since the renderer is merged; the flexible-call machinery\ + \ only adapts on call-shape TypeError/AttributeError/ValueError and cannot swallow\ + \ an assertion failure; cap/order/stability assertions are genuine bounds (4MB/5MB\ + \ inputs asserted truncated below a 1/20 bound; permuted dict/list order asserted\ + \ byte-identical), not tautologies." + ack_version: 1 + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:51:11Z] reviewer_code_holistic (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_code_holistic + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 5f1883aa-3b85-4c +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:35Z] reviewer_code → tester (CONSENSUS_ACK): ACK from reviewer_code for tester + +ACK task-4-2 (slice-4) protected-root tests at 1f4b9167a. The proposal adds ONE file within the tester boundary, shared/egg_anchor/tests/test_protected_root.py (503 lines), asserting the four task-4-2 acceptance properties of the slice-4 renderer: (1) byte-stability — identical input -> identical bytes, plus all four sections a->b->c->d present in fixed order, including section-(c) #3189 anchors (last-reviewed SHA + open-NACK reason); (2) per-section caps — a 4MB role-contract is hard-capped with the head surviving (truncated-not-dropped), and a 5000-NACK flood is bounded; (3) sort-stability — reversed dict-key/list-element order renders identical bytes; (4) role-parameterization — two roles render distinct-but-each-stable roots. + +Empirical verification (not just diff-read): materialized BOTH the test and the real renderer at proposal SHA 1f4b9167a (the merge carries the task-4-1 renderer a3dc986 I previously ACKed) and ran the suite against the REAL merged render_protected_root with system pydantic 2.13.4 — 6/6 PASS, NOT skipped. This is the key check: it proves the skip-guard locator + alias-group flexible-invocation machinery actually resolves the renderer symbol and exercises genuine assertions, rather than vacuously pytest.skip-ing and going green for free. The locator/alias spellings correctly map the renderer's keyword-only params (role/role_contract/task_description/derived/directives) onto canonical input groups; the caps/None args are correctly skipped. All five model imports + fixtures (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack, ConditionalAckObligation, ReviewVerdict.ACK/NACK/CONDITIONAL_ACK) match the merged slice-3 models.py field-for-field, so fixtures construct cleanly. Follows the established parallel-BRC skip-guard convention (test_brc_anchor_derivation.py / test_reseed_threshold.py). ruff clean (rc=0). No blockers — both passes (named prior-blockers: none; new delta findings: none) succeed. + +````yaml +id: b8430206-6981-45 +phase: implement +metadata: + payload: + artifact_references: + - shared/egg_anchor/tests/test_protected_root.py + reason: "ACK task-4-2 (slice-4) protected-root tests at 1f4b9167a. The proposal\ + \ adds ONE file within the tester boundary, shared/egg_anchor/tests/test_protected_root.py\ + \ (503 lines), asserting the four task-4-2 acceptance properties of the slice-4\ + \ renderer: (1) byte-stability \u2014 identical input -> identical bytes, plus\ + \ all four sections a->b->c->d present in fixed order, including section-(c)\ + \ #3189 anchors (last-reviewed SHA + open-NACK reason); (2) per-section caps\ + \ \u2014 a 4MB role-contract is hard-capped with the head surviving (truncated-not-dropped),\ + \ and a 5000-NACK flood is bounded; (3) sort-stability \u2014 reversed dict-key/list-element\ + \ order renders identical bytes; (4) role-parameterization \u2014 two roles\ + \ render distinct-but-each-stable roots.\n\nEmpirical verification (not just\ + \ diff-read): materialized BOTH the test and the real renderer at proposal SHA\ + \ 1f4b9167a (the merge carries the task-4-1 renderer a3dc986 I previously ACKed)\ + \ and ran the suite against the REAL merged render_protected_root with system\ + \ pydantic 2.13.4 \u2014 6/6 PASS, NOT skipped. This is the key check: it proves\ + \ the skip-guard locator + alias-group flexible-invocation machinery actually\ + \ resolves the renderer symbol and exercises genuine assertions, rather than\ + \ vacuously pytest.skip-ing and going green for free. The locator/alias spellings\ + \ correctly map the renderer's keyword-only params (role/role_contract/task_description/derived/directives)\ + \ onto canonical input groups; the caps/None args are correctly skipped. All\ + \ five model imports + fixtures (BRCDerivedAnchors, ReviewEdgeVerdict, OpenNack,\ + \ ConditionalAckObligation, ReviewVerdict.ACK/NACK/CONDITIONAL_ACK) match the\ + \ merged slice-3 models.py field-for-field, so fixtures construct cleanly. Follows\ + \ the established parallel-BRC skip-guard convention (test_brc_anchor_derivation.py\ + \ / test_reseed_threshold.py). ruff clean (rc=0). No blockers \u2014 both passes\ + \ (named prior-blockers: none; new delta findings: none) succeed." + ack_version: 1 + attestation: + files_reviewed: + - shared/egg_anchor/tests/test_protected_root.py + issues_found: 0 + tests_run: 6 + tests_passed: 6 + checks_passed: + - pytest + - ruff + validated_against_real_renderer: true + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:51:35Z] orchestrator → tester (STATUS): Ready to confirm — all confirm preconditions satisfied + +Your proposal (version 1) is ready to confirm — all blocking reviews are clear and global confirm preconditions are met. Run `egg-orch consensus confirmed` to confirm. + +````yaml +id: 02907ba2-4d92-4d +phase: implement +metadata: + ready_to_confirm: true + version: 1 + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] tester (CONSENSUS_CONFIRMED): Consensus confirmed by tester + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 61485bc2-5e7a-4c +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] reviewer_code (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_code + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 6de1701c-6eaa-44 +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] reviewer_code_holistic (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_code_holistic + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: b3600b50-4f8f-4d +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] reviewer_contract (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_contract + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: daf0d28a-06c5-4c +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] reviewer_security (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_security + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: ed11f341-ae9d-47 +phase: implement +metadata: + slice_id: slice-4 +```` + +### [2026-06-25T06:51:37Z] reviewer_concurrency (CONSENSUS_CONFIRMED): Consensus confirmed by reviewer_concurrency + +orchestrator-side confirm (#3064 event loop) + +````yaml +id: 2ed6ea39-cb30-49 +phase: implement +metadata: + slice_id: slice-4 +```` diff --git a/orchestrator/agent_model_resolution.py b/orchestrator/agent_model_resolution.py index fec5995c35..3d1df11383 100644 --- a/orchestrator/agent_model_resolution.py +++ b/orchestrator/agent_model_resolution.py @@ -457,11 +457,7 @@ def real_backend_window(model: str) -> int: conservative unknown window (:func:`_conservative_unknown_window`), which is 200_000 under the current registry. """ - bare = ( - model.removesuffix(_CONTEXT_1M_SUFFIX) - if model.endswith(_CONTEXT_1M_SUFFIX) - else model - ) + bare = model.removesuffix(_CONTEXT_1M_SUFFIX) if model.endswith(_CONTEXT_1M_SUFFIX) else model # Registry first: authoritative over the [1m] alias for sub-1M backends, so # a stray ``[1m]`` suffix can never inflate a sub-1M window to the implied 1M. if bare in _SUB_1M_CONTEXT_MODELS: diff --git a/shared/egg_anchor/__init__.py b/shared/egg_anchor/__init__.py index b84201d299..30394f0497 100644 --- a/shared/egg_anchor/__init__.py +++ b/shared/egg_anchor/__init__.py @@ -22,6 +22,7 @@ ReviewVerdict, TaskInfo, ) +from .protected_root import RootCaps, render_protected_root from .validator import check_size_budget, validate_anchor __all__ = [ @@ -37,10 +38,12 @@ "ProgressItem", "ReviewEdgeVerdict", "ReviewVerdict", + "RootCaps", "TaskInfo", "check_size_budget", "derive_brc_anchors", "load_anchor", + "render_protected_root", "save_anchor", "sync_anchor_to_api", "validate_anchor", diff --git a/shared/egg_anchor/protected_root.py b/shared/egg_anchor/protected_root.py new file mode 100644 index 0000000000..9967e71ac7 --- /dev/null +++ b/shared/egg_anchor/protected_root.py @@ -0,0 +1,231 @@ +"""Deterministic protected-root renderer (#3200, slice-4). + +Assembles the small, stable, permanently-resident *protected root* for an +event-pump BRC agent in a FIXED four-section order: + + (a) role contract — the role's non-negotiable behavioural spec + (b) task anchor — ``compose_task_description`` output (#3163) + (c) #3189 deterministic anchors — last-reviewed SHA per producer, latest + verdicts, open NACKs, conditional-ACK + obligations (``BRCDerivedAnchors``, slice-3) + (d) non-negotiable directives + +**Byte stability.** The render is byte-identical for identical input: every +collection is sorted by a deterministic key, list counts are bounded, each +section is hard-capped, and NO timestamps / sequence numbers / nondeterministic +ordering enter the output. Identical ``(role, role_contract, task_description, +derived, directives)`` -> identical bytes — which is exactly what makes the +root a cacheable prompt prefix (warm resume, #3186) and a deterministic reseed +source (the #3200 threshold reseed re-renders the same root). + +**Purity.** The renderer accepts already-composed strings — the caller runs +:func:`egg_contracts.loader.compose_task_description` for section (b) — so +``egg_anchor`` takes on no new package dependency and stays importable from the +sandbox, the orchestrator, and tests alike. Section (c) is sourced ONLY from +the mechanically-derived :class:`BRCDerivedAnchors` (never agent-authored +prose), so the authoritative anchor layer cannot drift from the message record. +""" + +from __future__ import annotations + +from collections.abc import Sequence +from dataclasses import dataclass + +from .models import BRCDerivedAnchors + +__all__ = ["RootCaps", "render_protected_root"] + + +@dataclass(frozen=True) +class RootCaps: + """Hard per-section caps for the protected root (deterministic knobs). + + Character caps bound the free-form sections; count caps bound the + derived-anchor lists. All values are deterministic constants — changing + one changes the output bytes uniformly, never per-render. The defaults are + deliberately generous: the root is meant to be small, and truncation is a + safety backstop against a pathological contract, not the common path. + """ + + role_contract_chars: int = 6000 + task_chars: int = 8000 + directives_chars: int = 4000 + reason_chars: int = 300 + condition_chars: int = 300 + max_shas: int = 24 + max_verdicts: int = 48 + max_nacks: int = 24 + max_obligations: int = 24 + + +# Stable, content-free markers. Both are count- or position-derived, so they +# never introduce nondeterminism. The truncation marker is space-prefixed (not +# newline-prefixed) so it never splits a truncated inline value — e.g. a capped +# NACK reason stays on its own indented anchor line. +_SECTION_TRUNCATION_MARKER = " …[truncated]" +_NONE = "(none)" + + +def _truncate(text: str, max_chars: int) -> str: + """Trim ``text`` to ``max_chars`` characters, appending a stable marker. + + Character-based (not byte-based) so the result is always valid UTF-8 and + deterministic for identical input. ``max_chars`` is a hard ceiling on the + returned length *including* the marker — even when a caller overrides + :class:`RootCaps` with a cap smaller than the marker, the result never + exceeds ``max_chars`` (it is hard-trimmed without the marker rather than + returning the marker alone). + """ + text = text.strip() + if len(text) <= max_chars: + return text + if max_chars <= len(_SECTION_TRUNCATION_MARKER): + # Cap too small to fit the marker — hard-trim to the ceiling so the + # documented "including the marker" guarantee holds for any cap. + return text[:max_chars] + keep = max_chars - len(_SECTION_TRUNCATION_MARKER) + return text[:keep].rstrip() + _SECTION_TRUNCATION_MARKER + + +def _elision(remaining: int) -> str: + return f" … (+{remaining} more elided)" + + +def _section(title: str, body: str) -> str: + body = body.strip() or _NONE + return f"## {title}\n{body}" + + +def _normalize_directives(directives: str | Sequence[str] | None) -> str: + """Render directives as deterministic text, preserving caller order. + + A directive *list* keeps its input order — order is part of the + directives' meaning and is deterministic for identical input, so it is NOT + sorted (unlike the keyed anchor collections below). + """ + if directives is None: + return "" + if isinstance(directives, str): + return directives.strip() + items = [d.strip() for d in directives if d and d.strip()] + return "\n".join(f"- {item}" for item in items) + + +def _render_anchors(derived: BRCDerivedAnchors | None, caps: RootCaps) -> str: + """Render the #3189 deterministic anchors with sorted keys + bounded counts.""" + if derived is None: + return "(no reviewed proposals yet)" + + lines: list[str] = [] + + # (i) last-reviewed SHA per producer — sort by producer. + lines.append("Last-reviewed SHA per producer:") + shas = sorted(derived.last_reviewed_sha.items()) + if shas: + for producer, sha in shas[: caps.max_shas]: + lines.append(f" {producer}: {sha}") + if len(shas) > caps.max_shas: + lines.append(_elision(len(shas) - caps.max_shas)) + else: + lines.append(f" {_NONE}") + + # (ii) latest verdict per reviewer->producer edge — sort by + # (producer, reviewer) with version/sha as final tiebreakers so the order is + # byte-stable even if the derived layer ever emits >1 entry per edge. + lines.append("Latest verdicts (reviewer -> producer):") + verdicts = sorted( + derived.latest_verdicts, + key=lambda v: (v.producer, v.reviewer, v.version, v.reviewed_sha or ""), + ) + if verdicts: + for v in verdicts[: caps.max_verdicts]: + sha = f" @ {v.reviewed_sha}" if v.reviewed_sha else "" + lines.append(f" {v.reviewer} -> {v.producer}: {v.verdict.value} (v{v.version}){sha}") + if len(verdicts) > caps.max_verdicts: + lines.append(_elision(len(verdicts) - caps.max_verdicts)) + else: + lines.append(f" {_NONE}") + + # (iii) open NACKs — sort by (producer, reviewer) with version/reason as + # final tiebreakers for byte-stability across duplicate edges. + lines.append("Open NACKs (current version, unresolved):") + nacks = sorted( + derived.open_nacks, + key=lambda n: (n.producer, n.reviewer, n.version, n.reason or ""), + ) + if nacks: + for n in nacks[: caps.max_nacks]: + reason = _truncate(n.reason, caps.reason_chars) if n.reason else "(no reason given)" + lines.append(f" {n.reviewer} -> {n.producer} (v{n.version}): {reason}") + if len(nacks) > caps.max_nacks: + lines.append(_elision(len(nacks) - caps.max_nacks)) + else: + lines.append(f" {_NONE}") + + # (iv) conditional-ACK obligations — sort by (producer, reviewer) with + # version/condition/resolved as final tiebreakers. These are the most + # plausible place for multiple entries per edge, so the extra keys keep the + # render byte-stable rather than relying on the upstream deriver's order. + lines.append("Conditional-ACK obligations:") + obligations = sorted( + derived.conditional_ack_obligations, + key=lambda o: (o.producer, o.reviewer, o.version, o.condition or "", o.resolved), + ) + if obligations: + for o in obligations[: caps.max_obligations]: + status = "resolved" if o.resolved else "OPEN" + condition = _truncate(o.condition, caps.condition_chars) + lines.append(f" {o.reviewer} -> {o.producer} (v{o.version}) [{status}]: {condition}") + if len(obligations) > caps.max_obligations: + lines.append(_elision(len(obligations) - caps.max_obligations)) + else: + lines.append(f" {_NONE}") + + return "\n".join(lines) + + +def render_protected_root( + *, + role: str, + role_contract: str, + task_description: str | None = None, + derived: BRCDerivedAnchors | None = None, + directives: str | Sequence[str] | None = None, + caps: RootCaps | None = None, +) -> str: + """Render the deterministic, byte-stable protected root for ``role``. + + Args: + role: The agent role (e.g. ``coder``, ``reviewer_code``). Parameterizes + the root header so two roles render distinct-but-each-stable roots. + role_contract: The role's behavioural contract text (section a). + Hard-capped at ``caps.role_contract_chars``. + task_description: The task anchor (section b) — compose it with + :func:`egg_contracts.loader.compose_task_description` so the + #3163 anchoring is applied uniformly. Hard-capped at + ``caps.task_chars``. ``None`` renders ``(none)``. + derived: The mechanically-derived #3189 anchors (section c). ``None`` + renders a "no reviewed proposals yet" placeholder. + directives: Non-negotiable directives (section d) as a single string or + an ordered sequence of bullet items. Hard-capped at + ``caps.directives_chars``. + caps: Optional override of the per-section caps. + + Returns: + The assembled root as a single string. Byte-identical for identical + input. + """ + caps = caps or RootCaps() + role = (role or "").strip() or "unknown" + + header = f"=== PROTECTED ROOT — role: {role} ===" + sections = [ + _section("ROLE CONTRACT", _truncate(role_contract or "", caps.role_contract_chars)), + _section("TASK", _truncate(task_description or "", caps.task_chars)), + _section("BRC ANCHORS (#3189)", _render_anchors(derived, caps)), + _section( + "NON-NEGOTIABLE DIRECTIVES", + _truncate(_normalize_directives(directives), caps.directives_chars), + ), + ] + return "\n\n".join([header, *sections]) + "\n" diff --git a/shared/egg_anchor/tests/test_brc_anchor_derivation.py b/shared/egg_anchor/tests/test_brc_anchor_derivation.py index eb6b23eba3..b62767a193 100644 --- a/shared/egg_anchor/tests/test_brc_anchor_derivation.py +++ b/shared/egg_anchor/tests/test_brc_anchor_derivation.py @@ -191,10 +191,14 @@ def _scenario_messages() -> list[dict[str, Any]]: return [ # coder v1 — ACKed, then superseded. _msg("CONSENSUS_PROPOSE", "coder", 1, version=1, commit_sha=SHA_CODER_V1), - _msg("CONSENSUS_ACK", "reviewer_code", 2, to_role="coder", version=1, commit_sha=SHA_CODER_V1), + _msg( + "CONSENSUS_ACK", "reviewer_code", 2, to_role="coder", version=1, commit_sha=SHA_CODER_V1 + ), # coder re-proposes v2 — supersedes v1. _msg("CONSENSUS_PROPOSE", "coder", 3, version=2, commit_sha=SHA_CODER_V2), - _msg("CONSENSUS_NACK", "reviewer_code", 4, to_role="coder", version=2, reason="missing guard"), + _msg( + "CONSENSUS_NACK", "reviewer_code", 4, to_role="coder", version=2, reason="missing guard" + ), _msg( "CONSENSUS_ACK", "reviewer_security", diff --git a/shared/egg_anchor/tests/test_protected_root.py b/shared/egg_anchor/tests/test_protected_root.py new file mode 100644 index 0000000000..eb858fc3e5 --- /dev/null +++ b/shared/egg_anchor/tests/test_protected_root.py @@ -0,0 +1,449 @@ +"""Tests for the deterministic protected-root renderer (slice-4, task-4-2). + +#3200 / slice-4 ("Protected root: deterministic, byte-stable, cacheable"). +The coder (task-4-1) lands a renderer that assembles the small, resident, +role-parameterized protected root in a FIXED four-section order: + + (a) role contract; + (b) task anchor (``compose_task_description``, #3163); + (c) the four #3189 deterministic anchors derived in slice-3 + (:class:`egg_anchor.models.BRCDerivedAnchors`: last-reviewed SHA per + producer, latest verdict per edge, open NACKs, conditional-ACK + obligations); + (d) non-negotiable directives. + +The renderer emits STABLE BYTES: sorted keys, bounded sections, hard +per-section caps, and NO timestamps / sequence numbers / nondeterministic +ordering — so an identical anchor input yields identical bytes across runs and +the root is safely cacheable + resident. + +This file asserts the four task-4-2 acceptance properties: + + 1. byte-stability — identical input -> identical bytes; + 2. per-section caps — oversized sections truncated at the documented cap; + 3. sort-stability — key/element ordering stable regardless of input order; + 4. role-parameterized — two roles render distinct-but-each-stable roots. + +The renderer signature (``render_protected_root(*, role, role_contract, +task_description, derived, directives, caps)``) is merged, so these tests call +it directly with keyword arguments — a renderer regression fails loudly here +rather than being masked by a skip. +""" + +from __future__ import annotations + +from typing import Any + +from egg_anchor.models import ( + BRCDerivedAnchors, + ConditionalAckObligation, + OpenNack, + ReviewEdgeVerdict, + ReviewVerdict, +) +from egg_anchor.protected_root import RootCaps, render_protected_root + +# --------------------------------------------------------------------------- +# Canonical fixture inputs. Sentinels are unique so each of the four sections +# can be located in the rendered root. +# --------------------------------------------------------------------------- + +ROLE_A = "reviewer_code" +ROLE_B = "coder" + +ROLE_CONTRACT_SENTINEL = "ZZ-ROLE-CONTRACT-SECTION-A-ZZ" +TASK_ANCHOR_SENTINEL = "ZZ-TASK-ANCHOR-SECTION-B-ZZ" +DIRECTIVE_SENTINEL = "ZZ-NON-NEGOTIABLE-DIRECTIVE-SECTION-D-ZZ" + +SHA_CODER = "abc1230000000000000000000000000000000def" +SHA_TESTER = "fed3210000000000000000000000000000000cba" + + +def _task_anchor() -> str: + """A faithful task anchor (compose_task_description, #3163) when importable.""" + try: + from egg_contracts.loader import compose_task_description + except ImportError: + return f"This pipeline's task is GitHub issue #3200. {TASK_ANCHOR_SENTINEL}" + composed = compose_task_description( + description=f"{TASK_ANCHOR_SENTINEL} Protected root context discipline.", + issue_number=3200, + issue_url="https://github.com/jwbron/egg/issues/3200", + ) + return composed or f"{TASK_ANCHOR_SENTINEL}" + + +def _anchors() -> BRCDerivedAnchors: + """A realistic, fully-populated set of #3189 anchors (section c).""" + return BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER, "tester": SHA_TESTER}, + latest_verdicts=[ + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.NACK, + version=2, + reviewed_sha=SHA_CODER, + ), + ReviewEdgeVerdict( + reviewer="reviewer_security", + producer="coder", + verdict=ReviewVerdict.CONDITIONAL_ACK, + version=2, + reviewed_sha=SHA_CODER, + ), + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="tester", + verdict=ReviewVerdict.ACK, + version=1, + reviewed_sha=SHA_TESTER, + ), + ], + open_nacks=[ + OpenNack( + reviewer="reviewer_code", + producer="coder", + version=2, + reason="missing guard on the ResultMessage branch", + ), + ], + conditional_ack_obligations=[ + ConditionalAckObligation( + reviewer="reviewer_security", + producer="coder", + version=2, + condition="git mv old/path new/path before merge", + resolved=False, + ), + ], + ) + + +def _canonical_inputs() -> dict[str, Any]: + return { + "role": ROLE_A, + "role_contract": ( + f"{ROLE_CONTRACT_SENTINEL} {ROLE_A}: review the diff for correctness " + "and never drop an open NACK obligation." + ), + "task_description": _task_anchor(), + "derived": _anchors(), + "directives": [ + f"{DIRECTIVE_SENTINEL} The deterministic anchor layer is authoritative.", + "Re-derive anchors on reseed; never re-review a settled SHA.", + ], + } + + +def _render(**overrides: Any) -> str: + """Render the protected root from the canonical inputs, with overrides.""" + inputs = _canonical_inputs() + inputs.update(overrides) + return render_protected_root(**inputs) + + +# --------------------------------------------------------------------------- +# 1. Byte-stability — identical input -> identical bytes, all four sections. +# --------------------------------------------------------------------------- + + +def test_render_is_byte_stable_across_identical_renders() -> None: + """Two renders of identical input produce byte-for-byte identical output.""" + first = _render() + second = _render() + assert first == second + assert isinstance(first, str) + assert first, "protected root rendered empty" + + +def test_render_contains_all_four_sections_in_fixed_order() -> None: + """All four sections render; the deterministic anchor layer is present.""" + text = _render() + # (a) role contract, (b) task anchor, (c) #3189 anchors, (d) directives. + assert ROLE_CONTRACT_SENTINEL in text + assert TASK_ANCHOR_SENTINEL in text + assert SHA_CODER in text, "section (c): last-reviewed SHA not rendered" + assert "missing guard" in text, "section (c): open NACK reason not rendered" + assert DIRECTIVE_SENTINEL in text + + # Fixed order a -> b -> c -> d. + markers = [ + ROLE_CONTRACT_SENTINEL, + TASK_ANCHOR_SENTINEL, + SHA_CODER, + DIRECTIVE_SENTINEL, + ] + positions = [text.find(m) for m in markers] + assert all(p >= 0 for p in positions), f"a section sentinel is missing: {positions}" + assert positions == sorted(positions), ( + f"protected-root sections are not in the fixed a->b->c->d order: {positions}" + ) + + +# --------------------------------------------------------------------------- +# 2. Per-section caps — oversized sections truncated at a hard cap. +# --------------------------------------------------------------------------- + +_OVERSIZE = 4_000_000 # ~4 MB of filler — far past any reasonable section cap. + + +def test_oversized_freetext_section_is_truncated() -> None: + """A multi-megabyte role-contract section is hard-capped, not inlined whole.""" + head = "OVERSIZE-HEAD-SENTINEL" + giant = f"{head} " + ("x" * _OVERSIZE) + text = _render(role_contract=giant) + assert giant not in text, "oversized section was inlined verbatim (no cap)" + # A hard cap keeps the whole root far smaller than the raw oversized input. + assert len(text) < _OVERSIZE / 20, ( + f"rendered root len {len(text)} not bounded below a hard per-section cap" + ) + # Truncated, not omitted: the head of the section survives. + assert head in text, "capped section dropped entirely instead of truncating" + + +def test_oversized_anchor_section_is_truncated() -> None: + """A flood of open NACKs (section c) is bounded by the per-section cap.""" + flood = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + open_nacks=[ + OpenNack( + reviewer=f"reviewer_{i}", + producer="coder", + version=2, + reason="y" * 1000, + ) + for i in range(5000) + ], + ) + text = _render(derived=flood) + # 5000 * ~1KB reasons ~= 5MB of raw anchor content; the cap must bound it. + assert len(text) < 5_000_000 / 20, ( + f"anchor section len {len(text)} not bounded by a hard per-section cap" + ) + + +# --------------------------------------------------------------------------- +# 3. Sort-stability — element/key ordering does not depend on input order. +# --------------------------------------------------------------------------- + + +def test_render_is_stable_regardless_of_input_ordering() -> None: + """Permuting dict-key and list-element order yields identical bytes. + + A byte-stable protected root must sort its own content rather than trust + callers to pre-sort — so the same logical anchors in a different order + render identically. + """ + forward = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER, "tester": SHA_TESTER}, + latest_verdicts=[ + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.NACK, + version=2, + reviewed_sha=SHA_CODER, + ), + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="tester", + verdict=ReviewVerdict.ACK, + version=1, + reviewed_sha=SHA_TESTER, + ), + ], + open_nacks=[ + OpenNack(reviewer="reviewer_a", producer="coder", version=2, reason="alpha"), + OpenNack(reviewer="reviewer_b", producer="coder", version=2, reason="beta"), + ], + ) + # Same logical content, reversed dict-insertion and list order. + reversed_anchors = BRCDerivedAnchors( + last_reviewed_sha={"tester": SHA_TESTER, "coder": SHA_CODER}, + latest_verdicts=list(reversed(forward.latest_verdicts)), + open_nacks=list(reversed(forward.open_nacks)), + ) + + assert _render(derived=forward) == _render(derived=reversed_anchors) + + +# --------------------------------------------------------------------------- +# 4. Role-parameterization — distinct roots per role, each individually stable. +# --------------------------------------------------------------------------- + + +def test_two_roles_render_distinct_but_each_stable_roots() -> None: + """Distinct roles -> distinct roots; each role's root is byte-stable.""" + role_a_contract = f"{ROLE_CONTRACT_SENTINEL} {ROLE_A} contract." + role_b_contract = f"{ROLE_CONTRACT_SENTINEL} {ROLE_B} contract." + + a_first = _render(role=ROLE_A, role_contract=role_a_contract) + a_second = _render(role=ROLE_A, role_contract=role_a_contract) + b_first = _render(role=ROLE_B, role_contract=role_b_contract) + b_second = _render(role=ROLE_B, role_contract=role_b_contract) + + # Each role's root is individually byte-stable. + assert a_first == a_second + assert b_first == b_second + # The two roles render distinct roots (role-parameterized). + assert a_first != b_first + + assert ROLE_A in a_first + assert ROLE_B in b_first + + +# --------------------------------------------------------------------------- +# 5. Robustness guards — exercise the tiebreaker keys and the sub-marker +# `_truncate` clamp directly, so the determinism they protect is locked in +# even though the upstream deriver currently makes both cases unreachable. +# --------------------------------------------------------------------------- + + +def test_duplicate_edge_entries_are_byte_stable_via_tiebreakers() -> None: + """>1 entry per (producer, reviewer) edge renders identically regardless of order. + + The primary sort key is ``(producer, reviewer)``; if the derived layer ever + emits multiple entries for the same edge, the ``version`` tiebreaker keeps + the render byte-stable. Here every duplicate pair carries a distinct + ``version``, so this test exercises the ``version`` tiebreaker specifically; + the secondary ``reviewed_sha``/``reason``/``condition``/``resolved`` keys (for + the rarer case where ``version`` also collides) are covered by + :func:`test_version_collisions_disambiguated_by_secondary_tiebreakers`. + Permuting the input order of duplicate-edge entries must not change the + output — this fails loudly if the ``version`` tiebreaker is dropped. + """ + forward = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + latest_verdicts=[ + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.NACK, + version=1, + reviewed_sha=SHA_CODER, + ), + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.ACK, + version=2, + reviewed_sha=SHA_TESTER, + ), + ], + open_nacks=[ + OpenNack(reviewer="reviewer_code", producer="coder", version=1, reason="alpha"), + OpenNack(reviewer="reviewer_code", producer="coder", version=2, reason="beta"), + ], + conditional_ack_obligations=[ + ConditionalAckObligation( + reviewer="reviewer_security", + producer="coder", + version=1, + condition="first condition", + resolved=False, + ), + ConditionalAckObligation( + reviewer="reviewer_security", + producer="coder", + version=2, + condition="second condition", + resolved=True, + ), + ], + ) + # Same logical content, every duplicate-edge list reversed. + reversed_anchors = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + latest_verdicts=list(reversed(forward.latest_verdicts)), + open_nacks=list(reversed(forward.open_nacks)), + conditional_ack_obligations=list(reversed(forward.conditional_ack_obligations)), + ) + + assert _render(derived=forward) == _render(derived=reversed_anchors) + + +def test_version_collisions_disambiguated_by_secondary_tiebreakers() -> None: + """Entries colliding on (producer, reviewer, version) sort by the secondary keys. + + This is the case the ``version`` tiebreaker alone cannot resolve: every pair + shares the same ``(producer, reviewer, version)``, so byte-stability rests + *only* on the trailing key — ``reviewed_sha`` for verdicts, ``reason`` for + NACKs, ``condition``/``resolved`` for obligations. Reversing the input must + still render identically; dropping any of those secondary keys makes the two + renders diverge and this test fail loudly. + """ + forward = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + latest_verdicts=[ + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.NACK, + version=2, + reviewed_sha=SHA_CODER, # secondary key A + ), + ReviewEdgeVerdict( + reviewer="reviewer_code", + producer="coder", + verdict=ReviewVerdict.ACK, + version=2, + reviewed_sha=SHA_TESTER, # secondary key B (same edge + version) + ), + ], + open_nacks=[ + OpenNack(reviewer="reviewer_code", producer="coder", version=2, reason="alpha"), + OpenNack(reviewer="reviewer_code", producer="coder", version=2, reason="beta"), + ], + conditional_ack_obligations=[ + ConditionalAckObligation( + reviewer="reviewer_security", + producer="coder", + version=2, + condition="aaa condition", + resolved=False, + ), + ConditionalAckObligation( + reviewer="reviewer_security", + producer="coder", + version=2, + condition="zzz condition", + resolved=True, + ), + ], + ) + reversed_anchors = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + latest_verdicts=list(reversed(forward.latest_verdicts)), + open_nacks=list(reversed(forward.open_nacks)), + conditional_ack_obligations=list(reversed(forward.conditional_ack_obligations)), + ) + + assert _render(derived=forward) == _render(derived=reversed_anchors) + + +def test_sub_marker_cap_hard_trims_without_marker() -> None: + """A cap smaller than the truncation marker hard-trims to the cap, never longer. + + With ``reason_chars`` below the marker length, ``_truncate`` cannot fit its + marker, so it hard-trims the value to the cap rather than returning the + (longer) marker alone — keeping the documented "hard ceiling including the + marker" guarantee for any custom :class:`RootCaps`. + """ + flood = BRCDerivedAnchors( + last_reviewed_sha={"coder": SHA_CODER}, + open_nacks=[ + OpenNack( + reviewer="reviewer_code", + producer="coder", + version=2, + reason="abcdefghij" * 10, # 100 chars, far past the 5-char cap. + ), + ], + ) + text = _render(derived=flood, caps=RootCaps(reason_chars=5)) + # The reason is hard-trimmed to exactly 5 chars, with no marker appended + # (the cap is smaller than the marker, so the marker cannot be added). + assert "abcde" in text + assert "abcdef" not in text + assert "…[truncated]" not in text