mdkg 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/CLI_COMMAND_MATRIX.md +56 -7
  3. package/README.md +33 -3
  4. package/dist/cli.js +132 -11
  5. package/dist/command-contract.json +431 -16
  6. package/dist/commands/bundle.js +2 -0
  7. package/dist/commands/checkpoint.js +139 -1
  8. package/dist/commands/db.js +8 -0
  9. package/dist/commands/format.js +116 -0
  10. package/dist/commands/goal.js +60 -0
  11. package/dist/commands/graph.js +148 -0
  12. package/dist/commands/handoff.js +295 -0
  13. package/dist/commands/mcp.js +9 -0
  14. package/dist/commands/pack.js +3 -1
  15. package/dist/commands/query_output.js +2 -0
  16. package/dist/commands/show.js +8 -0
  17. package/dist/commands/status.js +1 -0
  18. package/dist/commands/task.js +2 -0
  19. package/dist/commands/upgrade.js +61 -0
  20. package/dist/commands/validate.js +162 -3
  21. package/dist/commands/work.js +164 -0
  22. package/dist/core/project_db_queue_contract.js +101 -0
  23. package/dist/graph/edges.js +15 -0
  24. package/dist/graph/frontmatter.js +4 -1
  25. package/dist/graph/indexer.js +8 -0
  26. package/dist/graph/node.js +12 -1
  27. package/dist/graph/sqlite_index.js +2 -0
  28. package/dist/graph/subgraphs.js +2 -0
  29. package/dist/graph/validate_graph.js +5 -0
  30. package/dist/graph/visibility.js +6 -0
  31. package/dist/init/AGENT_START.md +4 -1
  32. package/dist/init/CLI_COMMAND_MATRIX.md +24 -3
  33. package/dist/init/README.md +17 -2
  34. package/dist/init/init-manifest.json +12 -12
  35. package/dist/init/templates/default/bug.md +2 -0
  36. package/dist/init/templates/default/chk.md +3 -0
  37. package/dist/init/templates/default/epic.md +2 -0
  38. package/dist/init/templates/default/feat.md +2 -0
  39. package/dist/init/templates/default/goal.md +3 -0
  40. package/dist/init/templates/default/spike.md +2 -0
  41. package/dist/init/templates/default/task.md +2 -0
  42. package/dist/init/templates/default/test.md +2 -0
  43. package/dist/pack/export_json.js +20 -8
  44. package/dist/pack/export_md.js +15 -4
  45. package/dist/pack/export_xml.js +9 -4
  46. package/dist/pack/metrics.js +12 -4
  47. package/dist/pack/pack.js +9 -1
  48. package/package.json +6 -2
