Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

| Order | Chunk | Purpose | Risk | State |
|---:|---|---|---:|---|
| 0 | `WS-ENG-007-00R1` | Repair planning-intake file/tree parity and recover PR #187 exactly once | L1/P0 | Emergency prerequisite review |
| 1 | `WS-ENG-007-01` | Add deterministic reviewed-patch identity and conservative base-delta review preservation | L1 | Blocked on 00R1 merge, signed reconciliation, and explicit start |
| 0 | `WS-ENG-007-00R1` | Repair planning-intake file/tree parity and recover PR #187 exactly once | L1/P0 | Merged; recovery superseded after rerun-cardinality failure |
| 0 | `WS-ENG-007-00R2` | Canonicalize repeated trusted check evidence and reconcile PRs #187 and #188 exactly once | L1/P0 | Proposed reliability recovery |
| 1 | `WS-ENG-007-01` | Add deterministic reviewed-patch identity and conservative base-delta review preservation | L1 | Blocked on 00R2 merge, successful three-merge reconciliation, and explicit start |
| 2 | `WS-ENG-007-02` | Add structured reviewer-track and upstream-finding reconciliation | L1 | Blocked on 01 merge and explicit start |
| 3 | `WS-ENG-007-03` | Add merge-group CI parity and queue-readiness proof | L1 | Blocked on 02 merge and explicit start |

Each chunk is one PR and stops after merge. Every successor requires a separate
Recovery chunks are exceptional ordered prerequisites; implementation chunks
remain one PR each and stop after merge. Every successor requires a separate
explicit signed start.
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ Use the existing closed schema-v1 two-merge recovery mechanism, rebound to PR
`WS-ENG-007-00R1`. Both ephemeral
exemptions must be consumed before signing; no wildcard, manual state edit,
force push, new secret, or persistent exemption is allowed.

## D12 - Check reruns are evidence versions, not ambiguity

For each protected check name, validate every returned same-name check against
the exact reviewed head and pinned GitHub Actions application. Reject the set if
any candidate is foreign, wrong-head, malformed, incomplete, or reuses an ID.
Order completed candidates by parsed `started_at` instant then positive numeric
check-run ID. The unique latest invocation determines the result. `completed_at`
must be a valid instant at or after start, but completion order never defines
recency. A later-started failure supersedes an older success even when the older
run completes last. Rerun count alone never fails reconciliation.

## D13 - Recover the exact three-merge backlog once

Schema v3 names an ordered `recovered_merges` list of one or two entries plus
one activation; production requires exactly two recovered entries.
For this repair it binds only PR #187 / `WS-ENG-007-PLAN`, PR #188 /
`WS-ENG-007-00R1`, and direct-next `WS-ENG-007-00R2`. The plan must be exactly
those adjacent first-parent merges. All exemptions are consumed before signing
and cannot appear in state, ledger, projections, or replay.
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ tracks. A PR never authors or narrows this graph.
- Exact GitHub merge-queue repository-setting API behavior.
- Hosted context behavior after queue enablement. These block administrative
enablement, not repository-side parity planning.

## Recovery reliability discovery — 2026-07-23

- PR #188 merged at `c65633f8f0991dbefe7b0635e053aab0df8f9af8`.
- Loop Memory run `29984940789` failed before publication with `planning intake
check agent-gates is missing or duplicated`.
- PR #187 head `34ddac158d8c8d5c96498de008dd43354205199f`
has two completed successful `agent-gates` runs from GitHub Actions app
`15368/github-actions` and one completed successful `test` run from the same
app.
- `_validate_protected_actions_checks()` requires exactly one match, while
`_check_evidence()` already treats check history as a latest-value stream.
- The current schema-v1 recovery certificate can name only one recovered merge
plus activation. Signed state is two merges behind, so the repair target is a
third adjacent merge and requires an exact ordered multi-recovered schema.
- The workflow already plans all unrecorded first-parent commits and publishes
only after reconciliation; no workflow edit is required.
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,34 @@ forged manifests, and merge-group combined trees.
Approve each implementation chunk and the later repository-setting change that
enables GitHub merge queue. No queue or automatic merge setting changes in the
planning intake.

