@sentropic/track 0.98.10 → 0.98.11-rc.13

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 (218) hide show
  1. package/README.md +39 -6
  2. package/dist/adopt/apply.d.ts +30 -0
  3. package/dist/adopt/apply.d.ts.map +1 -0
  4. package/dist/adopt/apply.js +573 -0
  5. package/dist/adopt/apply.js.map +1 -0
  6. package/dist/adopt/plan.d.ts +63 -0
  7. package/dist/adopt/plan.d.ts.map +1 -0
  8. package/dist/adopt/plan.js +320 -0
  9. package/dist/adopt/plan.js.map +1 -0
  10. package/dist/capture/cli.d.ts +5 -0
  11. package/dist/capture/cli.d.ts.map +1 -0
  12. package/dist/capture/cli.js +532 -0
  13. package/dist/capture/cli.js.map +1 -0
  14. package/dist/capture/index.d.ts +8 -0
  15. package/dist/capture/index.d.ts.map +1 -0
  16. package/dist/capture/index.js +8 -0
  17. package/dist/capture/index.js.map +1 -0
  18. package/dist/capture/inscribe.d.ts +64 -0
  19. package/dist/capture/inscribe.d.ts.map +1 -0
  20. package/dist/capture/inscribe.js +407 -0
  21. package/dist/capture/inscribe.js.map +1 -0
  22. package/dist/capture/markers.d.ts +10 -0
  23. package/dist/capture/markers.d.ts.map +1 -0
  24. package/dist/capture/markers.js +26 -0
  25. package/dist/capture/markers.js.map +1 -0
  26. package/dist/capture/queue.d.ts +131 -0
  27. package/dist/capture/queue.d.ts.map +1 -0
  28. package/dist/capture/queue.js +422 -0
  29. package/dist/capture/queue.js.map +1 -0
  30. package/dist/capture/reader.d.ts +42 -0
  31. package/dist/capture/reader.d.ts.map +1 -0
  32. package/dist/capture/reader.js +72 -0
  33. package/dist/capture/reader.js.map +1 -0
  34. package/dist/capture/registry.d.ts +42 -0
  35. package/dist/capture/registry.d.ts.map +1 -0
  36. package/dist/capture/registry.js +141 -0
  37. package/dist/capture/registry.js.map +1 -0
  38. package/dist/capture/secrets.d.ts +30 -0
  39. package/dist/capture/secrets.d.ts.map +1 -0
  40. package/dist/capture/secrets.js +145 -0
  41. package/dist/capture/secrets.js.map +1 -0
  42. package/dist/cli/adopt.d.ts +10 -0
  43. package/dist/cli/adopt.d.ts.map +1 -0
  44. package/dist/cli/adopt.js +151 -0
  45. package/dist/cli/adopt.js.map +1 -0
  46. package/dist/cli/desync.d.ts +24 -4
  47. package/dist/cli/desync.d.ts.map +1 -1
  48. package/dist/cli/desync.js +86 -22
  49. package/dist/cli/desync.js.map +1 -1
  50. package/dist/cli/events-contains.d.ts +2 -0
  51. package/dist/cli/events-contains.d.ts.map +1 -1
  52. package/dist/cli/events-contains.js +1 -1
  53. package/dist/cli/events-contains.js.map +1 -1
  54. package/dist/cli/index.d.ts +2 -0
  55. package/dist/cli/index.d.ts.map +1 -1
  56. package/dist/cli/index.js +443 -17
  57. package/dist/cli/index.js.map +1 -1
  58. package/dist/cli/install-skills.d.ts +2 -0
  59. package/dist/cli/install-skills.d.ts.map +1 -1
  60. package/dist/cli/install-skills.js +74 -12
  61. package/dist/cli/install-skills.js.map +1 -1
  62. package/dist/cli/journal-reference.d.ts +46 -0
  63. package/dist/cli/journal-reference.d.ts.map +1 -0
  64. package/dist/cli/journal-reference.js +434 -0
  65. package/dist/cli/journal-reference.js.map +1 -0
  66. package/dist/cli/journal.d.ts +12 -0
  67. package/dist/cli/journal.d.ts.map +1 -0
  68. package/dist/cli/journal.js +302 -0
  69. package/dist/cli/journal.js.map +1 -0
  70. package/dist/cli/resolve.d.ts.map +1 -1
  71. package/dist/cli/resolve.js +9 -0
  72. package/dist/cli/resolve.js.map +1 -1
  73. package/dist/cli/restructure-apply.d.ts +3 -0
  74. package/dist/cli/restructure-apply.d.ts.map +1 -1
  75. package/dist/cli/restructure-apply.js +5 -1
  76. package/dist/cli/restructure-apply.js.map +1 -1
  77. package/dist/events/store.d.ts +5 -1
  78. package/dist/events/store.d.ts.map +1 -1
  79. package/dist/events/store.js +8 -1
  80. package/dist/events/store.js.map +1 -1
  81. package/dist/events/types.d.ts +8 -3
  82. package/dist/events/types.d.ts.map +1 -1
  83. package/dist/events/types.js +12 -0
  84. package/dist/events/types.js.map +1 -1
  85. package/dist/focus-vendor/artifact/check.d.ts +73 -0
  86. package/dist/focus-vendor/artifact/check.d.ts.map +1 -0
  87. package/dist/focus-vendor/artifact/check.js +148 -0
  88. package/dist/focus-vendor/artifact/check.js.map +1 -0
  89. package/dist/focus-vendor/artifact/index.d.ts +3 -0
  90. package/dist/focus-vendor/artifact/index.d.ts.map +1 -0
  91. package/dist/focus-vendor/artifact/index.js +3 -0
  92. package/dist/focus-vendor/artifact/index.js.map +1 -0
  93. package/dist/focus-vendor/artifact/manifest.d.ts +74 -0
  94. package/dist/focus-vendor/artifact/manifest.d.ts.map +1 -0
  95. package/dist/focus-vendor/artifact/manifest.js +485 -0
  96. package/dist/focus-vendor/artifact/manifest.js.map +1 -0
  97. package/dist/focus-vendor/cli/index.d.ts +1 -1
  98. package/dist/focus-vendor/index.d.ts +1 -0
  99. package/dist/focus-vendor/index.js +1 -0
  100. package/dist/focus-vendor/index.js.map +1 -1
  101. package/dist/focus-vendor/registry/entries.v1.json +1 -1
  102. package/dist/fs-private.d.ts +37 -0
  103. package/dist/fs-private.d.ts.map +1 -0
  104. package/dist/fs-private.js +224 -0
  105. package/dist/fs-private.js.map +1 -0
  106. package/dist/graph-export.d.ts +19 -0
  107. package/dist/graph-export.d.ts.map +1 -1
  108. package/dist/graph-export.js +53 -0
  109. package/dist/graph-export.js.map +1 -1
  110. package/dist/index.d.ts +6 -0
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +8 -0
  113. package/dist/index.js.map +1 -1
  114. package/dist/journal/identity.d.ts +37 -0
  115. package/dist/journal/identity.d.ts.map +1 -0
  116. package/dist/journal/identity.js +134 -0
  117. package/dist/journal/identity.js.map +1 -0
  118. package/dist/journal/index-store.d.ts +56 -0
  119. package/dist/journal/index-store.d.ts.map +1 -0
  120. package/dist/journal/index-store.js +167 -0
  121. package/dist/journal/index-store.js.map +1 -0
  122. package/dist/journal/index.d.ts +4 -0
  123. package/dist/journal/index.d.ts.map +1 -0
  124. package/dist/journal/index.js +4 -0
  125. package/dist/journal/index.js.map +1 -0
  126. package/dist/journal/inscription.d.ts +28 -0
  127. package/dist/journal/inscription.d.ts.map +1 -0
  128. package/dist/journal/inscription.js +93 -0
  129. package/dist/journal/inscription.js.map +1 -0
  130. package/dist/model/blocker.d.ts +2 -0
  131. package/dist/model/blocker.d.ts.map +1 -1
  132. package/dist/model/blocker.js.map +1 -1
  133. package/dist/model/decision.d.ts +11 -0
  134. package/dist/model/decision.d.ts.map +1 -1
  135. package/dist/model/decision.js +4 -0
  136. package/dist/model/decision.js.map +1 -1
  137. package/dist/model/demand.d.ts +34 -1
  138. package/dist/model/demand.d.ts.map +1 -1
  139. package/dist/model/demand.js +4 -0
  140. package/dist/model/demand.js.map +1 -1
  141. package/dist/model/item.d.ts +3 -1
  142. package/dist/model/item.d.ts.map +1 -1
  143. package/dist/model/item.js.map +1 -1
  144. package/dist/model/report-status.d.ts +124 -21
  145. package/dist/model/report-status.d.ts.map +1 -1
  146. package/dist/model/report-status.js +372 -38
  147. package/dist/model/report-status.js.map +1 -1
  148. package/dist/read/commands.d.ts +15 -0
  149. package/dist/read/commands.d.ts.map +1 -1
  150. package/dist/read/commands.js +26 -0
  151. package/dist/read/commands.js.map +1 -1
  152. package/dist/read/contract.d.ts +24 -0
  153. package/dist/read/contract.d.ts.map +1 -1
  154. package/dist/read/contract.js +68 -1
  155. package/dist/read/contract.js.map +1 -1
  156. package/dist/read/index.d.ts +2 -2
  157. package/dist/read/index.d.ts.map +1 -1
  158. package/dist/read/index.js +1 -1
  159. package/dist/read/index.js.map +1 -1
  160. package/dist/report/audit.d.ts +2 -19
  161. package/dist/report/audit.d.ts.map +1 -1
  162. package/dist/report/audit.js +9 -26
  163. package/dist/report/audit.js.map +1 -1
  164. package/dist/report/index.d.ts +2 -0
  165. package/dist/report/index.d.ts.map +1 -1
  166. package/dist/report/index.js +2 -0
  167. package/dist/report/index.js.map +1 -1
  168. package/dist/report/owner-table-qualified.d.ts +153 -0
  169. package/dist/report/owner-table-qualified.d.ts.map +1 -0
  170. package/dist/report/owner-table-qualified.js +702 -0
  171. package/dist/report/owner-table-qualified.js.map +1 -0
  172. package/dist/report/owner-table-scope.d.ts +41 -0
  173. package/dist/report/owner-table-scope.d.ts.map +1 -0
  174. package/dist/report/owner-table-scope.js +92 -0
  175. package/dist/report/owner-table-scope.js.map +1 -0
  176. package/dist/report/owner-table-strings.d.ts +142 -0
  177. package/dist/report/owner-table-strings.d.ts.map +1 -0
  178. package/dist/report/owner-table-strings.js +321 -0
  179. package/dist/report/owner-table-strings.js.map +1 -0
  180. package/dist/report/owner-table.d.ts +194 -0
  181. package/dist/report/owner-table.d.ts.map +1 -0
  182. package/dist/report/owner-table.js +2154 -0
  183. package/dist/report/owner-table.js.map +1 -0
  184. package/dist/report/stage-status-lexicon.d.ts.map +1 -1
  185. package/dist/report/stage-status-lexicon.js +61 -37
  186. package/dist/report/stage-status-lexicon.js.map +1 -1
  187. package/dist/report/stage-status.d.ts +20 -9
  188. package/dist/report/stage-status.d.ts.map +1 -1
  189. package/dist/report/stage-status.js +211 -85
  190. package/dist/report/stage-status.js.map +1 -1
  191. package/dist/report/velocity-eta.d.ts +81 -0
  192. package/dist/report/velocity-eta.d.ts.map +1 -0
  193. package/dist/report/velocity-eta.js +217 -0
  194. package/dist/report/velocity-eta.js.map +1 -0
  195. package/dist/state/fold.d.ts +11 -0
  196. package/dist/state/fold.d.ts.map +1 -1
  197. package/dist/state/fold.js +492 -7
  198. package/dist/state/fold.js.map +1 -1
  199. package/dist/state-home.d.ts +28 -0
  200. package/dist/state-home.d.ts.map +1 -0
  201. package/dist/state-home.js +63 -0
  202. package/dist/state-home.js.map +1 -0
  203. package/dist/track.d.ts +133 -8
  204. package/dist/track.d.ts.map +1 -1
  205. package/dist/track.js +767 -28
  206. package/dist/track.js.map +1 -1
  207. package/dist/workspace-id.d.ts.map +1 -1
  208. package/dist/workspace-id.js +5 -0
  209. package/dist/workspace-id.js.map +1 -1
  210. package/dist/write-policy.d.ts +83 -0
  211. package/dist/write-policy.d.ts.map +1 -0
  212. package/dist/write-policy.js +290 -0
  213. package/dist/write-policy.js.map +1 -0
  214. package/package.json +1 -1
  215. package/registry/entries.v1.json +1 -1
  216. package/skills/present-decision/SKILL.md +9 -16
  217. package/skills/present-decision/assets/dossier-template.md +2 -3
  218. package/skills/present-decision/assets/self-audit.md +3 -3
