Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def _append_ledger_row(context: FlowContext, branch: str, ledger: str, row: dict
raise
except (RuntimeError, TimeoutError, OSError, ValueError) as exc:
return redact_agent_secrets(str(exc))
# why: the row is already pushed to origin, so a failed local ref sync must never be reported as a failed write
_best_effort_sync_local_refs(context, branch, pushed_sha)
return None

Expand Down
1 change: 1 addition & 0 deletions apps/sandbox-executor/tests/test_executor_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def test_witness_pattern_3_multiline_yaml_json_nested_keys(self):
def test_diagnostic_retention_invariants(self):
from sandbox_executor.entrypoint.executor import redact_text

# why: non-secret *_key and look-alike names must stay unmasked so redaction never destroys diagnostic output
benign_text = (
"sort_key=asc cache_key=123 primary_key=id foreign_key=user_id "
"compat=1.0.0 compact=true impact=high monkey=banana donkey=kong"
Expand Down
87 changes: 87 additions & 0 deletions executions/E-1796254209-CLA-CO5.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Execution Record: E-1796254209-CLA-CO5.5

## Summary

Comment-only restoration of the remaining `# why:` rationale entries for intent
`I-1796253989-hac-restore-why-src-batch3` following plan `P-1796254012-CLA-CO5.5`.

## Actual Metrics

| metric | value |
| --------------------- | ----- |
| success_actual | 0.9 |
| entropy_actual | 2.4 |
| impact_actual | 30.0 |
| cost_actual | 5.0 |
| learning_value_actual | 3.0 |

## Steps Executed

### Step 1: Re-confirm the in-scope inventory

- `measure_deleted_why_comments.py --ref HEAD --format json` still lists exactly 18 in-scope entries (PRs #305, #426,
#405, #388, #387, #386, #428); total `unmatched_count` is 101.
- Every "already present" `# why:` line exists at the plan's recorded line. `flow/git_refs.py` was 343 lines with
`_best_effort_sync_local_refs(context, branch, pushed_sha)` at the end of `_append_ledger_row`.
`test_diagnostic_retention_invariants` began with `benign_text = (` and had no `# why:` comment. No drift.

### Step 2: Restore the ledger-row local-ref-sync rationale

- Added one `# why:` line above `_best_effort_sync_local_refs(...)` in `_append_ledger_row` (`git_refs.py:261`).
- AST equal to `HEAD`, file is 344 lines (budget 350), `ruff check` and `ruff format --check` clean.

### Step 3: Restore the diagnostic-retention rationale

- Added one `# why:` line above `benign_text = (` in `test_diagnostic_retention_invariants`
(`test_executor_commands.py:207`). No second comment above `kebab_text`.
- AST equal to `HEAD`, `ruff check`, `ruff format --check` and `check_self_explaining.py` clean (the `*_key` text was
accepted, so no rewording was needed).

### Step 4: Record the full entry mapping

#### Why-comment entry mapping

| PR | File (old line) | Removed text (abridged) | Disposition | Reason or location |
| ---- | ------------------------------------- | ------------------------------------------------ | --------------- | ------------------------------------------------------------------------------------------ |
| #305 | `flow/git_refs.py:305` | row is on origin now; local ref sync best-effort | restored | `flow/git_refs.py:261` |
| #426 | `test_sandbox_hermetic_guard.py:127` | files and dummy .git untouched by child run | already present | `test_sandbox_hermetic_guard.py:77` |
| #426 | `test_touch_set_overlap.py:48` | metadata never overlaps | already present | `test_touch_set_overlap.py:46` |
| #426 | `test_touch_set_overlap.py:66` | new file never overlaps a folder | already present | `test_touch_set_overlap.py:65` |
| #426 | `test_turn_live_children.py:21` | foreground test, no CPU, never exits | already present | `test_turn_live_children.py:16` |
| #405 | `flow/test_in_flight.py:151` | own worktree is never read | already present | `flow/test_in_flight.py:152` |
| #405 | `flow/test_ledger_interleave.py:74` | ours appended out of time order | already present | `flow/test_ledger_interleave.py:72` |
| #405 | `flow/test_ledger_interleave.py:89` | ours never moves; untimed row glued | already present | `flow/test_ledger_interleave.py:87` |
| #388 | `test_init.py:122` | second init without force: data persists | shown by code | `force=False` call followed by byte-equal asserts on all three ledgers |
| #388 | `test_init.py:134` | third init with force: data still persists | already present | `test_init.py:123` |
| #388 | `test_init.py:153` | without force must preserve custom content | shown by code | `assertEqual(..., "CUSTOM USER RULESET")` after the non-force init |
| #388 | `test_init.py:158` | with force must overwrite with template | shown by code | `force=True` then `assertNotEqual` and `assertIn("Holon World Ruleset")` |
| #388 | `test_init.py:187` | run again, total idempotency | shown by code | test name `..._appends_without_duplication` and `assertEqual(lines, lines2)` after re-init |
| #387 | `flow/github/test_review_post.py:139` | exactly one post, never gh pr comment | already present | `flow/github/test_review_post.py:129` |
| #386 | `test_executor_commands.py:215` | multiline YAML quoted child key | already present | `test_executor_commands.py:195` |
| #386 | `test_executor_commands.py:228` | benign diagnostic keys remain unmasked | restored | `test_executor_commands.py:207` |
| #386 | `test_executor_commands.py:235` | kebab-case diagnostic keys remain unmasked | covered | the comment at line 207 covers the whole invariant block; `assertEqual(redact_text(x), x)` |
| #428 | `tests/test_self_doc_src_g.py:29` | `# why: reason` | obsolete | file deleted by PR #428; the text was a scanner fixture, not a rationale |

`measure_deleted_why_comments.py` replays the removed lines of historical merged PR diffs, so its `unmatched_count` is
expected to stay unchanged after this execution; the mapping above, not the script count, is the acceptance record.

### Step 5: Verify gates, affected tests and the full suite

- `git diff --stat a1f07bf5a` lists only `flow/git_refs.py` (`1 +`), `tests/test_executor_commands.py` (`1 +`) and these
notes. AST equality against `HEAD` holds for both code files.
- One full-suite failure, `test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave` (ledger lock timeout
under `-n auto` load). This plan changed no code in that test or in the ledger modules. Rerun alone, the file passes
(`15 passed`). The plan asks to confirm the failure on the base commit, but `git worktree add` failed here (read-only
git metadata directory), so it is recorded as a pre-existing, timing-sensitive flake and not edited.

## Tests Run

| command | result | time |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------- | ------- |
| `uv run python scripts/check_self_explaining.py` | passed | n/a |
| `uv run task lint` | passed (exit 0; module budgets passed, 441 modules) | n/a |
| `uv run pytest -n auto --dist worksteal` on the 8 affected test files from plan Step 5 | 1413 passed, 0 failed | 16.26s |
| `uv run task test` (full suite, one run) | 11330 passed, 1 failed, 8 skipped | 199.89s |
| `uv run pytest apps/sandbox-executor/tests/test_ledger_lock.py` (isolated flake recheck) | 15 passed, 0 failed | 13.04s |

Each command ran once, so each median equals its single recorded time.
Loading
Loading