package/CHANGELOG.md CHANGED
@@ -8,6 +8,75 @@ mdkg is pre-v1 public alpha software. Command, graph, cache, bundle, and DAL con
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## 0.3.7 - 2026-06-20
12
+
13
+ ### Added
14
+
15
+ - Added `context_refs` and `evidence_refs` as generic semantic reference
16
+ fields for mdkg work nodes, with indexing, validation, search/show output,
17
+ pack traversal, SQLite cache support, subgraph projection, and visibility
18
+ enforcement.
19
+ - Added `mdkg graph refs <id-or-qid> --json` to summarize inbound and outbound
20
+ scope, context, evidence, blocker, related, and structural references for
21
+ local graph nodes and read-only subgraph qids.
22
+ - Added richer checkpoint kinds for implementation milestones, test proof, goal
23
+ closeout, read-only audits, and handoffs. Generated checkpoint bodies now
24
+ include sections for evidence, validation, known warnings, changed surfaces,
25
+ boundaries, and follow-up references.
26
+ - Added `mdkg work validate [<id-or-qid>] --type ... --json` for focused
27
+ SPEC, WORK, WORK_ORDER, RECEIPT, FEEDBACK, DISPUTE, and PROPOSAL semantic
28
+ mirror diagnostics.
29
+ - Added validation warning categories plus `mdkg validate --changed-only` for
30
+ changed-file warning review while preserving full-graph error checking.
31
+ - Added `mdkg format --headings --dry-run|--apply --json` to preview or apply
32
+ recommended heading migrations for historical mdkg Markdown nodes.
33
+ - Added `mdkg db queue contract --json` as the public project DB queue adapter
34
+ contract covering payload hashing, dedupe, claim ordering, lease-owner
35
+ settlement, retry/dead-letter behavior, expired lease release, pause/resume,
36
+ snapshot policies, and stats semantics.
37
+ - Added `mdkg handoff create <id-or-qid>` for sanitized, copy-ready agent
38
+ handoff prompts built from pack context, goal state, latest checkpoints,
39
+ required checks, semantic refs, and raw-content warnings.
40
+ - Added packed temp-repo smokes for semantic refs, checkpoint templates,
41
+ handoffs, and the full integration UX flow.
42
+
43
+ ### Changed
44
+
45
+ - Completed goals now move the final `active_node` to `last_active_node` when
46
+ marked done or archived, so historical routing state is preserved without
47
+ leaving completed goals actionable.
48
+ - `mdkg goal next <done-goal> --json` now returns `node: null` without
49
+ misleading stale `active_node` warnings for achieved goals.
50
+ - Goal and pack workflows now distinguish executable `scope_refs` from
51
+ contextual and evidence references, reducing validation noise when goals cite
52
+ checkpoints, design evidence, prerequisite goals, or external proof refs.
53
+ - README, init assets, command matrix, generated command contract metadata,
54
+ help targets, and publish-readiness assertions now document the new semantic
55
+ refs, handoff, workflow validation, checkpoint, queue contract, and warning
56
+ migration surfaces.
57
+ - Upgrade behavior now migrates legacy achieved goals that still have
58
+ `active_node` into the new `last_active_node` shape.
59
+
60
+ ### Fixed
61
+
62
+ - Reduced false-positive operational friction for completed goals and
63
+ intentional contextual refs without weakening missing-reference or invalid
64
+ graph-edge validation.
65
+ - Strengthened cross-subgraph blocker diagnostics so read-only external graph
66
+ nodes are reported as planning context instead of locally actionable work.
67
+
68
+ ### Security
69
+
70
+ - Handoff generation omits raw node body content for nodes with obvious raw
71
+ prompt, payload, or secret markers and reports typed raw-marker warnings
72
+ instead.
73
+ - Workflow validation and checkpoint validation warn on obvious raw secret,
74
+ prompt, token, or payload markers without turning mdkg into a broad secret
75
+ scanner or blocking operator review.
76
+ - The public queue contract explicitly states that queue payloads should be
77
+ compact refs or redacted envelopes, not raw secrets, prompts, provider
78
+ payloads, or bulky runtime artifacts.
79
+
11
80
  ## 0.3.6 - 2026-06-17
12
81
 
13
82
  ### Added
@@ -23,6 +23,7 @@ Primary commands:
23
23
  - `list`
24
24
  - `search`
25
25
  - `pack`
26
+ - `handoff`
26
27
  - `skill`
27
28
  - `capability`
28
29
  - `spec`
@@ -349,6 +350,10 @@ Allowed formats:
349
350
  - `toon`
350
351
  - `xml`
351
352
 
353
+ Allowed pack edges:
354
+ - `parent`, `epic`, `relates`, `blocked_by`, `blocks`, `prev`, `next`
355
+ - `context_refs` and `evidence_refs` for non-executable semantic references
356
+
352
357
  Profiles:
353
358
  - `standard`
354
359
  - `concise`
@@ -363,6 +368,26 @@ Visibility:
363
368
  - `--visibility internal` includes public/internal records and fails when included records reference private records
364
369
  - `--visibility private` records explicit private intent and may include all records
365
370
  - visibility filtering does not inspect or redact arbitrary Markdown body text