package/dist/cli/index.js CHANGED
@@ -1,13 +1,23 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
- import { mkdirSync, readFileSync } from 'node:fs';
3
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
4
4
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
5
5
  import { readHead } from '../events/head.js';
6
6
  import { EventStore } from '../events/store.js';
7
7
  import { validate } from '../events/validate.js';
8
8
  import { cmdEventsContains } from './events-contains.js';
9
+ import { cmdAdopt } from './adopt.js';
10
+ import { cmdCapture } from '../capture/cli.js';
11
+ import { readCaptureViewForIdentity } from '../capture/reader.js';
12
+ import { maskSecrets } from '../capture/secrets.js';
9
13
  import { cmdInstallSkills } from './install-skills.js';
10
14
  import { initTrackDir, resolveTrackDir, resolveTrackDirOrNull } from './resolve.js';
15
+ import { resolveJournalOfReference } from './journal-reference.js';
16
+ import { cmdJournal } from './journal.js';
17
+ import { readWritePolicy } from '../write-policy.js';
18
+ import { resolveOwnerTablePolicyFile, trackStateHome } from '../state-home.js';
19
+ import { canonicalPath, identityOf, isInsideDir, isJournalIdentity, projectIdentity, tmpCeilingFor } from '../journal/identity.js';
20
+ import { deriveLabelFromIndex, readJournalIndex } from '../journal/index-store.js';
11
21
  import { assertItemLink, DomainError } from '../model/item.js';