## Recovery reliability addendum — WS-ENG-007-00R2

### Problem being solved

Signed reconciliation treats legitimate same-name GitHub Actions reruns as
ambiguity. PR #187 therefore cannot enter signed history even though both
`agent-gates` runs and its `test` run are trusted and successful.

### Target behavior

Rerun count is harmless. A deterministic latest trusted run controls each
protected result, later failures cannot be hidden by older successes, and the
exact three-merge backlog is reconciled atomically without reusable authority.

### Boundaries preserved

Required checks, branch protection, signing keys, permissions, human merge
approval, coverage floors, product behavior, and successor start gates do not
change.

### Proof strategy

Adversarial check histories, permutation invariance, exact production policy
pinning, ordered recovery consumption, replay rejection, and byte-identical
idempotency evidence.

### Human decision

The user's explicit `start` instruction approves planning and execution of this
bounded reliability repair only. Successor starts remain separately gated.
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,28 @@ always:

Stop if preservation depends on mutable PR prose, inaccessible commits, an
unbounded semantic judgment, weakened CI, or automatic human approval.

## Recovery reliability plan — WS-ENG-007-00R2

1. Replace exact-cardinality protected-check validation with a deterministic
latest-run selector that validates all same-name candidates against exact
head, pinned app, structural fields, and parseable timestamps before sorting.
2. Reject the complete name-set if any candidate is malformed, untrusted, or
incomplete. Order completed candidates by parsed `started_at` instant then
positive numeric check-run ID. `completed_at` proves terminal consistency
but never defines invocation recency. Require the selected run to succeed.
3. Extend the closed recovery certificate with schema v3: an ordered
`recovered_merges` list plus one activation. Validate exact plan equality,
chronological first-parent adjacency, identities, aggregate required checks,
protected-check provenance on every recovered/target head, uniqueness, and
consumption. Schema v3 permits at most two recovered merges; production
requires exactly both named entries.
4. Bind production recovery to PR #187, PR #188, and direct-next 00R2 only.
5. Prove adversarial rerun histories, permutation invariance, exact recovery,
non-serialization, replay rejection, and deterministic repeated output.
6. Preserve the existing workflow, signing, human approval, successor stops,
and required-check names unchanged.

Rejected alternatives: ignore duplicate runs, accept any successful run, use API
array order, use only a check name/status context, rerun until history changes,
manually edit signed state, or add a persistent recovery bypass.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
| Concurrent queue entries interact | High | Validate each exact merge-group SHA and invalidate on queue recomputation. |
| Planning intake cannot enter signed history | Critical | Filter only validated directory entries from the GitHub recursive tree map, preserve every validated supported non-tree leaf identity, reject unsupported entries, and recover exact PR `#187` plus 00R1 through a consumed two-merge certificate. |
| Recovery becomes a reusable bypass | Critical | Bind schema-v1 recovery to PR #187 merge `8928ba80eeaf31e609dbdeda7d2cc22e9ea482c8` and the exact 00R1 activation identity; require the ordered two-merge plan, successful checks, full consumption, and no persisted exemption. |
| Legitimate check reruns block signed memory | Critical | Validate every same-name candidate, order completed trusted invocations by parsed start instant and positive check-run ID, then require the unique latest candidate to succeed. |
| A stale success hides a later failure | Critical | Latest validated run wins; an in-progress, failed, cancelled, foreign-app, malformed, or timestamp-ambiguous latest run fails closed. |
| Three-merge repair becomes general authority | Critical | Schema v3 permits at most two recovered merges and production names only PR #187, PR #188, and 00R2; require exact first-parent adjacency, unique identities, full consumption before signing, and no serialization. |
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# STATUS: WS-ENG-007 - Concurrent PR Review Reconciliation

