Skip to content

Per-kind ids: schema 3 and docket migrate - #28

Merged
NovusEdge merged 31 commits into
mainfrom
per-kind-ids
Oct 7, 2026
Merged

NovusEdge merged 31 commits into
mainfrom
per-kind-ids

Conversation

@NovusEdge

@NovusEdge NovusEdge commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Schema 3 gives claims, decisions and questions independent id counters (c1, d1, q1) and adds a one-run migration from schema 1 or 2.

What changes

  • Ids and validation. Ids count per kind, allocated as that kind's highest number plus one. Every line carries schema: 3. Readers refuse an older ledger with an instruction to run docket migrate, and the session hook passes that instruction to the agent in place of a briefing (stdout, exit 0). docket check compares order per kind.

  • docket migrate. Schema 1 and 2 both reach 3 in one run, in one file-order pass:

    • each record keeps its old id in a hidden migrated_from field;
    • relations, correction and review targets, and id mentions in record prose are rewritten, each mention once so shifted ids never chain, with schema-1 records resolving through legacy.source_id;
    • .docket/features.jsonl and its archive are remapped and move to features schema 2.

    Writes are crash-safe: features and named files are replaced first, the original ledger is hard-linked to ledger.jsonl.schemaN, and the ledger is swapped in one os.replace. A rerun finishes an interrupted run, and the migration refuses if the ledger changed underneath it. --dry-run lists every prose rewrite and every unresolved id token. --rewrite FILE... rewrites citations in tracked, clean files.

  • Merges. Each branch migrates itself. The merge driver and docket rebase refuse mixed schemas, and the driver leaves conflict markers naming the side that is behind. A pre-migration BASE is upgraded in memory for matching only. Matching ignores migrated_from and id tokens in prose, so two branches migrated separately merge without duplicates.

  • Finding old ids. docket list --where was:ID finds the record that carried an old id, retired records included. docket show OLD points at that search.

  • Docs. A new docs/schemas.md page covers the schema versions and the upgrade procedure. docs/ledger.md, the skill and the changelog are updated.

Testing

  • python3 -m unittest discover -s tests -p 'test_*.py': 1252 tests, OK, 9 skipped. Three of the skips are temporary guards for tests that read this repository's own ledger, which stays at schema 2 until it is migrated after this merges.
  • ruff 0.16.7 format and check are clean.
  • The renumber is linear: 0.41 s at 6,000 records and 0.94 s at 12,000.
  • A whole-branch review traced this repository's real ledger through dry run, migrate, check, show, was: and context. It also merged two branches migrated separately through the driver, with no duplicates and a clean check.

After merge

  1. Migrate this repository's ledger on main and commit ledger.jsonl and features.jsonl, not the backup.
  2. Remove the three temporary test skips.
  3. Run just release 0.26.0, then install 0.26.0.

Between the migration and the install, the installed 0.25.1 hook cannot read the ledger.

Summary by CodeRabbit

  • New Features

    • Added migration to schema 3, with IDs numbered independently by record type and former IDs retained for lookup.
    • Added was:ID searches for records by their pre-migration IDs.
    • Migration can preview changes and rewrite citations in eligible tracked files.
  • Bug Fixes

    • Merge and rebase now handle independently migrated branches while refusing incompatible schema versions.
    • Validation and command output provide migration guidance for outdated ledgers.
  • Documentation

    • Updated migration, schema compatibility, backup, and branch coordination guidance.

Schema 3 renumbers per kind and keeps each record's schema-2 id in a field; the migration rewrites feature citations and stays cheap for agents; old ids stay history only. How an unmigrated project's ledger is read stays open.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
A schema-2 ledger is refused until migrated, and the session hook passes the migrate instruction to the agent instead of failing on stderr.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Migrate chains schema steps, the merge driver and rebase migrate a schema-2 side in memory, and --rewrite fixes citations in named files.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
migrated_from is an audit field hidden like legacy; the renumber rewrites structured ids and id mentions in record prose.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Chained steps, a single file-order renumber pass, features moved under a schema bump, and record keys that ignore id tokens in headlines.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
The merge driver and rebase upgrade a schema-2 side in memory, and merges rewrite prose mentions with the migration's translation.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Per-kind validation and allocation, a per-kind check, a migrate instruction from the session hook, and the rescope script removed.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
This repository's docs cite illustrative ids, so its migration runs without --rewrite, and legacy audit blocks stay untouched because the validator no longer checks them.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Each branch migrates itself and merges require matching schemas, merge matching ignores migrated_from and prose id tokens, migrate survives a crash at any point, and prose resolution uses legacy source ids.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
A schema refusal keeps the merge driver's conflict markers, and this repository's ledger migrates right before the 0.26.0 release.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
…map on schema 2