12
22
  import { displayText, formatRows } from '../report/format.js';
13
23
  import { Track } from '../track.js';
@@ -16,17 +26,23 @@ import { ingest } from '../ingest/ingest.js';
16
26
  import { applyRestructurePlan } from './restructure-apply.js';
17
27
  import { TrackReader } from '../read/contract.js';
18
28
  import { queryText, reportInline, reportText, resolveHandle, statusText } from '../read/commands.js';
29
+ import { auditOwnerTable, formatOwnerTableNoJournalMessage } from '../report/owner-table.js';
30
+ import { buildQualifiedOwnerTable, renderQualifiedOwnerTable } from '../report/owner-table-qualified.js';
19
31
  import { STATUS_LEVELS } from '../report/status-by-level.js';
20
32
  import { renderSnapshot } from '../report/snapshot.js';
21
33
  import { VERSION } from '../version.js';
22
34
  import { durableWorkspaceId } from '../workspace-id.js';
23
- import { desyncFindings } from './desync.js';
35
+ import { desyncFindings, evaluateDesync } from './desync.js';
24
36
  const USAGE = `usage: track <command>
25
37
  --help | help
26
38
  global read/store override: --track-dir <directory-containing-events.jsonl> (or TRACK_DIR)
27
39
  may appear before or after the command; it redirects reads AND writes to that directory
40
+ global write-policy token: --writer-token-file <path> (or TRACK_WRITER_TOKEN)
41
+ may appear before or after the command; presents the exclusive writer token
28
42
  --version | -v
29
43
  init
44
+ journal which [--format json|text] | designate <dir> [--by <name>] | attach --to <dir> | declare-writer --holder <name> [--token-file <path>] | takeover --holder <name> --reason <text> [--token-file <path>] | release | status [--format json|text]
45
+ capture add|register|status|list|remind|classify|inscribe|acknowledge ...
30
46
  item new --kind <feature|bug|chore> --title <t> --workspace <w> [--body <b>] [--parent <id>] [--role <workpackage|spec-phase|stream>] [--accountable <a>] [--responsible <a,a>] [--link <kind=locator>] (repeatable --link; trim actor IDs; blank responsible members are dropped)
31
47
  item link <itemId> --kind <kind> --locator <locator> [--reason <text>] [--client-token <t>] (attach one link/pin to an existing item; kind spec-exempt requires --reason)
32
48
  item reparent <itemId> [--parent <pid>] [--detach]
@@ -41,8 +57,14 @@ const USAGE = `usage: track <command>
41
57
  item assign-code <itemId> --code <c> [--client-token <t>]
42
58
  item show <itemId>
43
59
  item ls [--workspace <w>] [--kind <feature|bug|chore>] [--format json|text|md]
60
+ demand raise (--text <text> | --stdin) [--title <t>] [--type <feature|defect|chore>] [--workspace <w>] [--source <human|agent|h2a|import|external>] [--key <k>]
61
+ demand number <demandId> --number <n> [--summary <s>] [--requested-stage <stage>]
62
+ demand summary <demandId> --summary <s> [--requested-stage <stage>]
63
+ demand archive <demandId> --decision-id <id> --reason <r>
64
+ demand eta <demandId> --target-stage <stage> (--when <date> --source <measured|committed|unknown> | --delivered) [--target-label <l>] [--by <actor>] [--reason <r>] [--rebaseline-decision <id>]
44
65
  decision new --kind <orientation|commitment> --title <t> --workspace <w> --targets <id,id> --context <c> --options-json <json> --recommendation <optionId> --rationale <r> [--accountable <a>] [--engagement-ref <e>]
45
66
  decision ls [--workspace <w>] [--outcome <pending|go|no-go|deferred>] [--format json|text|md] [--commit <sha>]
67
+ decision number (<decisionId> | --all-unnumbered)
46
68
  decision outcome <decisionId> deferred
47
69
  decision select <decisionId> <optionId> [--outcome <go|no-go>]
48
70
  decision dossier <decisionId> [--context <c>] [--options-json <json> --recommendation <optionId> --rationale <r>]