371
+ - `context_refs` and `evidence_refs` are indexed semantic refs, not executable goal queues; include them with `--edges context_refs,evidence_refs` when a handoff needs background or proof nodes
372
+
373
+ ### `mdkg handoff`
374
+
375
+ When to use:
376
+ - create a sanitized, copy-ready agent handoff prompt from graph context
377
+ - summarize goal/work state, included pack nodes, latest checkpoint, boundaries, required checks, and next actions
378
+
379
+ Usage:
380
+ - `mdkg handoff create <id-or-qid> [--ws <alias>] [--depth <n>] [--out <path>] [--json]`
381
+
382
+ Notes:
383
+ - uses pack traversal with `context_refs` and `evidence_refs`
384
+ - does not copy raw node bodies into the handoff
385
+ - reports raw secret, prompt, token, or payload marker warnings without including raw marker content
386
+ - `--out` must stay inside the repo root
387
+ - the command does not execute work, mutate graph nodes, or generate detailed node content
388
+
389
+ Receipts:
390
+ - `handoff-created`: `{ action, ok, mdkg_version, target, output_path, content_sha256, raw_marker_warning_count, raw_marker_warnings, latest_checkpoint_qid, included_qids, pack, content }`
366
391
 
367
392
  ### `mdkg skill`
368
393
 
@@ -624,12 +649,14 @@ JSON receipts:
624
649
  When to use:
625
650
  - clone or fork a complete mdkg graph into a separate target directory while preserving IDs
626
651
  - import a template graph into the current repo with deterministic ID/link rewrites
652
+ - inspect inbound and outbound graph references across local and read-only subgraph qids
627
653
  - prepare selected-goal demo handoffs from reusable graph templates
628
654
 
629
655
  Usage:
630
656
  - `mdkg graph clone <source-bundle-or-mdkg-dir> --target <path> [--json]`
631
657
  - `mdkg graph fork <source-bundle-or-mdkg-dir> --target <path> [--start-goal <goal-id>] [--json]`
632
658
  - `mdkg graph import-template <source-bundle-or-mdkg-dir> [--start-goal <goal-id>] [--select-goal] [--id-prefix <prefix>] [--dry-run] [--apply] [--json]`
659
+ - `mdkg graph refs <id-or-qid> [--ws <alias>] [--json]`
633
660
 
634
661
  Flags:
635
662
  - `--target <path>`
@@ -638,6 +665,7 @@ Flags:
638
665
  - `--id-prefix <prefix>`
639
666
  - `--dry-run`
640
667
  - `--apply`
668
+ - `--ws <alias>`
641
669
  - `--json`
642
670
 
643
671
  Notes:
@@ -651,12 +679,14 @@ Notes:
651
679
  - colliding semantic template IDs require `--id-prefix`
652
680
  - `--select-goal` requires `--start-goal`; on apply it activates the imported start goal, pauses competing active root goals, validates, then writes selected-goal state
653
681
  - importing active template goals without `--select-goal` fails before writing when it would create multiple active root goals
682
+ - `graph refs` is read-only; it reports `scope_refs`, `context_refs`, `evidence_refs`, blockers, related refs, and structural inbound/outbound links
654
683
  - subgraphs remain read-only bundle projections for orchestration context; use `graph clone|fork|import-template` when authored graph state should be created
655
684
 
656
685
  JSON receipts:
657
686
  - `clone`: `{ action: "graph.clone", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, index, validation, warnings }`
658
687
  - `fork`: `{ action: "graph.fork", ok, mode, source, target, source_hash, preserved_ids, files_written, skipped_paths, start_goal?, selected_goal?, index, validation, warnings }`
659
688
  - `import-template`: `{ action: "graph.import_template", ok, mode, source, source_hash, preserved_ids: false, rewritten_ids, rewritten_refs, planned_paths, files_written, skipped_paths, start_goal?, selected_goal?, activated_goal?, paused_goals, index?, validation?, warnings }`
