Skip to content

merge_audit: read each run's drafts where that run deleted them - #16

Open
vbanas wants to merge 1 commit into
vsov:mainfrom
vbanas:fix-drafts-per-run
Open

vbanas wants to merge 1 commit into
vsov:mainfrom
vbanas:fix-drafts-per-run

Conversation

@vbanas

@vbanas vbanas commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #15.

Problem

recover_drafts read every draft at one commit: the parent of the newest commit
that deleted drafts/. So only the last consolidation run's drafts could be read.
/okfy:update merges new drafts into existing concepts, so the merge group then
holds drafts from two runs. merge-audit reported such groups as unverifiable.
Since 49a0c9d, release-check also refuses them under acceptance.dissent: required
with E_REL_DISSENT_UNVERIFIABLE.

Reading each draft at the newest deletion of its own path doesn't fix it: a draft id
is not unique across runs. Re-extraction reuses ids. Two branches can each extract and
delete the same id with different content when only one branch's row maps it.

Change

  • One git log over drafts/ (--name-only -z, plus --no-renames and
    --relative) maps each draft path to the commits that deleted it, newest first.
    It keeps the existing --full-history --date-order --diff-merges=first-parent.
    If its output can't be parsed, the lookup fails closed as git-error.
  • Per ledger row, not per bundle or per path. A draft belongs to the last row
    whose merge_map names it, the "later row wins" rule merge_groups already
    applies. A row's drafts are read at the parent of the newest commit that deleted
    all of them. That commit is the row's consolidation, or a re-extraction that
    deleted the same drafts again. A draft that no commit deleted doesn't count
    toward "all". If no single commit deleted them all (piecemeal deletion), each
    draft is read at the newest deletion of its own path.
  • An explicit --ref still overrides the lookup for every draft.
  • merge-audit --json adds refs, mapping each draft id to the commit it was
    read at. I keyed it by draft rather than run id (as the issue sketched) for two
    reasons: one run id can cover several rows, and the piecemeal fallback can put
    drafts of one row at different commits. ref keeps its old value when every
    draft shares one commit, and is null otherwise. Naming one commit for all of
    them would send a reader (or the schism pass) to the wrong drafts. The text
    header lists each commit: state: ok (refs 2b1aabc, 16da77a).
  • Docs: USAGE-merge-audit.md describes the per-run lookup and the manual
    command. In schism.md, the blind-first git show uses each draft's own entry
    in refs. The --ref help is updated too.

No new codes or states. recover_drafts keeps its signature. _resolve_ref is gone
(replaced by _commit / _deletions), in case private tests call it.

Tests

scripts/smoke.sh has a new NEG runs step on a standalone bundle:

  • run-1 deletes its two drafts in separate commits (piecemeal);
  • run-2 adds a draft to the same merge group and maps a second draft;
  • a side branch, committed later and merged, extracts and deletes an id that run-2
    maps, with other content and no ledger row.

The step requires merge-audit to read all three group drafts, each at its own
run's commit, with ref: null. It also requires release-check to reach
E_REL_DISSENT_UNADJUDICATED without E_REL_DISSENT_UNVERIFIABLE. It fails:

  • on the previous wheel: 2 of 3 drafts unreadable;
  • with the newest deletion per path: update-01/x is read from the side branch;
  • without the piecemeal fallback: run-1's group is unverifiable.

The full smoke.sh passes, including the reference bundle's merged and rerun
checks and NEG embed. ruff check passes in core. I also checked these by hand:
a merge commit that itself deletes drafts/; draft ids with spaces and non-ASCII
characters; shallow clones (unreachable-ref); a non-git bundle (git-error); an
explicit or bad --ref.

Not included: the optional hardening from the issue (recording each draft's blob id
in input_hashes).

recover_drafts read every draft at one commit, the parent of the
newest commit that deleted drafts/, so only the last consolidation
run's drafts could be read. /okfy:update merges new drafts into
existing concepts, so a merge group then holds drafts of two runs:
merge-audit called it unverifiable, and since 49a0c9d release-check
refuses it under acceptance.dissent: required with
E_REL_DISSENT_UNVERIFIABLE.

The newest deletion of each draft's own path is not enough either: a
draft id is not unique across runs. Re-extraction reuses ids, and two
branches can each extract and delete the same id with different
content when only one of their rows maps it.

- One git log over drafts/ (--name-only -z, with --no-renames and
  --relative) maps each draft path to the commits that deleted it,
  newest first. Output it cannot parse fails closed as git-error.
- A draft belongs to the last ledger row whose merge_map names it,
  the rule merge_groups applies. A row's drafts are read at the
  parent of the newest commit that deleted all of them. If no one
  commit did, each is read at the newest deletion of its own path.
- An explicit --ref still overrides the lookup for every draft.
- merge-audit --json adds refs, {draft id: commit it was read at}.
  ref is set only when every draft shares one commit and is null
  otherwise, so nothing reads all drafts at one wrong commit. The
  header lists each commit: "state: ok (refs 2b1aabc, 16da77a)".
- smoke.sh: a NEG runs step. run-1 deletes its drafts in two commits,
  run-2 grows the group, and a merged side branch deletes an id that
  run-2 maps. It fails on the previous wheel (2 of 3 drafts
  unreadable), with the newest deletion per path (the side branch's
  draft is read), and without the piecemeal fallback.
- USAGE-merge-audit.md and schism.md: the per-run lookup, and the
  blind-first read uses each draft's own entry in refs.

Fixes vsov#15.
@vbanas

vbanas commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@vsov Please, take a look when You will have time. Thank You in advance,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge groups that span consolidation runs are unverifiable: every draft is read from one commit

1 participant