- Phase: planning-intake recovery
- Phase: canonical check-evidence recovery
- Gate: fail-closed automation repair
- Active planning chunk: none
- Active implementation chunk: none
- Recovery chunk: `WS-ENG-007-00R1`
- Completed but unreconciled recovery chunk: `WS-ENG-007-00R1`
- Proposed recovery chunk: `WS-ENG-007-00R2`
- Proposed implementation successor after recovery: `WS-ENG-007-01`
- Separate explicit start required: true
- Current gate: PR #187 merged at
`8928ba80eeaf31e609dbdeda7d2cc22e9ea482c8`, but signed post-merge memory and
the fresh explicit start both fail closed because recursive GitHub tree
evidence includes directory entries while the reviewed PR file inventory and
independent local Git checker contain only recursive non-tree entries.
- Current gate: PR #188 merged at
`c65633f8f0991dbefe7b0635e053aab0df8f9af8`. Its tree normalization repair is
correct, but signed reconciliation still fails because PR #187 has two
successful trusted `agent-gates` reruns and planning intake incorrectly
treats repeated check evidence as ambiguous. Signed state remains at
`73b457925b02301587b83d01ced0adb66319d134`; no successor is active.
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Chunk Contract: WS-ENG-007-00R2 — Canonical Check Evidence Recovery

## Goal

Make signed merge reconciliation stable under legitimate GitHub Actions reruns
and reconcile the exact PR #187 → PR #188 → 00R2 backlog once.

## Why this chunk exists

PR #188 fixed recursive tree parity, but run `29984940789` failed because PR
#187 has two successful trusted `agent-gates` check runs. Cardinality is mutable
GitHub history and is not a valid ambiguity signal. Signed state remains at
`73b457925b02301587b83d01ced0adb66319d134`.

## Start phase

`implementation`

## Risk

L1 / P0 policy, audit, CI-evidence, and signed-memory recovery

## Authorization boundary

This otherwise-unstartable repair uses a reviewed exact schema-v3 recovery
certificate. It grants no workflow, repository, secret, merge, or continuing
start authority.

## Allowed files

```text
scripts/update_post_merge_memory.py
scripts/test_update_post_merge_memory.py
scripts/test_agent_gates.py
scripts/test_check_loop_memory_state.py
.agent-loop/policies/loop-memory-recovery.json
docs/operations_post_merge_memory.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/CHUNK_MAP.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/STATUS.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/RISKS.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/DECISIONS.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/chunks/WS-ENG-007-00R2-canonical-check-recovery.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/reviews/WS-ENG-007-00R2-internal-review-evidence.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/reviews/WS-ENG-007-00R2-pr-trust-bundle.md
.agent-loop/initiatives/WS-ENG-007-concurrent-pr-review-reconciliation/reviews/WS-ENG-007-00R2-external-review-response.md
.agent-loop/merge-intents/WS-ENG-007-00R2.json
```

## Not allowed

- Workflow, required-check name, branch-protection, coverage, dependency,
signing-key, secret, permission, product, backend, or frontend changes.
- Treating CodeRabbit status as implementation-start authority.
- Accepting a foreign app, wrong head, incomplete or malformed check run.
- Letting an older success override a later failure.
- Persistent, wildcard, reorderable, cross-repository, or reusable recovery.
- Starting `WS-ENG-007-01` or `WS-ENG-006-01` in this chunk.

## Acceptance criteria