689
+ - `refs`: `{ action: "graph.refs", ok, target, outgoing, incoming, warnings }`
660
690
 
661
691
  ### `mdkg subgraph`
662
692
 
@@ -745,6 +775,8 @@ Usage:
745
775
  - `mdkg work receipt verify <id-or-qid> [--json]`
746
776
  - `mdkg work receipt update <id-or-qid> [--receipt-status <status>] [--add-artifacts <...>] [--add-proof-refs <...>] [--add-attestation-refs <...>] [--add-evidence-hashes <sha256:...>] [--json]`
747
777
  - `mdkg work artifact add <order-or-receipt-id-or-qid> <file> [--id <archive.id>] [--kind source|artifact] [--json]`
778
+ - `mdkg work validate [<id-or-qid>] [--type <workflow-type>] [--json]`
779
+ - `mdkg work validate [<id-or-qid>] [--type spec|work|work_order|receipt|feedback|dispute|proposal] [--json]`
748
780
 
749
781
  Notes:
750
782
  - work commands mutate semantic mirror files only
@@ -758,6 +790,7 @@ Notes:
758
790
  - `work order status` is read-only and reports deterministic order state plus linked receipts
759
791
  - `work receipt new` accepts URI-style cost/proof/attestation refs, explicit redaction policy, and SHA-256 evidence/input/output hash refs
760
792
  - `work receipt verify` is read-only and reports linkage, evidence, archive ref, hash, outcome, and redaction-policy checks; invalid receipts print JSON before exiting nonzero
793
+ - `work validate` is read-only and reports typed diagnostics for SPEC.md, WORK.md, WORK_ORDER.md, RECEIPT.md, FEEDBACK.md, DISPUTE.md, and PROPOSAL.md mirrors; obvious raw secret, prompt, token, or payload markers are warnings, not hard failures
761
794
  - `work artifact add` calls `mdkg archive add`, then attaches the resulting `archive://...` ref to the target order or receipt
762
795
  - `work order update`, `work receipt update`, and `work artifact add` accept local ids or local qids; subgraph qids are read-only and must be changed in their source workspace
763
796
 
@@ -767,6 +800,7 @@ JSON receipts:
767
800
  - `order status`: `{ kind: "work_order_status", order, receipt_count, receipts }`
768
801
  - `receipt verify`: `{ kind: "work_receipt_verify", ok, receipt, work_order?, checks, errors, warnings }`
769
802
  - `artifact add`: `{ action: "artifact_registered", target, archive }`
803
+ - `validate` work-validate-receipt: `{ action: "work.validate", ok, type, target?, checked_count, nodes, warning_count, error_count, warnings, errors, diagnostics }`
770
804
 
771
805
  ### `mdkg goal`
772
806
 
@@ -799,7 +833,7 @@ Usage:
799
833
  - `mdkg goal archive <goal-id-or-qid> [--ws <alias>] [--json]`
800
834
 
801
835
  Behavior:
802
- - `goal show` reports goal condition, goal state, scope refs, active node, required skills, required checks, and source path.
836
+ - `goal show` reports goal condition, goal state, scope refs, active node, last active node, required skills, required checks, and source path.
803
837
  - `goal select` writes local ignored selected-goal state so `goal next` can omit the goal id.
804
838
  - `goal activate` makes one local root goal active, pauses competing local active goals in the same workspace, and writes selected-goal state.
805
839
  - `goal current` shows the selected goal or unique active goal fallback.
@@ -807,7 +841,7 @@ Behavior:
807
841
  - `goal next` is read-only and selects feature, task, bug, test, or spike work inside explicit `scope_refs`; epics are recursive containers, not executable returns.
808
842
  - `goal claim` mutates only `active_node` after the work item is confirmed inside the goal scope.
809
843
  - `goal evaluate` is report-only and never runs commands from `required_checks`.
