From 2928db337d34f45090fba4431a3ba8dafc619268 Mon Sep 17 00:00:00 2001 From: vbanas Date: Tue, 3 Nov 2026 19:09:24 +0200 Subject: [PATCH 1/2] merge_audit: read the deleted drafts of an embedded bundle recover_drafts read each draft with `git show :.md` from the bundle root. In `:` git reads from the repository root, so in an --embed bundle (a subdirectory of the corpus repository) every read failed and recover_drafts returned ('git', {}). merge-audit used the mapping and called every group unverifiable; release-check checked only the state, so under acceptance.dissent: required (the --embed default) its recoverability check passed without reading a single draft. - recover_drafts reads `:./.md`, relative to the bundle root, the form update.py already uses for corpus reads. - release-check keeps the mapping and reports E_REL_DISSENT_UNVERIFIABLE when any draft of a merge group is missing from it, as merge-audit already does. No new codes. - schism.md: the blind-first `git show` uses the same `./` form. - smoke.sh: an installed-artifact negative on a bundle made with `okfy init --embed`. merge-audit must read both drafts, and release-check must refuse a merge_map draft that no commit holds. The first assertion fails on the previous wheel, the second with only the path fix applied. The other sites the issue names do not reach a bundle-relative path in an embedded bundle today. validate.ledger_prefix_check runs git only when the bundle root holds .git, so an embedded bundle gets W_LEDGER_UNVERIFIABLE (documented: no repository of its own). memory.events_at_head is called only after that check reports rewritten, which needs .git at the bundle root, where the bare `HEAD:` form is correct. Fixes vsov/okfy#11. --- core/src/okfy/merge_audit.py | 7 +++- core/src/okfy/release.py | 17 +++++++-- plugin/commands/schism.md | 6 +++- scripts/smoke.sh | 67 ++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 4 deletions(-) diff --git a/core/src/okfy/merge_audit.py b/core/src/okfy/merge_audit.py index 97a3264..a6bfa4f 100644 --- a/core/src/okfy/merge_audit.py +++ b/core/src/okfy/merge_audit.py @@ -138,7 +138,12 @@ def _parse(did: str, text: str, out: dict) -> None: return (state, {}) out = {} for did in ids: - show = _git(bundle, "show", f"{sha}:{did}.md") + # `./`: in `:` git reads from the repository root, + # not the current directory. An --embed bundle sits below that root, + # so the bare form failed on every draft and this returned ('git', {}) + # (vsov/okfy#11); `./` makes it relative to the bundle root, which is + # the repository root for a standalone bundle. + show = _git(bundle, "show", f"{sha}:./{did}.md") if show.returncode != 0: continue _parse(did, show.stdout, out) diff --git a/core/src/okfy/release.py b/core/src/okfy/release.py index 47108fe..2e905a8 100644 --- a/core/src/okfy/release.py +++ b/core/src/okfy/release.py @@ -741,8 +741,8 @@ def _check_dissent(bundle: Bundle, problems: list, notes: list): # required contract that is a failure of the evidence, not a detail — the # same standard merge-audit applies to itself when it refuses to report # "clean" for groups it could not read. - rstate, _ = recover_drafts(bundle, sorted({d for g in groups - for d in g["drafts"]})) + wanted = sorted({d for g in groups for d in g["drafts"]}) + rstate, recovered = recover_drafts(bundle, wanted) if rstate not in ("live", "git"): problems.append( f"E_REL_DISSENT_UNVERIFIABLE: acceptance.dissent is required but the " @@ -751,6 +751,19 @@ def _check_dissent(bundle: Bundle, problems: list, notes: list): f"redone; restore the history that holds drafts/ or drop the " f"required contract") return + # The state says where recovery looked, not that it found anything: a draft + # that could not be read or parsed is only absent from the mapping. Checking + # the state alone passed an --embed bundle whose every read failed + # (vsov/okfy#11). merge-audit already counts these as unverifiable. + missing = [d for d in wanted if d not in recovered] + if missing: + problems.append( + f"E_REL_DISSENT_UNVERIFIABLE: acceptance.dissent is required but " + f"{len(missing)} of {len(wanted)} pre-consolidation draft(s) cannot be " + f"read ({rstate}; e.g. {', '.join(missing[:3])}) — their adjudications " + f"in meta/dissent.jsonl are unfalsifiable and cannot be redone; restore " + f"the history that holds those drafts or drop the required contract") + return unadjudicated, open_, stale = [], [], [] for g in groups: diff --git a/plugin/commands/schism.md b/plugin/commands/schism.md index 40a4f00..aaffd49 100644 --- a/plugin/commands/schism.md +++ b/plugin/commands/schism.md @@ -52,9 +52,13 @@ For each group, **before you open the final concept and before you look at the findings**, read the drafts: ```bash -git -C show :.md +git -C show :./.md ``` +Keep the `./`: without it git reads the path from the repository root, so in a +bundle created with `--embed` (a subdirectory of the corpus repository) every +draft reads as missing. + Then answer, in writing: > **What is the smallest source-backed boundary that would make these two (or N) diff --git a/scripts/smoke.sh b/scripts/smoke.sh index 9825895..ccc0320 100755 --- a/scripts/smoke.sh +++ b/scripts/smoke.sh @@ -650,4 +650,71 @@ else echo "SMOKE NEG stat: PASS" fi +step "NEG embed (vsov/okfy#11): deleted drafts of an --embed bundle are read from git" +echo "SMOKE NEG embed: merge-audit must read both drafts; release-check must refuse a draft no commit holds" +# `git show :` reads from the repository root, and an --embed +# bundle sits below it, so every draft read failed. recover_drafts still said +# 'git', and release-check, which looked only at that state, passed its +# recoverability check without reading a single draft. +EC="$WORK/neg-embed/corpus" +EB="$EC/kb" +mkdir -p "$EC" || fail "NEG embed setup: mkdir" +printf '# App\n\nOne tracked note.\n' > "$EC/app.md" +{ git -C "$EC" init -q && git -C "$EC" add . && git -C "$EC" commit -qm "initial"; } \ + >/dev/null 2>&1 || fail "NEG embed setup: could not commit the corpus" +okfy init "$EB" --corpus "$EC" --embed --language en >/dev/null 2>"$WORK/emb-init.err" \ + || { cat "$WORK/emb-init.err"; fail "NEG embed setup: okfy init --embed"; } +grep -q 'dissent: required' "$EB/meta/purpose.md" \ + || fail "NEG embed setup: --embed no longer requires dissent, so release-check would skip the check" +mkdir -p "$EB/drafts/segment-01" "$EB/glossary" +for d in gamma-a gamma-b; do + printf -- '---\ntype: GlossaryTerm\ntitle: Gamma\nsources: [app.md]\n---\n\nDraft %s.\n' "$d" \ + > "$EB/drafts/segment-01/$d.md" +done +{ git -C "$EC" add . && git -C "$EC" commit -qm "extract: two drafts"; } >/dev/null 2>&1 \ + || fail "NEG embed setup: could not commit the drafts" +printf -- '---\ntype: GlossaryTerm\ntitle: Gamma\nsources: [app.md]\n---\n\nGamma.\n' \ + > "$EB/glossary/gamma.md" +rm -rf "$EB/drafts" +{ git -C "$EC" add -A && git -C "$EC" commit -qm "consolidate: 1 concept from 2 drafts"; } \ + >/dev/null 2>&1 || fail "NEG embed setup: could not commit the consolidation" +emb_ledger() { # $1 = run id, $2 = merge map + okfy ledger add "$EB" --run "$1" --segment consolidation --inputs app.md \ + --prompt-version consolidate@1 --outputs glossary/gamma --validation ok \ + --merge-map "$2" >/dev/null 2>"$WORK/emb-ledger.err" \ + || { cat "$WORK/emb-ledger.err"; fail "NEG embed setup: okfy ledger add ($1)"; } +} +emb_ledger run-1 "drafts/segment-01/gamma-a=glossary/gamma,drafts/segment-01/gamma-b=glossary/gamma" +[ "$(git -C "$EB" rev-parse --show-prefix)" = "kb/" ] \ + || fail "NEG embed setup: the bundle is not a subdirectory of its repository" +[ ! -e "$EB/.git" ] || fail "NEG embed setup: the bundle has a repository of its own" +okfy merge-audit "$EB" --json > "$WORK/emb-audit.json" 2>"$WORK/emb-audit.err" \ + || { cat "$WORK/emb-audit.err"; fail "NEG embed setup: okfy merge-audit exited non-zero"; } +EMB_AUDIT_MSG="NEG embed: merge-audit did not read the deleted drafts of an --embed bundle from git" +python - "$WORK/emb-audit.json" <<'PY' || fail "$EMB_AUDIT_MSG" +import json, sys +d = json.load(open(sys.argv[1])) +assert d["recovery"] == "git" and d["groups_total"] == 1, d +assert d["unverifiable"] == [], d["unverifiable"] +PY +emb_dissent() { # $1 = output file; release-check is red either way, only its dissent lines count + set +e + okfy release-check "$EB" > "$1" 2>"$WORK/emb-release.err" + set -e + python -c 'import json, sys; json.load(open(sys.argv[1]))' "$1" 2>/dev/null \ + || { cat "$1" "$WORK/emb-release.err"; fail "NEG embed setup: release-check printed no JSON report"; } +} +emb_dissent "$WORK/emb-release.json" +# Readable drafts: the check moves on to adjudication, which nothing has done yet. +grep -q 'E_REL_DISSENT_UNADJUDICATED' "$WORK/emb-release.json" \ + && ! grep -q 'E_REL_DISSENT_UNVERIFIABLE' "$WORK/emb-release.json" \ + || { cat "$WORK/emb-release.json"; fail "NEG embed setup: release-check did not reach adjudication with readable drafts"; } +# A merge_map entry for a draft that no commit ever held: recovery still says +# 'git' (the deletion commit is found), but one draft is missing from what it read. +emb_ledger run-2 "drafts/segment-01/gamma-c=glossary/gamma" +emb_dissent "$WORK/emb-missing.json" +grep -q 'E_REL_DISSENT_UNVERIFIABLE' "$WORK/emb-missing.json" \ + || { cat "$WORK/emb-missing.json"; fail "NEG embed: release-check passed the dissent check with a draft it could not read"; } +echo "SMOKE NEG embed: PASS" + printf '\nSMOKE OK\n' From cc1f7aa6fcb37e79a783a8cdd37c1cf54f24bab4 Mon Sep 17 00:00:00 2001 From: vbanas Date: Wed, 4 Nov 2026 00:28:52 +0200 Subject: [PATCH 2/2] smoke: the dissent gate refuses a committed draft that does not parse vsov/okfy#13 reports the same two defects as #11, plus a third way to reach the gate gap: a draft committed with frontmatter that does not parse. recover_drafts leaves it out of the mapping, merge-audit calls its group unverifiable, and release-check passed it. The previous commit already fails it closed (the gate counts every draft missing from the mapping, whatever the reason), but only a draft that no commit held was tested. - The NEG embed step commits a third draft, gamma-bad, whose title does not parse, and proves it is in the commit before the deletion. - The unparsed draft and the never-committed one are each checked on their own copy of the corpus, because the ledger only grows: once one is in the merge map, the other could not turn the gate red by itself. Each refusal must name its draft. - Both assertions fail with only the path fix applied; the step fails earlier, at merge-audit, on the previous wheel. Fixes vsov/okfy#13. --- scripts/smoke.sh | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/scripts/smoke.sh b/scripts/smoke.sh index ccc0320..ed56301 100755 --- a/scripts/smoke.sh +++ b/scripts/smoke.sh @@ -650,12 +650,13 @@ else echo "SMOKE NEG stat: PASS" fi -step "NEG embed (vsov/okfy#11): deleted drafts of an --embed bundle are read from git" -echo "SMOKE NEG embed: merge-audit must read both drafts; release-check must refuse a draft no commit holds" +step "NEG embed (vsov/okfy#11, #13): deleted drafts of an --embed bundle are read from git" +echo "SMOKE NEG embed: merge-audit must read both drafts; release-check must refuse a draft that does not parse and one no commit holds" # `git show :` reads from the repository root, and an --embed # bundle sits below it, so every draft read failed. recover_drafts still said # 'git', and release-check, which looked only at that state, passed its -# recoverability check without reading a single draft. +# recoverability check without reading a single draft. A committed draft whose +# frontmatter does not parse was passed the same way, in any bundle. EC="$WORK/neg-embed/corpus" EB="$EC/kb" mkdir -p "$EC" || fail "NEG embed setup: mkdir" @@ -671,7 +672,10 @@ for d in gamma-a gamma-b; do printf -- '---\ntype: GlossaryTerm\ntitle: Gamma\nsources: [app.md]\n---\n\nDraft %s.\n' "$d" \ > "$EB/drafts/segment-01/$d.md" done -{ git -C "$EC" add . && git -C "$EC" commit -qm "extract: two drafts"; } >/dev/null 2>&1 \ +# committed with the others; no merge_map names it until the unparsed check below +printf -- '---\ntype: GlossaryTerm\ntitle: [unclosed\n---\n\nDraft gamma-bad.\n' \ + > "$EB/drafts/segment-01/gamma-bad.md" +{ git -C "$EC" add . && git -C "$EC" commit -qm "extract: three drafts"; } >/dev/null 2>&1 \ || fail "NEG embed setup: could not commit the drafts" printf -- '---\ntype: GlossaryTerm\ntitle: Gamma\nsources: [app.md]\n---\n\nGamma.\n' \ > "$EB/glossary/gamma.md" @@ -709,12 +713,32 @@ emb_dissent "$WORK/emb-release.json" grep -q 'E_REL_DISSENT_UNADJUDICATED' "$WORK/emb-release.json" \ && ! grep -q 'E_REL_DISSENT_UNVERIFIABLE' "$WORK/emb-release.json" \ || { cat "$WORK/emb-release.json"; fail "NEG embed setup: release-check did not reach adjudication with readable drafts"; } -# A merge_map entry for a draft that no commit ever held: recovery still says -# 'git' (the deletion commit is found), but one draft is missing from what it read. +# Two drafts a merge group can name that recovery cannot hand back, while its +# state still says 'git' (the deletion commit is found): one committed with +# frontmatter that does not parse (#13), and one no commit ever held. Each gets +# its own copy of the corpus, because the ledger only grows: once one of them is +# in the merge map, the other could not turn the gate red on its own. +emb_unverifiable() { # $1 = report, $2 = the draft the refusal must name + python - "$1" "$2" <<'PY' +import json, sys +problems = json.load(open(sys.argv[1]))["problems"] +assert any(p.startswith("E_REL_DISSENT_UNVERIFIABLE") and sys.argv[2] in p + for p in problems), problems +PY +} +EMB_DEL="$(git -C "$EB" log -n 1 --format=%H --diff-filter=D -- 'drafts/*')" +git -C "$EB" show "$EMB_DEL^:./drafts/segment-01/gamma-bad.md" >/dev/null 2>&1 \ + || fail "NEG embed setup: the unparsable draft is not in the commit before the deletion" +cp -R "$EC" "$WORK/neg-embed/corpus-missing" || fail "NEG embed setup: could not copy the corpus" +emb_ledger run-2 "drafts/segment-01/gamma-bad=glossary/gamma" +emb_dissent "$WORK/emb-unparsed.json" +emb_unverifiable "$WORK/emb-unparsed.json" drafts/segment-01/gamma-bad \ + || fail "NEG embed: release-check passed the dissent check with a committed draft whose frontmatter does not parse" +EB="$WORK/neg-embed/corpus-missing/kb" emb_ledger run-2 "drafts/segment-01/gamma-c=glossary/gamma" emb_dissent "$WORK/emb-missing.json" -grep -q 'E_REL_DISSENT_UNVERIFIABLE' "$WORK/emb-missing.json" \ - || { cat "$WORK/emb-missing.json"; fail "NEG embed: release-check passed the dissent check with a draft it could not read"; } +emb_unverifiable "$WORK/emb-missing.json" drafts/segment-01/gamma-c \ + || fail "NEG embed: release-check passed the dissent check with a draft no commit holds" echo "SMOKE NEG embed: PASS" printf '\nSMOKE OK\n'