- [ ] Every same-name candidate is validated before selection. Any poisoned
candidate fails whether older or newer than a valid success and under
every input permutation. Completed trusted candidates are ordered by
parsed `started_at` instant then positive check-run ID; the unique latest
invocation determines success. Completion order never defines recency.
- [ ] Zero matches, incomplete API response, foreign app, wrong head, missing or
malformed ID/timestamps, any non-completed run, non-success latest
conclusion, or a canonical identity collision fails closed. Timestamp
parsing is timezone-aware RFC3339 normalized to instants; naive/non-string
values fail. IDs require `type(id) is int` and `id > 0`; booleans,
byte-identical duplicate IDs, and conflicting ID reuse fail.
- [ ] Tests cover one success, two successes, failure→success, success→failure,
an older-started success completing after a newer-started failure,
queued/in-progress evidence, cancelled/timed_out/skipped conclusions,
foreign app with the protected name, wrong head, offset-equivalent and
identical timestamps resolved by ID, duplicate ID rejection, malformed
timestamps, API truncation, and evidence order permutation. Poisoned
candidates appear both older and newer than a valid success. Later failure
is tested independently for `agent-gates` and `test`.
- [ ] The real PR #187 shape—two successful trusted `agent-gates` plus one
successful trusted `test`—passes deterministically and is permutation
invariant.
- [ ] Schema v3 permits only `schema_version`, ordered `recovered_merges`, and
`activation`; the list contains one or two entries, is identity-unique and SHA-unique,
and every entry binds initiative, chunk, positive PR number, and merge SHA.
Tests reject unknown/missing keys at every level, empty/three-entry lists,
duplicate identity or SHA under changed counterparts, bool/invalid PR,
malformed SHA, activation collision, and policy/Git order mismatch.
- [ ] Production policy binds exactly PR #187 merge
`8928ba80eeaf31e609dbdeda7d2cc22e9ea482c8` / `WS-ENG-007-PLAN`, then PR #188
merge `c65633f8f0991dbefe7b0635e053aab0df8f9af8` /
`WS-ENG-007-00R1`, then activation `WS-ENG-007-00R2`.
- [ ] Recovery requires the exact adjacent first-parent plan
`[8928ba80…, c65633f8…, target]`, validates every recovered identity and
required-check aggregate, validates exact protected-check provenance on
every recovered and target reviewed head, consumes all three exemptions
before signing, serializes none,
and rejects missing, extra, reordered, repeated, intervening, wrong-parent,
wrong-identity, check-failure, partial-consumption, and replay cases.
- [ ] Ephemeral recovery-file schema v1 retains its original maximum of two
entries. Transport schema v2 is emitted only for the exact three-entry
schema-v3 recovery result, requires exactly three unique entries, and
rejects unknown versions, partial inventories, and four entries.
- [ ] Applying the exact authenticated plan to two fresh copies of the same
starting state produces byte-identical complete generated closed trees,
including signing input. Replay from completed state proves no exemption
reinjection and no publication change.
- [ ] Final state records 00R2 stopped with `WS-ENG-007-01` as explicit-start
successor; both `WS-ENG-007-01` and `WS-ENG-006-01` remain inactive.
- [ ] Existing tree, planning grammar, merge attribution, lifecycle, signing,
checker, and recovery regression suites remain blocking and unchanged in
authority semantics.
- [ ] Exactly one schema-v2 merge intent names `WS-ENG-007-01` as the same-
initiative explicit-start successor.

## Verification commands

```bash
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest -q scripts/test_update_post_merge_memory.py scripts/test_agent_gates.py scripts/test_check_loop_memory_state.py
python3 scripts/test_agent_gates.py
python3 scripts/update_post_merge_memory.py validate-merge-intent --repository-root . --base-ref origin/main
PR_HEAD_SHA="$(git rev-parse HEAD)" python3 scripts/check_internal_review_evidence.py
python3 scripts/check_markdown_links.py
python3 scripts/check_stale_workstream_wording.py
git diff --check origin/main...HEAD
```

## Required reviewers

- senior engineering
- QA/test
- security/auth
- product/ops
- architecture
- CI integrity
- docs
- reuse/dedup
- test delta

## Human review focus

Confirm latest-run semantics match GitHub rerun behavior, later failures cannot
be hidden, and schema-v3 authority is exact, ordered, consumed, and non-reusable.

## Stop condition

Stop after this PR. Do not start either successor until the user merges this
specific PR and signed automation proves the exact recovered state.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# External Review Response: WS-ENG-007-00R2

## Comments addressed

- CodeRabbit minor: reflowed the PR `#187` reference in the operations runbook
so Markdown does not parse it as a malformed ATX heading. The review thread
is resolved on PR #189.

## Comments deferred

None.

## Human decisions needed

None.

## Commands rerun

```bash
python3 scripts/check_markdown_links.py
python3 scripts/check_stale_workstream_wording.py
git diff --check origin/main...HEAD
```

## Remaining risks

No new risk. Exact adjacency and fresh exact-head checks remain blocking.
Loading
Loading