810
- - `goal pause`, `goal resume`, and `goal done` update `goal_state`, compatible work status, and `updated`.
844
+ - `goal pause`, `goal resume`, and `goal done` update `goal_state`, compatible work status, and `updated`; done goals move any current `active_node` to `last_active_node` and no longer emit stale active-node routing warnings.
811
845
  - `goal archive` marks a superseded historical goal as `status: archived` and `goal_state: archived`; archived goals remain show/search/list readable but are excluded from active routing.
812
846
  - subgraph goal qids are read-only; update the source workspace instead.
813
847
 
@@ -832,7 +866,7 @@ When to use:
832
866
  Usage:
833
867
  - `mdkg task start <id-or-qid> [--ws <alias>] [--run-id <id>] [--note "<text>"] [--json]`
834
868
  - `mdkg task update <id-or-qid> [options] [--json]`
835
- - `mdkg task done <id-or-qid> [--checkpoint "<title>"] [options] [--json]`
869
+ - `mdkg task done <id-or-qid> [--checkpoint "<title>"] [--checkpoint-kind implementation|test-proof|goal-closeout|audit|handoff] [options] [--json]`
836
870
 
837
871
  #### `mdkg task start`
838
872
 
@@ -868,12 +902,13 @@ JSON receipt:
868
902
 
869
903
  Usage:
870
904
  - `mdkg task done <id-or-qid> [--ws <alias>] [--add-artifacts <a,...>] [--add-links <l,...>]`
871
- - ` [--add-refs <id,...>] [--checkpoint "<title>"] [--run-id <id>] [--note "<text>"] [--json]`
905
+ - ` [--add-refs <id,...>] [--checkpoint "<title>"] [--checkpoint-kind implementation|test-proof|goal-closeout|audit|handoff] [--run-id <id>] [--note "<text>"] [--json]`
872
906
 
873
907
  Behavior:
874
908
  - supports task-like `feat`, `task`, `bug`, `test`, and `spike` nodes
875
909
  - sets `status: done`
876
910
  - `--checkpoint` creates a related checkpoint
911
+ - `--checkpoint-kind` selects the evidence template for the related checkpoint
877
912
  - if `events.jsonl` is missing for the workspace, prints a short `stderr` reminder about `mdkg event enable`
878
913
 
879
914
  JSON receipt:
@@ -902,7 +937,9 @@ When to use:
902
937
  - run the repo trust gate before calling work done
903
938
 
904
939
  Usage:
905
- - `mdkg validate [--out <path>] [--quiet] [--json]`
940
+ - `mdkg validate [--out <path>] [--quiet] [--changed-only] [--json]`
941
+ - `--changed-only` filters warning presentation to changed `.mdkg` files while full graph errors still run
942
+ - JSON receipts include `warning_diagnostics` with warning ids, categories, severity, paths, refs, and remediation text
906
943
 
907
944
  Flags:
908
945
  - `--out <path>`
@@ -959,11 +996,12 @@ JSON receipt:
959
996
  ### `mdkg checkpoint`
960
997
 
961
998
  Usage:
962
- - `mdkg checkpoint new <title> [--ws <alias>] [--json]`
999
+ - `mdkg checkpoint new <title> [--kind implementation|test-proof|goal-closeout|audit|handoff] [--ws <alias>] [--json]`
963
1000
  - ` [--relates <id,id,...>] [--scope <id,id,...>] [--run-id <id>] [--note "<text>"]`
1001
+ - checkpoint kinds render bodies with command evidence, pass/fail status, known warnings, changed surfaces, boundaries, and follow-up refs
964
1002
 
965
1003
  JSON receipt:
966
- - `{ action: "created", checkpoint: { workspace, id, qid, path } }`
1004
+ - `{ action: "created", checkpoint: { workspace, id, qid, path, kind } }`
967
1005
 
968
1006
  ### `mdkg index`
969
1007
 
@@ -1003,6 +1041,7 @@ Usage:
1003
1041
  - `mdkg db queue list <queue> [--status ready|leased|acked|dead_letter|all] [--limit <n>] [--json]`