@@ -70,6 +92,8 @@ const USAGE = `usage: track <command>
70
92
  audit [--format json|text]
71
93
  focus <decision-id> --workspace <w> [--format terminal|md|html|json] [--baseline-commit <sha>]
72
94
  branch import <BRANCH.md> [--commit <sha>]
95
+ adopt plan [--out <file>] [--now <iso>] [--commit <sha>] [--policy <path>]
96
+ adopt apply <plan.json> [--writer-token-file <path>] [--now <iso>] [--commit <sha>] [--policy <path>]
73
97
  restructure apply --plan <plan.json>
74
98
  ingest <file.jsonl> --workspace <w>
75
99
  install-skills --host <claude|codex|gemini|agy|all> [--scope user|project] [--force]
@@ -94,7 +118,10 @@ function eventsPathOf(trackDir) {
94
118
  return join(trackDir, 'events.jsonl');
95
119
  }
96
120
  function store(ctx) {
97
- return new EventStore(ctx.eventsPath);
121
+ return new EventStore(ctx.eventsPath, {
122
+ ...(ctx.writerTokenFile !== undefined ? { writerTokenFile: ctx.writerTokenFile } : {}),
123
+ ...(ctx.io.env !== undefined ? { env: ctx.io.env } : {}),
124
+ });
98
125
  }
99
126
  function gitHead(cwd) {
100
127
  try {
@@ -421,6 +448,28 @@ function extractTrackDirFlag(argv) {
421
448
  }
422
449
  return trackDirFlag !== undefined ? { trackDirFlag, rest } : { rest };
423
450
  }
451
+ /**
452
+ * Pull a global `--writer-token-file <path>` out of argv BEFORE per-command parsing (plan/07 Lot 3),
453
+ * mirroring `extractTrackDirFlag`. Fails closed when `--writer-token-file` is passed without a path.
454
+ */
455
+ function extractWriterTokenFileFlag(argv, cwd) {
456
+ const rest = [];
457
+ let writerTokenFile;
458
+ for (let i = 0; i < argv.length; i++) {
459
+ const a = argv[i];
460
+ if (a === '--writer-token-file') {
461
+ const next = argv[i + 1];
462
+ if (next === undefined || next.startsWith('--')) {
463
+ throw new DomainError('--writer-token-file requires a path');
464
+ }
465
+ writerTokenFile = isAbsolute(next) ? next : resolve(cwd, next);
466
+ i++;
467
+ continue;
468
+ }
469
+ rest.push(a);
470
+ }
471
+ return writerTokenFile !== undefined ? { writerTokenFile, rest } : { rest };
472
+ }
424
473
  /**
425
474
  * Request-lifecycle Part 1 (Lot L2) — pull a REPEATABLE value flag's occurrences out of argv.
426
475
  * `parseFlags` keeps only the LAST occurrence of a repeated key, so `item new --link a --link b`
@@ -444,7 +493,9 @@ function extractRepeatableFlag(args, key) {
444
493
  }
445
494
  return { values, rest };
446
495
  }
447
- const REPORT_USAGE = `usage: track report [--status-table] [--scope <container-id|code|label>] [--since <sha|YYYY-MM-DD> [--until <sha|YYYY-MM-DD>] | --period <today|week|month|all|last-week|last-day>] [--raw] [--wp] [--flat] [--inline|--width <40..240>] [--decisions] [--active-roster] [--require-accepted] [--resolve <handle>] [--commit <sha>] [--now <iso>] [--sub-wp] [--lang <bcp47>] [--format json|text|md] [--track-dir <directory-containing-events.jsonl>]
496
+ const REPORT_USAGE = `usage: track report [--owner-table [--strict]] [--status-table] [--scope <container-id|code|label>] [--since <sha|YYYY-MM-DD> [--until <sha|YYYY-MM-DD>] | --period <today|week|month|all|last-week|last-day>] [--raw] [--wp] [--flat] [--inline|--width <40..240>] [--decisions] [--active-roster] [--require-accepted] [--resolve <handle>] [--commit <sha>] [--now <iso>] [--sub-wp] [--lang <bcp47>] [--format json|text|md] [--track-dir <directory-containing-events.jsonl>]
497
+
498
+ --owner-table is the default owner report: it renders the qualified owner status table with its declared scope header, 8-column table, unnumbered demands to attach, and pending decisions; --strict restores the all-or-nothing refusal on any per-element gap.
448
499
 
449
500
  --status-table selects the validated four-section report: À-FAIRE carries WP · av. · étape · statut · à faire · bloqué · prochaine action over a rolling last-week window by default (an explicit period always wins). Stage/status are neutral codes over recorded evidence; missing information is flagged, never colored. It preserves DÉCISIONS and supports scoped Markdown.
450
501
 
@@ -465,7 +516,19 @@ Rebind the exact rendering context with --scope/--period/--since/--until/--now/-
465
516
  --track-dir is a global override and may appear before or after the command. It selects the directory that contains events.jsonl; it is especially useful for a read-only fixture. TRACK_DIR is the environment equivalent.
466
517
  `;