Signed-off-by: NovusEdge <novusedge0@gmail.com>
…, takes --rewrite

Signed-off-by: NovusEdge <novusedge0@gmail.com>
…dger

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
…r against late writes and odd input

list --where was: includes retired records. The merge driver refuses a non-UTF-8 or non-object BASE with markers. migrate refuses a non-object features line and a ledger that changed since it was read, names a remedy for another branch's backup, and tells users not to commit the backup. renumber_per_kind no longer rebuilds a set per record. docket rebase prints its schema error once.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
…at to abort

Signed-off-by: NovusEdge <novusedge0@gmail.com>
Signed-off-by: NovusEdge <novusedge0@gmail.com>
was: includes retired records, the migration backup stays uncommitted, migrate refuses a ledger changed mid-run, schema-1 rewrites use schema-1 ids, and false positives are fixed after migrating.
Signed-off-by: NovusEdge <novusedge0@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9b38fe25-5ea4-4ab9-afb6-b0ac0ca8568b
📥 Commits

Reviewing files that changed from the base of the PR and between 07ad68f and 4bac39b.

📒 Files selected for processing (52)
  • .docket/ledger.jsonl
  • CHANGELOG.md
  • README.md
  • docket/cli/__init__.py
  • docket/cli/admin.py
  • docket/cli/context_cmd.py
  • docket/cli/graph.py
  • docket/cli/query.py
  • docket/construct/accept.py
  • docket/context.py
  • docket/corrections.py
  • docket/feature_archive.py
  • docket/features.py
  • docket/ledger.py
  • docket/merge_driver.py
  • docket/migrate.py
  • docket/rebase.py
  • docket/reviews.py
  • docket/where.py
  • docs/SUMMARY.md
  • docs/commands.md
  • docs/decision-chains.md
  • docs/definitions.md
  • docs/ledger.md
  • docs/maintenance.md
  • docs/north-star.md
  • docs/schemas.md
  • hooks/guard_ledger.py
  • skills/docket/SKILL.md
  • tests/golden/context_snapshots.json
  • tests/golden/regenerate.py
  • tests/test_check_order.py
  • tests/test_correct_cli.py
  • tests/test_corrections.py
  • tests/test_docket.py
  • tests/test_feature_cli.py
  • tests/test_features.py
  • tests/test_graph_cli.py
  • tests/test_graph_export.py
  • tests/test_guard_ledger.py
  • tests/test_ledger.py
  • tests/test_merge_driver.py
  • tests/test_migrate_cli.py
  • tests/test_migration.py
  • tests/test_rebase.py
  • tests/test_review_cli.py
  • tests/test_reviews.py
  • tests/test_supersede_reason.py
  • tests/test_support.py
  • tests/test_support_smoke.py
  • tests/test_web.py
  • tests/test_where.py
 ____________________________________________________________________________________________________________________________________________________________________________________________
< The object-oriented model makes it easy to build up programs by accretion. What this often means, in practice, is that it provides a structured way to write spaghetti code. - Paul Graham >
 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ed_from

Signed-off-by: NovusEdge <novusedge0@gmail.com>
…ration

Corrects c138, q139, d187 and d197 and restates d185 so the dry run no longer rewrites ids quoted from the stoat and nimblefox ledgers or illustrative ids as this ledger's citations.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
…an follow it

pyrefly rejected calling build_records and renumber_step through one dict, and could not prove a correction's target was bound where renumber_per_kind used it.

Signed-off-by: NovusEdge <novusedge0@gmail.com>
@NovusEdge
NovusEdge merged commit 59e10e3 into main Oct 7, 2026
5 of 6 checks passed
@NovusEdge
NovusEdge deleted the per-kind-ids branch October 7, 2026 12:01
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.

1 participant