1004
1042
  - `mdkg db queue show <queue> <message-id> [--json]`
1005
1043
  - `mdkg db queue stats|list|show ... [--json]`
1044
+ - `mdkg db queue contract [--json]`
1006
1045
  - `mdkg db snapshot seal [--queue-policy drain|paused] [--json]`
1007
1046
  - `mdkg db snapshot verify [--json]`
1008
1047
  - `mdkg db snapshot status [--json]`
@@ -1023,6 +1062,10 @@ Boundaries:
1023
1062
  in the configured migration table
1024
1063
  - `mdkg db queue ...` exposes durable local delivery operations backed by
1025
1064
  node:sqlite; queue rows are delivery state, not canonical event history
1065
+ - `mdkg db queue contract --json` returns the public adapter contract covering
1066
+ canonical payload hashing, dedupe semantics, oldest-ready claim order,
1067
+ lease-owner checked settlement, retry/dead-letter behavior, release-expired,
1068
+ pause/resume, snapshot queue policy, stats, and boundary guidance
1026
1069
  - paused queues reject enqueue and claim, but ack/fail/dead-letter and
1027
1070
  release-expired remain available so leased work can settle
1028
1071
  - event tables are durable local history for project DB state transitions;
@@ -1064,6 +1107,12 @@ Usage:
1064
1107
 
1065
1108
  Usage:
1066
1109
  - `mdkg format`
1110
+ - `mdkg format --headings [--dry-run|--apply] [--json]`
1111
+
1112
+ Notes:
1113
+ - default `mdkg format` normalizes frontmatter in place
1114
+ - `mdkg format --headings` defaults to dry-run and returns planned missing-heading additions
1115
+ - `mdkg format --headings --apply` appends missing recommended body headings and returns a migration receipt
1067
1116
 
1068
1117
  ### `mdkg status`
1069
1118
 
package/README.md CHANGED
@@ -29,9 +29,21 @@ The primary loop is:
29
29
  4. build a deterministic pack
30
30
  5. validate before closing the loop
31
31
 
32
- If an agent is involved, the default handoff primitive is `mdkg pack <id>`.
32
+ If an agent is involved, use `mdkg pack <id>` for deterministic context and
33
+ `mdkg handoff create <id-or-qid> --json` for a sanitized, copy-ready agent
34
+ handoff prompt. Handoffs summarize goal/work state, included pack nodes, latest
35
+ checkpoint, boundaries, required checks, next actions, and raw-content marker
36
+ warnings without copying raw node bodies into the prompt.
33
37
  If a repo needs repeatable procedures, author them as first-class skills under `.mdkg/skills/`.
34
38
 
39
+ Work nodes can separate semantic background from executable scope with
40
+ `context_refs` and `evidence_refs`. Use `context_refs` for related plans,
41
+ external docs, subgraph qids, or URI references that explain why work exists.
42
+ Use `evidence_refs` for proof, audit, receipt, checkpoint, archive, or URI
43
+ references. These fields are indexed, validated, shown, and packable, but they
44
+ do not make referenced nodes actionable goal work; keep executable queues in
45
+ goal `scope_refs`.
46
+
35
47
  ## Install
36
48
 
37
49
  ```bash
@@ -136,6 +148,7 @@ Build deterministic context:
136
148
  mdkg pack task-1
137
149
  mdkg pack task-1 --profile concise --dry-run --stats
138
150
  mdkg pack task-1 --visibility public --dry-run
151
+ mdkg pack task-1 --edges context_refs,evidence_refs --format json
139
152
  ```
140
153
 
141
154
  Create a full `.mdkg` graph snapshot bundle for root or child orchestration:
@@ -208,6 +221,8 @@ Materialized trees are generated local state, ignored by graph indexing/search/v
208
221
 