467
518
  export function runCli(rawArgv, io) {
468
- const { trackDirFlag, rest: argv } = extractTrackDirFlag(rawArgv);
519
+ const { trackDirFlag, rest: argvAfterTrackDir } = extractTrackDirFlag(rawArgv);
520
+ let writerTokenFile;
521
+ let argv;
522
+ try {
523
+ const extracted = extractWriterTokenFileFlag(argvAfterTrackDir, io.cwd);
524
+ writerTokenFile = extracted.writerTokenFile;
525
+ argv = extracted.rest;
526
+ }
527
+ catch (error) {
528
+ const rawMsg = error instanceof Error ? error.message : String(error);
529
+ io.err(`error: ${maskSecrets(rawMsg).text}\n`);
530
+ return 1;
531
+ }
469
532
  const cmd = argv[0];
470
533
  const rest = argv.slice(1);
471
534
  if (cmd === '--help' || cmd === 'help' || cmd === undefined) {
@@ -476,7 +539,7 @@ export function runCli(rawArgv, io) {
476
539
  io.out(REPORT_USAGE);
477
540
  return 0;
478
541
  }
479
- const trackDirEnv = process.env['TRACK_DIR'];
542
+ const trackDirEnv = (io.env ?? process.env)['TRACK_DIR'];
480
543
  const resolveOpts = {
481
544
  cwd: io.cwd,
482
545
  ...(trackDirFlag !== undefined ? { flag: trackDirFlag } : {}),
@@ -494,8 +557,26 @@ export function runCli(rawArgv, io) {
494
557
  return cmdDecisionLs(rest, {
495
558
  io,
496
559
  eventsPath: trackDir !== null ? eventsPathOf(trackDir) : eventsPathOf(join(resolve(io.cwd), '.track')),
560
+ writerTokenFile,
497
561
  });
498
562
  }
563
+ // `demand raise` and `decision number` resolve their journal via `resolveJournalOfReference`
564
+ // (spec DS-6: main checkout from a linked worktree, temp-root ceiling included, never falling
565
+ // back to `resolveTrackDir`).
566
+ if (cmd === 'demand' && rest[0] === 'raise') {
567
+ const ref = resolveJournalOfReference({ ...resolveOpts, processEnv: io.env ?? process.env });
568
+ if (ref.trackDir === null) {
569
+ throw new DomainError(formatOwnerTableNoJournalMessage(io.cwd, ref.reason));
570
+ }
571
+ return cmdDemandRaise(rest.slice(1), { io, eventsPath: eventsPathOf(ref.trackDir), writerTokenFile });
572
+ }
573
+ if (cmd === 'decision' && rest[0] === 'number') {
574
+ const ref = resolveJournalOfReference({ ...resolveOpts, processEnv: io.env ?? process.env });
575
+ if (ref.trackDir === null) {
576
+ throw new DomainError(formatOwnerTableNoJournalMessage(io.cwd, ref.reason));
577
+ }
578
+ return cmdDecisionNumber(rest.slice(1), { io, eventsPath: eventsPathOf(ref.trackDir), writerTokenFile });
579
+ }
499
580
  switch (cmd) {
500
581
  case '--version':
501
582
  case '-v':
@@ -523,11 +604,36 @@ export function runCli(rawArgv, io) {
523
604
  // PATHS. Git-free AND store-free: it never resolves a `.track` dir (the paths are supplied),
524
605
  // so it dispatches here alongside install-skills/workspace-id, before store resolution.
525
606
  return cmdEventsContains(rest, io);
607
+ case 'adopt':
608
+ return cmdAdopt(rest, io, resolveOpts, resolveCommit, cliActor, writerTokenFile);
609
+ case 'journal':
610
+ // Journal of reference inspection, designation/attachment (lot 4a), and write policy (lot 3a).
611
+ return cmdJournal(rest, io, { ...resolveOpts, processEnv: io.env ?? process.env }, writerTokenFile);
612
+ case 'capture':
613
+ // Capture queue, registry, classification, inscription, and acknowledgement (lot 3a).
614
+ return cmdCapture(rest, io, { ...resolveOpts, processEnv: io.env ?? process.env }, cliActor, writerTokenFile);
526
615
  // READ commands SERVE-EMPTY (launch/serve alignment): they resolve via the non-throwing
527
616
  // `resolveTrackDirOrNull`, so an unadopted repo yields rc=0 + an honest-empty view + a stderr
528
617
  // `track init` hint, never a boot crash. NEVER creates. A bad EXPLICIT override still throws
529
618
  // (user error → the outer catch → rc=1). The reader over a nonexistent log already reads empty.
530
- case 'report':
619
+ case 'report': {
620
+ if (rest.includes('--owner-table')) {
621
+ const ref = resolveJournalOfReference({ ...resolveOpts, processEnv: io.env ?? process.env });
622
+ const ctx = {
623
+ io,
624
+ eventsPath: ref.trackDir !== null
625
+ ? eventsPathOf(ref.trackDir)
626
+ : eventsPathOf(join(resolve(io.cwd), '.track')),
627
+ };
628
+ return cmdReport(rest, ctx, ref.trackDir === null, ref);
629
+ }
630
+ const trackDir = resolveTrackDirOrNull(resolveOpts);
631
+ const ctx = {
632
+ io,
633
+ eventsPath: trackDir !== null ? eventsPathOf(trackDir) : eventsPathOf(join(resolve(io.cwd), '.track')),
634
+ };
635
+ return cmdReport(rest, ctx, trackDir === null);
636
+ }
531
637
  case 'snapshot':
532
638
  case 'export-graph':
533
639
  case 'query':
@@ -548,8 +654,6 @@ export function runCli(rawArgv, io) {
548
654
  eventsPath: trackDir !== null ? eventsPathOf(trackDir) : eventsPathOf(join(resolve(io.cwd), '.track')),
549
655
  };
550
656
  switch (cmd) {
551
- case 'report':
552
- return cmdReport(rest, ctx);
553
657
  case 'snapshot':
554
658
  return cmdSnapshot(rest, ctx);
555
659
  case 'export-graph':
@@ -577,6 +681,7 @@ export function runCli(rawArgv, io) {
577
681
  // USAGE/rc=2 branch for an UNKNOWN command is reached BEFORE resolution (a typo must not be masked
578
682
  // by a "no .track" error), so `resolveTrackDir` runs only for a recognized command.
579
683
  case 'item':
684
+ case 'demand':
580
685
  case 'decision':
581
686
  case 'blocker':
582
687
  case 'accept':
@@ -586,10 +691,12 @@ export function runCli(rawArgv, io) {
586
691
  case 'restructure':
587
692
  case 'ingest':
588
693
  case 'reseal': {
589
- const ctx = { io, eventsPath: eventsPathOf(resolveTrackDir(resolveOpts)) };
694
+ const ctx = { io, eventsPath: eventsPathOf(resolveTrackDir(resolveOpts)), writerTokenFile };
590
695
  switch (cmd) {
591
696
  case 'item':
592
697
  return cmdItem(rest, ctx);
698
+ case 'demand':
699
+ return cmdDemand(rest, ctx);
593
700
  case 'restructure':
594
701
  return cmdRestructure(rest, ctx);
595
702
  case 'decision':
@@ -621,7 +728,8 @@ export function runCli(rawArgv, io) {
621
728
  }
622
729
  }
623
730
  catch (error) {
624
- io.err(`error: ${error instanceof Error ? error.message : String(error)}\n`);
731
+ const rawMsg = error instanceof Error ? error.message : String(error);
732
+ io.err(`error: ${maskSecrets(rawMsg).text}\n`);
625
733
  return 1;
626
734
  }
627
735
  }
@@ -667,6 +775,31 @@ function cmdItem(args, ctx) {
667
775
  io.out('ok\n');
668
776
  return 0;
669
777
  }
778
+ if (sub === 'eta') {
779
+ assertOnlyFlags(flags, ['target-stage', 'target-label', 'when', 'source', 'by', 'reason', 'rebaseline-decision', 'delivered']);
780
+ if (positional.length !== 1)
781
+ throw new DomainError('item eta requires one itemId');
782
+ const delivered = assertBooleanFlag(flags, 'delivered');
783
+ track.setItemEta(positional[0], {
784
+ targetStage: req(flags, 'target-stage'),
785
+ ...(delivered
786
+ ? {
787
+ delivered: true,
788
+ ...(opt(flags, 'when') !== undefined ? { when: req(flags, 'when') } : {}),
789
+ ...(opt(flags, 'source') !== undefined ? { source: req(flags, 'source') } : {}),
790
+ }
791
+ : {
792
+ when: req(flags, 'when'),
793
+ source: req(flags, 'source'),
794
+ }),
795
+ ...(opt(flags, 'target-label') !== undefined ? { targetLabel: req(flags, 'target-label') } : {}),
796
+ ...(opt(flags, 'by') !== undefined ? { by: req(flags, 'by') } : {}),
797
+ ...(opt(flags, 'reason') !== undefined ? { reason: req(flags, 'reason') } : {}),
798
+ ...(opt(flags, 'rebaseline-decision') !== undefined ? { rebaselineDecisionId: req(flags, 'rebaseline-decision') } : {}),
799
+ });
800
+ io.out('ok\n');
801
+ return 0;
802
+ }
670
803
  if (sub === 'new') {
671
804
  // Request-lifecycle Part 1 (Lot L2) — `--link <kind=locator>` is REPEATABLE (parseFlags keeps only
672
805
  // the LAST occurrence), so the pairs are pulled out of raw argv before the standard parse; each is
@@ -931,10 +1064,42 @@ function cmdRestructure(args, ctx) {
931
1064
  catch {
932
1065
  throw new DomainError('restructure apply: --plan must be a valid JSON plan file');
933
1066
  }
934
- const res = applyRestructurePlan(ctx.eventsPath, plan, { by: cliActor(io.cwd) });
1067
+ const res = applyRestructurePlan(ctx.eventsPath, plan, {
1068
+ by: cliActor(io.cwd),
1069
+ ...(ctx.writerTokenFile !== undefined ? { writerTokenFile: ctx.writerTokenFile } : {}),
1070
+ ...(io.env !== undefined ? { env: io.env } : {}),
1071
+ });
935
1072
  io.out(`applied ${res.applied} edge(s) of ${res.edges} (${res.alreadyApplied} already applied) [plan ${res.planHash}]\n`);
936
1073
  return 0;
937
1074
  }
1075
+ function cmdDecisionNumber(args, ctx) {
1076
+ const { io } = ctx;
1077
+ const { positional, flags } = parseFlags(args);
1078
+ assertOnlyFlags(flags, ['all-unnumbered']);
1079
+ const allUnnumbered = assertBooleanFlag(flags, 'all-unnumbered');
1080
+ if (allUnnumbered && positional.length > 0) {
1081
+ throw new DomainError('decision number: --all-unnumbered does not accept a <decisionId> argument');
1082
+ }
1083
+ if (!allUnnumbered && positional.length !== 1) {
1084
+ io.err('usage: track decision number (<decisionId> | --all-unnumbered)\n');
1085
+ return 2;
1086
+ }
1087
+ const track = writeTrack(ctx);
1088
+ if (allUnnumbered) {
1089
+ const numbered = track.numberAllUnnumberedDecisions();
1090
+ if (numbered.length === 0) {
1091
+ io.out('no-op: 0 unnumbered structured decision(s)\n');
1092
+ return 0;
1093
+ }
1094
+ for (const entry of numbered) {
1095
+ io.out(`${entry.decisionId} D${entry.number}\n`);
1096
+ }
1097
+ return 0;
1098
+ }
1099
+ const result = track.numberDecision(positional[0]);
1100
+ io.out(`${result.decisionId} D${result.number}\n`);
1101
+ return 0;
1102
+ }
938
1103
  function cmdDecision(args, ctx) {
939
1104
  const { io } = ctx;
940
1105
  const sub = args[0];
@@ -1032,7 +1197,7 @@ function cmdDecision(args, ctx) {
1032
1197
  io.out('ok\n');
1033
1198
  return 0;
1034
1199
  }
1035
- io.err('usage: track decision <new|outcome|select|dossier|disposition|add-artifact>\n');
1200
+ io.err('usage: track decision <new|ls|number|outcome|select|dossier|disposition|add-artifact>\n');
1036
1201
  return 2;
1037
1202
  }
1038
1203
  function cmdBlocker(args, ctx) {
@@ -1171,18 +1336,158 @@ function cmdPriority(args, ctx) {
1171
1336
  io.err('usage: track priority assess <itemId> --ubv --tc --rr --js\n');
1172
1337
  return 2;
1173
1338
  }
1174
- function cmdReport(args, ctx) {
1339
+ const DEMAND_TYPES = ['feature', 'defect', 'chore'];
1340
+ const DEMAND_SOURCE_KINDS = ['human', 'agent', 'h2a', 'import', 'external'];
1341
+ function cmdDemandRaise(args, ctx) {
1342
+ const { io } = ctx;
1343
+ const { positional, flags } = parseFlags(args);
1344
+ if (positional.length > 0) {
1345
+ throw new DomainError(`demand raise: unexpected positional argument(s): ${positional.join(' ')}`);
1346
+ }
1347
+ assertOnlyFlags(flags, ['text', 'stdin', 'title', 'type', 'workspace', 'source', 'key']);
1348
+ for (const name of ['text', 'title', 'type', 'workspace', 'source', 'key'])
1349
+ assertValueFlag(flags, name);
1350
+ const useStdin = assertBooleanFlag(flags, 'stdin');
1351
+ const textFlag = opt(flags, 'text');
1352
+ if (useStdin && textFlag !== undefined) {
1353
+ throw new DomainError('demand raise: --text and --stdin are mutually exclusive');
1354
+ }
1355
+ if (!useStdin && textFlag === undefined) {
1356
+ throw new DomainError('demand raise: requires --text <text> or --stdin');
1357
+ }
1358
+ const rawText = useStdin ? (io.stdin ?? readFileSync(0, 'utf8')).replace(/\r?\n$/u, '') : textFlag;
1359
+ if (rawText.trim().length === 0) {
1360
+ throw new DomainError('demand raise: text must be non-empty');
1361
+ }
1362
+ const title = opt(flags, 'title');
1363
+ if (title !== undefined && title.trim().length === 0) {
1364
+ throw new DomainError('demand raise: --title must be non-empty');
1365
+ }
1366
+ const type = oneOf(opt(flags, 'type') ?? 'feature', DEMAND_TYPES, '--type');
1367
+ const sourceKind = oneOf(opt(flags, 'source') ?? 'human', DEMAND_SOURCE_KINDS, '--source');
1368
+ const workspace = opt(flags, 'workspace') ?? projectIdentity(io.cwd);
1369
+ if (workspace === undefined || workspace.trim().length === 0) {
1370
+ throw new DomainError('demand raise: --workspace is required outside a git repository');
1371
+ }
1372
+ const key = opt(flags, 'key');
1373
+ if (key !== undefined && key.trim().length === 0) {
1374
+ throw new DomainError('demand raise: --key must be non-empty');
1375
+ }
1376
+ const track = writeTrack(ctx);
1377
+ const result = track.raiseNumberedDemand({
1378
+ type,
1379
+ raw: {
1380
+ text: rawText,
1381
+ ...(title !== undefined ? { title: title.trim() } : {}),
1382
+ },
1383
+ source: { kind: sourceKind },
1384
+ workspace: workspace.trim(),
1385
+ ...(title !== undefined ? { summary: title.trim() } : {}),
1386
+ ...(key !== undefined ? { key: key.trim() } : {}),
1387
+ });
1388
+ io.out(`${result.demandId} #${result.number}\n`);
1389
+ return 0;
1390
+ }
1391
+ function cmdDemand(args, ctx) {
1392
+ const { io } = ctx;
1393
+ const sub = args[0];
1394
+ const { positional, flags } = parseFlags(args.slice(1));
1395
+ const track = writeTrack(ctx);
1396
+ if (sub === 'number') {
1397
+ const demandId = positional[0];
1398
+ if (demandId === undefined)
1399
+ throw new DomainError('demand number requires <demandId>');
1400
+ assertOnlyFlags(flags, ['number', 'summary', 'requested-stage']);
1401
+ track.numberDemand(demandId, num(flags, 'number'));
1402
+ if (opt(flags, 'summary') !== undefined) {
1403
+ track.updateDemandOwnerSummary(demandId, {
1404
+ summary: req(flags, 'summary'),
1405
+ ...(opt(flags, 'requested-stage') !== undefined ? { requestedStage: req(flags, 'requested-stage') } : {}),
1406
+ });
1407
+ }
1408
+ io.out('ok\n');
1409
+ return 0;
1410
+ }
1411
+ if (sub === 'summary') {
1412
+ const demandId = positional[0];
1413
+ if (demandId === undefined)
1414
+ throw new DomainError('demand summary requires <demandId>');
1415
+ assertOnlyFlags(flags, ['summary', 'requested-stage']);
1416
+ track.updateDemandOwnerSummary(demandId, {
1417
+ summary: req(flags, 'summary'),
1418
+ ...(opt(flags, 'requested-stage') !== undefined ? { requestedStage: req(flags, 'requested-stage') } : {}),
1419
+ });
1420
+ io.out('ok\n');
1421
+ return 0;
1422
+ }
1423
+ if (sub === 'archive') {
1424
+ const demandId = positional[0];
1425
+ if (demandId === undefined)
1426
+ throw new DomainError('demand archive requires <demandId>');
1427
+ assertOnlyFlags(flags, ['decision-id', 'reason']);
1428
+ track.archiveDemand(demandId, {
1429
+ decisionId: req(flags, 'decision-id'),
1430
+ reason: req(flags, 'reason'),
1431
+ });
1432
+ io.out('ok\n');
1433
+ return 0;
1434
+ }
1435
+ if (sub === 'eta') {
1436
+ const demandId = positional[0];
1437
+ if (demandId === undefined)
1438
+ throw new DomainError('demand eta requires <demandId>');
1439
+ assertOnlyFlags(flags, ['target-stage', 'target-label', 'when', 'source', 'by', 'reason', 'rebaseline-decision', 'delivered']);
1440
+ const delivered = assertBooleanFlag(flags, 'delivered');
1441
+ track.setDemandEta(demandId, {
1442
+ targetStage: req(flags, 'target-stage'),
1443
+ ...(delivered
1444
+ ? {
1445
+ delivered: true,
1446
+ ...(opt(flags, 'when') !== undefined ? { when: req(flags, 'when') } : {}),
1447
+ ...(opt(flags, 'source') !== undefined ? { source: req(flags, 'source') } : {}),
1448
+ }
1449
+ : {
1450
+ when: req(flags, 'when'),
1451
+ source: req(flags, 'source'),
1452
+ }),
1453
+ ...(opt(flags, 'target-label') !== undefined ? { targetLabel: req(flags, 'target-label') } : {}),
1454
+ ...(opt(flags, 'by') !== undefined ? { by: req(flags, 'by') } : {}),
1455
+ ...(opt(flags, 'reason') !== undefined ? { reason: req(flags, 'reason') } : {}),
1456
+ ...(opt(flags, 'rebaseline-decision') !== undefined ? { rebaselineDecisionId: req(flags, 'rebaseline-decision') } : {}),
1457
+ });
1458
+ io.out('ok\n');
1459
+ return 0;
1460
+ }
1461
+ io.err('usage: track demand <raise|number|summary|archive|eta> ...\n');
1462
+ return 2;
1463
+ }
1464
+ function cmdReport(args, ctx, noTrackDir = false, journalRef) {
1175
1465
  const { io } = ctx;
1176
1466
  const { positional, flags } = parseFlags(args);
1177
1467
  if (positional.length > 0)
1178
1468
  throw new DomainError(`unexpected report argument(s): ${positional.join(' ')}`);
1179
- for (const name of ['commit', 'format', 'level', 'width', 'resolve', 'now', 'scope', 'since', 'until', 'period', 'lang'])
1469
+ for (const name of ['commit', 'format', 'level', 'width', 'resolve', 'now', 'scope', 'since', 'until', 'period', 'lang', 'policy'])
1180
1470
  assertValueFlag(flags, name);
1181
1471
  const scope = opt(flags, 'scope');
1472
+ const ownerTable = assertBooleanFlag(flags, 'owner-table');
1473
+ const strict = assertBooleanFlag(flags, 'strict');
1182
1474
  const statusTable = assertBooleanFlag(flags, 'status-table');
1475
+ if (strict && !ownerTable) {
1476
+ throw new DomainError('--strict is only valid with --owner-table');
1477
+ }
1478
+ if (ownerTable && statusTable) {
1479
+ throw new DomainError('--owner-table and --status-table are mutually exclusive');
1480
+ }
1183
1481
  if (statusTable && ['flat', 'inline', 'width', 'raw', 'level', 'active-roster'].some(k => flags[k] !== undefined)) {
1184
1482
  throw new DomainError('--status-table rejects --flat/--inline/--width/--raw/--level/--active-roster');
1185
1483
  }
1484
+ if (ownerTable && ['flat', 'inline', 'width', 'raw', 'level', 'active-roster', 'wp', 'scope', 'since', 'until', 'period', 'sub-wp', 'lang', 'resolve', 'require-accepted'].some(k => flags[k] !== undefined)) {
1485
+ throw new DomainError('--owner-table rejects legacy conductor/filter flags');
1486
+ }
1487
+ if (noTrackDir && !ownerTable) {
1488
+ io.err(`track: no .track resolved from ${io.cwd}. Run \`track init\` to create one ` +
1489
+ `(the ONLY command that does), or pass --track-dir / TRACK_DIR. Serving an empty view.\n`);
1490
+ }
1186
1491
  // Criterion 10b — the one documented command that turns a short report handle back into an item.
1187
1492
  if (opt(flags, 'resolve') !== undefined) {
1188
1493
  // Amendment D4/D13 — `--resolve` rebinds the exact rendering context
@@ -1236,7 +1541,7 @@ function cmdReport(args, ctx) {
1236
1541
  }
1237
1542
  assertOnlyFlags(flags, [
1238
1543
  'commit', 'require-accepted', 'decisions', 'active-roster', 'wp', 'flat', 'inline', 'width', 'format', 'now',
1239
- 'sub-wp', 'scope', 'since', 'until', 'period', 'status-table', 'lang',
1544
+ 'sub-wp', 'scope', 'since', 'until', 'period', 'status-table', 'owner-table', 'strict', 'lang', 'policy',
1240
1545
  ]);
1241
1546
  const rawFormat = opt(flags, 'format');
1242
1547
  if (rawFormat !== undefined && !['json', 'text', 'md'].includes(rawFormat)) {
@@ -1311,6 +1616,125 @@ function cmdReport(args, ctx) {
1311
1616
  throw new DomainError('--lang must be a BCP47 tag (e.g. fr, es-MX, ja, ar)');
1312
1617
  }
1313
1618
  const reader = new TrackReader(ctx.eventsPath);
1619
+ if (ownerTable) {
1620
+ const procEnv = io.env ?? process.env;
1621
+ const ceiling = tmpCeilingFor(io.cwd);
1622
+ const stateHome = trackStateHome(procEnv);
1623
+ const indexAllowed = ceiling === undefined ||
1624
+ isInsideDir(resolve(stateHome), resolve(ceiling)) ||
1625
+ isInsideDir(canonicalPath(stateHome), canonicalPath(ceiling));
1626
+ const captureView = indexAllowed && journalRef !== undefined
1627
+ ? readCaptureViewForIdentity(journalRef.identity, { env: procEnv, now: periodClock })
1628
+ : undefined;
1629
+ if (noTrackDir) {
1630
+ // DS-2 (spec §4 G4, §5, §7.1): active capture without a journal is a readable source —
1631
+ // render header, captured-not-inscribed section and partial-scope sentence, exit 0, write nothing.
1632
+ if (journalRef?.captureActive === true && captureView !== undefined) {
1633
+ const resolvedPolicy = resolveOwnerTablePolicyFile({
1634
+ flagPolicyPath: opt(flags, 'policy'),
1635
+ env: procEnv,
1636
+ });
1637
+ const policyFound = resolvedPolicy.policyPath !== undefined && existsSync(resolvedPolicy.policyPath);
1638
+ const emptyView = {
1639
+ kind: 'owner-table-report',
1640
+ rows: [],
1641
+ decisions: [],
1642
+ replyLine: '',
1643
+ registeredNumbers: [],
1644
+ archivedNumbers: [],
1645
+ ...(resolvedPolicy.policyPath !== undefined ? { policyPath: resolvedPolicy.policyPath } : {}),
1646
+ statePolicyPath: resolvedPolicy.statePolicyPath,
1647
+ };
1648
+ const qualified = buildQualifiedOwnerTable(emptyView, {
1649
+ now: periodClock,
1650
+ mode: strict ? 'strict' : 'default',
1651
+ policyFound,
1652
+ captureView,
1653
+ header: {
1654
+ label: journalRef.label,
1655
+ resolution: journalRef.resolution ?? 'dossier',
1656
+ noJournal: true,
1657
+ },
1658
+ ...(resolvedPolicy.policyPath !== undefined ? { policyPath: resolvedPolicy.policyPath } : {}),
1659
+ statePolicyPath: resolvedPolicy.statePolicyPath,
1660
+ });
1661
+ io.out(renderQualifiedOwnerTable(qualified, format));
1662
+ return 0;
1663
+ }
1664
+ throw new DomainError(formatOwnerTableNoJournalMessage(io.cwd, journalRef?.reason));
1665
+ }
1666
+ const resolvedPolicy = resolveOwnerTablePolicyFile({
1667
+ flagPolicyPath: opt(flags, 'policy'),
1668
+ trackDir: dirname(ctx.eventsPath),
1669
+ env: procEnv,
1670
+ });
1671
+ const ownerOpts = {
1672
+ baselineCommit: options.baselineCommit,
1673
+ now: periodClock,
1674
+ ...(resolvedPolicy.defaultPolicyPath !== undefined
1675
+ ? { defaultPolicyPath: resolvedPolicy.defaultPolicyPath }
1676
+ : {}),
1677
+ statePolicyPath: resolvedPolicy.statePolicyPath,
1678
+ ...(resolvedPolicy.policyPath !== undefined ? { policyPath: resolvedPolicy.policyPath } : {}),
1679
+ };
1680
+ const tableCtx = reader.ownerTableContext(ownerOpts);
1681
+ if (strict) {
1682
+ const audit = auditOwnerTable(tableCtx.view, ownerOpts);
1683
+ for (const notice of audit.notices ?? []) {
1684
+ io.err(`Notice: ${notice}\n`);
1685
+ }
1686
+ }
1687
+ const journalIndex = indexAllowed ? readJournalIndex(procEnv) : { version: 1, identities: {} };
1688
+ const isOffRepo = journalRef?.resolution === 'journal hors dépôt';
1689
+ const desyncEval = evaluateDesync(tableCtx.state, reader.journalProjectDir(), {
1690
+ index: journalIndex,
1691
+ env: procEnv,
1692
+ offRepo: isOffRepo,
1693
+ fallbackRoot: journalRef?.identityRoot ?? null,
1694
+ });
1695
+ const writePolicy = readWritePolicy(ctx.eventsPath);
1696
+ // Origin labels for rows raised from an identity different from the journal's own identity (lot 4a).
1697
+ const journalOwnIdentity = journalRef?.conductorIdentity ??
1698
+ (isOffRepo
1699
+ ? journalRef?.identity
1700
+ : journalRef?.trackDir !== null && journalRef?.trackDir !== undefined
1701
+ ? identityOf(reader.journalProjectDir()).id
1702
+ : journalRef?.identity);
1703
+ const rowOriginLabels = new Map();
1704
+ for (const row of tableCtx.view.rows) {
1705
+ const ws = tableCtx.state.demands.get(row.id)?.workspace ??
1706
+ tableCtx.state.items.get(row.id)?.workspace ??
1707
+ (row.parentDemandId !== undefined
1708
+ ? tableCtx.state.demands.get(row.parentDemandId)?.workspace
1709
+ : undefined);
1710
+ if (ws !== undefined &&
1711
+ isJournalIdentity(ws) &&
1712
+ journalOwnIdentity !== undefined &&
1713
+ ws !== journalOwnIdentity) {
1714
+ const shortLabel = deriveLabelFromIndex(ws, journalIndex) ?? 'journal';
1715
+ rowOriginLabels.set(row.id, shortLabel);
1716
+ }
1717
+ }
1718
+ const qualified = buildQualifiedOwnerTable(tableCtx.view, {
1719
+ ...ownerOpts,
1720
+ mode: strict ? 'strict' : 'default',
1721
+ policyFound: tableCtx.policyFound,
1722
+ desyncFindings: desyncEval.findings,
1723
+ unverifiedDocsCount: desyncEval.unverifiedCount,
1724
+ unassignedJournal: journalRef !== undefined && !journalRef.designated && journalRef.knownCopies > 1,
1725
+ rowOriginLabels,
1726
+ writePolicy: { mode: writePolicy.mode, holder: writePolicy.holder },
1727
+ ...(captureView !== undefined ? { captureView } : {}),
1728
+ header: {
1729
+ ...(journalRef?.label !== undefined ? { label: journalRef.label } : {}),
1730
+ resolution: journalRef?.resolution ?? 'dossier',
1731
+ localOnlyEventCount: journalRef?.localOnlyEventCount ?? 0,
1732
+ ...(tableCtx.lastEventAt !== undefined ? { lastEventAt: tableCtx.lastEventAt } : {}),
1733
+ },
1734
+ });
1735
+ io.out(renderQualifiedOwnerTable(qualified, format));
1736
+ return 0;
1737
+ }
1314
1738
  if (inline) {
1315
1739
  io.out(reportInline(reader, options, width === undefined ? {} : { width }, nowArg, period));
1316
1740
  }
@@ -1649,7 +2073,9 @@ function cmdValidate(args, ctx, noStore = false) {
1649
2073
  return 0;
1650
2074
  }
1651
2075
  const integrity = validate(events, readHead(ctx.eventsPath));
1652
- const desync = desyncFindings(new Track(s).state(), io.cwd);
2076
+ const trackDir = dirname(ctx.eventsPath);
2077
+ const journalFolder = basename(trackDir) === '.track' ? dirname(trackDir) : trackDir;
2078
+ const desync = desyncFindings(new Track(s).state(), journalFolder, { env: io.env ?? process.env });
1653
2079
  const findings = [...integrity.findings.map((f) => ({ ...f })), ...desync];
1654
2080
  if (findings.length === 0) {
1655
2081
  io.out(`OK: ${events.length} events, integrity + desync clean\n`);