209
222
  Subgraph nodes are projected under the subgraph alias, for example `child_repo:task-1`. They are available to `list`, `search`, `show`, `pack`, capability discovery, and `capability resolve`, but remain read-only; mutate the child repo and sync its root-owned bundle snapshot to change subgraph content. Root-authored relationship and reference fields can point at configured subgraph qids such as `child_repo:work.example`; local ownership fields such as `epic`, `parent`, `prev`, and `next` stay local-only. Stale subgraphs warn during planning reads and fail `mdkg subgraph verify`. Public or internal subgraphs must be backed by public bundle profiles; private subgraphs stay private planning context.
210
223
 
224
+ Use `mdkg graph refs <id-or-qid> --json` to inspect inbound and outbound scope, context, evidence, blocker, related, and structural links for local or read-only subgraph qids without mutating either graph.
225
+
211
226
  Launch a local read-only MCP server when an MCP-capable agent should inspect a
212
227
  specific mdkg graph without receiving mutation tools:
213
228
 
@@ -226,6 +241,7 @@ Validate before handoff or commit:
226
241
 
227
242
  ```bash
228
243
  mdkg validate
244
+ mdkg handoff create <id-or-qid> --out .mdkg/handoffs/example.md
229
245
  ```
230
246
 
231
247
  Discover cached capability surfaces:
@@ -280,8 +296,11 @@ Update structured task state and evidence while keeping body and narrative edits
280
296
  mdkg task start task-1 --run-id run_local_1
281
297
  mdkg task update task-1 --add-artifacts tests://unit.txt --add-tags release
282
298
  mdkg task done task-1 --checkpoint "release readiness milestone"
299
+ mdkg task done task-1 --checkpoint "goal complete" --checkpoint-kind goal-closeout
283
300
  ```
284
301
 
302
+ Checkpoint kinds are `implementation`, `test-proof`, `goal-closeout`, `audit`, and `handoff`; generated checkpoint bodies include command evidence, pass/fail status, known warnings, changed surfaces, boundaries, and follow-up refs.
303
+
285
304
  Ensure and append baseline event memory:
286
305
 
287
306
  ```bash
@@ -359,6 +378,11 @@ Advanced / maintenance commands still exist, but they are not the first-run stor
359
378
  - `mdkg fix plan --json`
360
379
  - `mdkg workspace`
361
380
 
381
+ For large historical graphs, use `mdkg validate --changed-only --json` to keep
382
+ warning review focused on changed `.mdkg` files while full graph errors still
383
+ run. Use `mdkg format --headings --dry-run --json` to review missing recommended
384
+ heading additions before applying them with `--apply`.
385
+
362
386
  ## Operator health
363
387
 
364
388
  Use `mdkg status --json` for a read-only operator summary before mutating a
@@ -478,6 +502,12 @@ rows are durable local project DB history; receipts, reducers, writer leases,
478
502
  and materializers remain internal helper surfaces in this release, with no
479
503
  public `mdkg db event`, `mdkg db reducer`, `mdkg db lease`, or
480
504
  `mdkg db materializer` CLI yet.
505
+ `mdkg db queue contract --json` is the read-only public adapter contract for
506
+ downstream integrations. It documents canonical payload hashing, dedupe keys,
507
+ oldest-ready claim order, lease-owner checked ack/fail/dead-letter, retry
508
+ delay, expired lease reclaim, max-attempt dead-letter behavior, pause/resume,
509
+ snapshot queue policy, and stats without exposing raw SQL or making queue rows
510
+ canonical runtime history.
481
511
  `mdkg work trigger --enqueue <queue>` can bridge a submitted work order mirror
482
512
  into an explicitly created active project DB queue; it writes local delivery
483
513
  state only and never executes work.
@@ -505,7 +535,7 @@ Goal nodes are durable recursive objective contracts. Use `mdkg new goal "<objec
505
535
 
506
536
  `goal` is work-like but distinct from `task`: it can have status, priority, graph links, skills, explicit `scope_refs`, and structured goal fields, but normal `mdkg next` does not select goals. Use `mdkg goal activate <goal-id>` to make one local root goal active, pause competing local active goals, and select it for future `goal next` calls. Use `mdkg goal select <goal-id>` only when you want to change the local ignored selected-goal pointer without changing lifecycle state. `mdkg goal next <goal-id>` remains available for explicit selection. Epics organize goal scope recursively but are not returned as executable work.
507
537
 
508
- Use `mdkg goal claim [goal-id] <work-id>` to durably set `active_node` after choosing the next scoped item. `goal next` is read-only. Use `mdkg goal pause|resume|done` to update goal state after review, and `mdkg goal archive` for superseded historical roadmap goals that should remain readable but non-actionable.
538
+ Use `mdkg goal claim [goal-id] <work-id>` to durably set `active_node` after choosing the next scoped item. `goal next` is read-only. Use `mdkg goal pause|resume|done` to update goal state after review; closing a goal moves the final `active_node` to `last_active_node` so completed goals keep history without staying actionable. Use `mdkg goal archive` for superseded historical roadmap goals that should remain readable but non-actionable.
509
539
 
510
540
  Required checks are stored as report-only guidance. Agents should run the checks themselves, record evidence in the goal or active work item, then use `mdkg goal evaluate` to summarize the current evidence state. During normal goal execution, skill improvements should be recorded as improvement candidates or proposal nodes; edit `SKILL.md` files only when the active node is explicit skill-maintenance work.
511
541
 
@@ -545,7 +575,7 @@ Use `mdkg new spec|work|work_order|receipt|feedback|dispute|proposal "<title>"`
545
575
 
546
576
  Relational templates contain editable placeholder refs. `spec` and `work` scaffold as validation-clean standalone docs; `work_order`, `receipt`, `feedback`, `dispute`, and `proposal` need real refs before strict `mdkg validate` passes.
547
577
 
548
- For executable or purchasable capability mirrors, prefer the lifecycle helpers under `mdkg work ...`. They create and update `WORK.md`, `WORK_ORDER.md`, and `RECEIPT.md` semantic mirror files only. `mdkg work trigger` creates a deterministic submitted `WORK_ORDER.md` from a WORK contract or a SPEC with exactly one resolvable work contract. `mdkg work order status` and `mdkg work receipt verify` are read-only review helpers for deterministic closeout. `mdkg work trigger --enqueue <queue>` optionally writes a local project DB queue delivery message after the queue has been explicitly created and is active; it still does not execute work. Production order state, receipt state, feedback, disputes, payments, ledgers, marketplace inventory, fulfillment records, and execution state remain canonical outside mdkg, such as in Postgres or another application database. Do not store raw secrets, credentials, live payment state, ledger mutations, canonical marketplace state, or bulky raw payloads in these mirrors.
578
+ For executable or purchasable capability mirrors, prefer the lifecycle helpers under `mdkg work ...`. They create and update `WORK.md`, `WORK_ORDER.md`, and `RECEIPT.md` semantic mirror files only. `mdkg work trigger` creates a deterministic submitted `WORK_ORDER.md` from a WORK contract or a SPEC with exactly one resolvable work contract. `mdkg work order status` and `mdkg work receipt verify` are read-only review helpers for deterministic closeout. `mdkg work validate [<id-or-qid>] [--type spec|work|work_order|receipt|feedback|dispute|proposal] --json` is a read-only focused validator for agent workflow mirrors; it returns typed diagnostics and warns on obvious raw secret, prompt, token, or payload markers. `mdkg work trigger --enqueue <queue>` optionally writes a local project DB queue delivery message after the queue has been explicitly created and is active; it still does not execute work. Production order state, receipt state, feedback, disputes, payments, ledgers, marketplace inventory, fulfillment records, and execution state remain canonical outside mdkg, such as in Postgres or another application database. Do not store raw secrets, credentials, live payment state, ledger mutations, canonical marketplace state, or bulky raw payloads in these mirrors.
549
579
 
550
580
  ## Archive sidecars
551
581