@sentropic/track 0.98.11-rc.8 → 0.98.11
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.
- package/README.md +22 -0
- package/dist/adopt/apply.d.ts +30 -0
- package/dist/adopt/apply.d.ts.map +1 -0
- package/dist/adopt/apply.js +573 -0
- package/dist/adopt/apply.js.map +1 -0
- package/dist/adopt/plan.d.ts +63 -0
- package/dist/adopt/plan.d.ts.map +1 -0
- package/dist/adopt/plan.js +320 -0
- package/dist/adopt/plan.js.map +1 -0
- package/dist/capture/cli.d.ts +5 -0
- package/dist/capture/cli.d.ts.map +1 -0
- package/dist/capture/cli.js +532 -0
- package/dist/capture/cli.js.map +1 -0
- package/dist/capture/index.d.ts +8 -0
- package/dist/capture/index.d.ts.map +1 -0
- package/dist/capture/index.js +8 -0
- package/dist/capture/index.js.map +1 -0
- package/dist/capture/inscribe.d.ts +64 -0
- package/dist/capture/inscribe.d.ts.map +1 -0
- package/dist/capture/inscribe.js +407 -0
- package/dist/capture/inscribe.js.map +1 -0
- package/dist/capture/markers.d.ts +10 -0
- package/dist/capture/markers.d.ts.map +1 -0
- package/dist/capture/markers.js +26 -0
- package/dist/capture/markers.js.map +1 -0
- package/dist/capture/queue.d.ts +131 -0
- package/dist/capture/queue.d.ts.map +1 -0
- package/dist/capture/queue.js +422 -0
- package/dist/capture/queue.js.map +1 -0
- package/dist/capture/reader.d.ts +42 -0
- package/dist/capture/reader.d.ts.map +1 -0
- package/dist/capture/reader.js +72 -0
- package/dist/capture/reader.js.map +1 -0
- package/dist/capture/registry.d.ts +42 -0
- package/dist/capture/registry.d.ts.map +1 -0
- package/dist/capture/registry.js +141 -0
- package/dist/capture/registry.js.map +1 -0
- package/dist/capture/secrets.d.ts +30 -0
- package/dist/capture/secrets.d.ts.map +1 -0
- package/dist/capture/secrets.js +145 -0
- package/dist/capture/secrets.js.map +1 -0
- package/dist/cli/adopt.d.ts +10 -0
- package/dist/cli/adopt.d.ts.map +1 -0
- package/dist/cli/adopt.js +151 -0
- package/dist/cli/adopt.js.map +1 -0
- package/dist/cli/desync.d.ts +24 -4
- package/dist/cli/desync.d.ts.map +1 -1
- package/dist/cli/desync.js +86 -22
- package/dist/cli/desync.js.map +1 -1
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +271 -18
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/journal-reference.d.ts +34 -3
- package/dist/cli/journal-reference.d.ts.map +1 -1
- package/dist/cli/journal-reference.js +314 -77
- package/dist/cli/journal-reference.js.map +1 -1
- package/dist/cli/journal.d.ts +12 -0
- package/dist/cli/journal.d.ts.map +1 -0
- package/dist/cli/journal.js +302 -0
- package/dist/cli/journal.js.map +1 -0
- package/dist/cli/restructure-apply.d.ts +3 -0
- package/dist/cli/restructure-apply.d.ts.map +1 -1
- package/dist/cli/restructure-apply.js +5 -1
- package/dist/cli/restructure-apply.js.map +1 -1
- package/dist/events/store.d.ts +5 -1
- package/dist/events/store.d.ts.map +1 -1
- package/dist/events/store.js +8 -1
- package/dist/events/store.js.map +1 -1
- package/dist/events/types.d.ts +8 -3
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +7 -0
- package/dist/events/types.js.map +1 -1
- package/dist/focus-vendor/artifact/check.d.ts +73 -0
- package/dist/focus-vendor/artifact/check.d.ts.map +1 -0
- package/dist/focus-vendor/artifact/check.js +148 -0
- package/dist/focus-vendor/artifact/check.js.map +1 -0
- package/dist/focus-vendor/artifact/index.d.ts +3 -0
- package/dist/focus-vendor/artifact/index.d.ts.map +1 -0
- package/dist/focus-vendor/artifact/index.js +3 -0
- package/dist/focus-vendor/artifact/index.js.map +1 -0
- package/dist/focus-vendor/artifact/manifest.d.ts +74 -0
- package/dist/focus-vendor/artifact/manifest.d.ts.map +1 -0
- package/dist/focus-vendor/artifact/manifest.js +485 -0
- package/dist/focus-vendor/artifact/manifest.js.map +1 -0
- package/dist/focus-vendor/cli/index.d.ts +1 -1
- package/dist/focus-vendor/cli/index.d.ts.map +1 -1
- package/dist/focus-vendor/cli/index.js +38 -3
- package/dist/focus-vendor/cli/index.js.map +1 -1
- package/dist/focus-vendor/index.d.ts +3 -1
- package/dist/focus-vendor/index.js +5 -1
- package/dist/focus-vendor/index.js.map +1 -1
- package/dist/focus-vendor/model.d.ts +13 -0
- package/dist/focus-vendor/model.d.ts.map +1 -1
- package/dist/focus-vendor/model.js +13 -0
- package/dist/focus-vendor/model.js.map +1 -1
- package/dist/focus-vendor/registry/definitions.js +7 -7
- package/dist/focus-vendor/registry/definitions.js.map +1 -1
- package/dist/focus-vendor/registry/entries.v1.json +14 -14
- package/dist/focus-vendor/render/html.d.ts +1 -1
- package/dist/focus-vendor/render/html.d.ts.map +1 -1
- package/dist/focus-vendor/render/html.js +8 -2
- package/dist/focus-vendor/render/html.js.map +1 -1
- package/dist/focus-vendor/render/theme.d.ts +17 -0
- package/dist/focus-vendor/render/theme.d.ts.map +1 -0
- package/dist/focus-vendor/render/theme.js +654 -0
- package/dist/focus-vendor/render/theme.js.map +1 -0
- package/dist/focus-vendor/validation/index.d.ts +6 -0
- package/dist/focus-vendor/validation/index.d.ts.map +1 -1
- package/dist/focus-vendor/validation/index.js +14 -1
- package/dist/focus-vendor/validation/index.js.map +1 -1
- package/dist/focus-vendor/validation/readability.d.ts.map +1 -1
- package/dist/focus-vendor/validation/readability.js +25 -25
- package/dist/focus-vendor/validation/readability.js.map +1 -1
- package/dist/fs-private.d.ts +37 -0
- package/dist/fs-private.d.ts.map +1 -0
- package/dist/fs-private.js +224 -0
- package/dist/fs-private.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/journal/identity.d.ts +37 -0
- package/dist/journal/identity.d.ts.map +1 -0
- package/dist/journal/identity.js +134 -0
- package/dist/journal/identity.js.map +1 -0
- package/dist/journal/index-store.d.ts +56 -0
- package/dist/journal/index-store.d.ts.map +1 -0
- package/dist/journal/index-store.js +167 -0
- package/dist/journal/index-store.js.map +1 -0
- package/dist/journal/index.d.ts +4 -0
- package/dist/journal/index.d.ts.map +1 -0
- package/dist/journal/index.js +4 -0
- package/dist/journal/index.js.map +1 -0
- package/dist/journal/inscription.d.ts +28 -0
- package/dist/journal/inscription.d.ts.map +1 -0
- package/dist/journal/inscription.js +93 -0
- package/dist/journal/inscription.js.map +1 -0
- package/dist/model/decision.d.ts +7 -0
- package/dist/model/decision.d.ts.map +1 -1
- package/dist/model/decision.js +4 -0
- package/dist/model/decision.js.map +1 -1
- package/dist/model/demand.d.ts +19 -1
- package/dist/model/demand.d.ts.map +1 -1
- package/dist/model/demand.js +4 -0
- package/dist/model/demand.js.map +1 -1
- package/dist/read/commands.d.ts +2 -0
- package/dist/read/commands.d.ts.map +1 -1
- package/dist/read/commands.js +3 -1
- package/dist/read/commands.js.map +1 -1
- package/dist/report/owner-table-qualified.d.ts +39 -2
- package/dist/report/owner-table-qualified.d.ts.map +1 -1
- package/dist/report/owner-table-qualified.js +147 -19
- package/dist/report/owner-table-qualified.js.map +1 -1
- package/dist/report/owner-table-scope.d.ts +13 -1
- package/dist/report/owner-table-scope.d.ts.map +1 -1
- package/dist/report/owner-table-scope.js +35 -6
- package/dist/report/owner-table-scope.js.map +1 -1
- package/dist/report/owner-table-strings.d.ts +47 -3
- package/dist/report/owner-table-strings.d.ts.map +1 -1
- package/dist/report/owner-table-strings.js +100 -20
- package/dist/report/owner-table-strings.js.map +1 -1
- package/dist/report/owner-table.d.ts +23 -3
- package/dist/report/owner-table.d.ts.map +1 -1
- package/dist/report/owner-table.js +166 -24
- package/dist/report/owner-table.js.map +1 -1
- package/dist/state/fold.d.ts.map +1 -1
- package/dist/state/fold.js +55 -0
- package/dist/state/fold.js.map +1 -1
- package/dist/track.d.ts +80 -7
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +470 -24
- package/dist/track.js.map +1 -1
- package/dist/write-policy.d.ts +83 -0
- package/dist/write-policy.d.ts.map +1 -0
- package/dist/write-policy.js +290 -0
- package/dist/write-policy.js.map +1 -0
- package/package.json +1 -1
- package/skills/present-decision/SKILL.md +24 -25
- package/skills/present-decision/assets/dossier-template.md +2 -3
- package/skills/present-decision/assets/self-audit.md +11 -10
package/dist/cli/desync.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { isAbsolute, join } from 'node:path';
|
|
2
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
3
|
+
import { canonicalPath, isInsideDir, isJournalIdentity, tmpCeilingFor } from '../journal/identity.js';
|
|
4
|
+
import { readJournalIndex } from '../journal/index-store.js';
|
|
5
|
+
import { trackStateHome } from '../state-home.js';
|
|
3
6
|
/**
|
|
4
7
|
* Decide whether an item `body` is a markdown *file reference* (SPEC §4 round-trip). Returns the
|
|
5
8
|
* resolved path plus whether it exists on disk, or `null` for everything that is NOT a reference —
|
|
@@ -21,17 +24,6 @@ import { isAbsolute, join } from 'node:path';
|
|
|
21
24
|
* interior whitespace and is not a path token;
|
|
22
25
|
* - it contains no `:` — a glued prose label ("Ref:docs/x.md", "See:docs/x.md") is prose,
|
|
23
26
|
* not a clean path (`:` is not used in this repo's paths).
|
|
24
|
-
*
|
|
25
|
-
* POLICY — ESCALATED to the conductor (two intentional, reversible defaults):
|
|
26
|
-
* (a) A MISSING path that contains whitespace (e.g. `docs/Getting Started.md`) is skipped as
|
|
27
|
-
* prose. This is IRREDUCIBLE: a spaced path is character-for-character indistinguishable from
|
|
28
|
-
* a spaced prose body that ends in a "…/foo.md" citation (both have whitespace + `/` + `.md`),
|
|
29
|
-
* so flagging the former necessarily re-flags the latter — i.e. re-opens the reported bug. The
|
|
30
|
-
* repo's spec-file convention uses hyphenated, space-free names, so precision-first is safe
|
|
31
|
-
* here today. If spaced spec filenames are ever adopted, relax the `\s` rule below (one line)
|
|
32
|
-
* and accept that prose citations will desync again.
|
|
33
|
-
* (b) A MISSING bare name (no `/`) is not validated, so `.md` domains/emails never desync. A bare
|
|
34
|
-
* spec is validated only once it exists (rule 1).
|
|
35
27
|
*/
|
|
36
28
|
function resolveMarkdownRef(body, cwd) {
|
|
37
29
|
if (!body.endsWith('.md'))
|
|
@@ -47,21 +39,85 @@ function resolveMarkdownRef(body, cwd) {
|
|
|
47
39
|
return null; // glued prose label (Ref:/See:/Spec:) — not a clean path
|
|
48
40
|
return { path, exists: false }; // a clean, nested, missing path: a genuine desync
|
|
49
41
|
}
|
|
42
|
+
/** Syntactic check for a relative `.md` document reference when its project folder is unknown. */
|
|
43
|
+
function isRelativeMarkdownRefCandidate(body) {
|
|
44
|
+
if (!body.endsWith('.md'))
|
|
45
|
+
return false;
|
|
46
|
+
if (/\s/.test(body))
|
|
47
|
+
return false;
|
|
48
|
+
if (body.includes(':'))
|
|
49
|
+
return false;
|
|
50
|
+
if (body.includes('@'))
|
|
51
|
+
return false;
|
|
52
|
+
return body.includes('/') || /^[A-Za-z0-9._-]+\.md$/u.test(body);
|
|
53
|
+
}
|
|
54
|
+
function loadIndexWithCeiling(cwd, options) {
|
|
55
|
+
if (options.index !== undefined)
|
|
56
|
+
return options.index;
|
|
57
|
+
const procEnv = options.env ?? process.env;
|
|
58
|
+
const ceiling = tmpCeilingFor(cwd);
|
|
59
|
+
if (ceiling !== undefined) {
|
|
60
|
+
const stateHome = trackStateHome(procEnv);
|
|
61
|
+
const absState = resolve(stateHome);
|
|
62
|
+
const absCeiling = resolve(ceiling);
|
|
63
|
+
const realCeiling = canonicalPath(ceiling);
|
|
64
|
+
if (!isInsideDir(absState, absCeiling) && !isInsideDir(canonicalPath(stateHome), realCeiling)) {
|
|
65
|
+
return { version: 1, identities: {} };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return readJournalIndex(procEnv);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return { version: 1, identities: {} };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
50
75
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* references and are skipped. Each finding carries a `hint` — a suggested fix the human/agent may
|
|
56
|
-
* apply (track never does).
|
|
76
|
+
* Evaluate document desynchronisation findings and unverified document references (spec DS-7,
|
|
77
|
+
* lot 4a). Items carrying a project/folder identity (`ws:` / `dir:`) resolve against the `root`
|
|
78
|
+
* recorded in `journals.json`; an identity with no recorded root is not checked and is counted
|
|
79
|
+
* under `unverifiedCount`. Legacy items in an in-repo journal keep lot 1's rule: `cwd`.
|
|
57
80
|
*/
|
|
58
|
-
export function
|
|
81
|
+
export function evaluateDesync(state, cwd, options = {}) {
|
|
59
82
|
const findings = [];
|
|
83
|
+
let unverifiedCount = 0;
|
|
84
|
+
let index;
|
|
60
85
|
for (const item of state.items.values()) {
|
|
61
86
|
const ref = item.body?.trim();
|
|
62
|
-
if (ref === undefined)
|
|
87
|
+
if (ref === undefined || !ref.endsWith('.md'))
|
|
63
88
|
continue;
|
|
64
|
-
|
|
89
|
+
let baseDir;
|
|
90
|
+
if (isAbsolute(ref)) {
|
|
91
|
+
baseDir = cwd;
|
|
92
|
+
}
|
|
93
|
+
else if (isJournalIdentity(item.workspace)) {
|
|
94
|
+
if (index === undefined)
|
|
95
|
+
index = loadIndexWithCeiling(cwd, options);
|
|
96
|
+
const recordedRoot = index.identities[item.workspace]?.root;
|
|
97
|
+
if (recordedRoot !== undefined && recordedRoot.trim() !== '') {
|
|
98
|
+
baseDir = recordedRoot;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (isRelativeMarkdownRefCandidate(ref))
|
|
102
|
+
unverifiedCount++;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (options.offRepo === true) {
|
|
107
|
+
if (options.fallbackRoot !== undefined && options.fallbackRoot !== null && options.fallbackRoot.trim() !== '') {
|
|
108
|
+
baseDir = options.fallbackRoot;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (isRelativeMarkdownRefCandidate(ref))
|
|
112
|
+
unverifiedCount++;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Journal inside a repository whose items carry no identity: keep lot 1 rule.
|
|
118
|
+
baseDir = cwd;
|
|
119
|
+
}
|
|
120
|
+
const resolved = resolveMarkdownRef(ref, baseDir);
|
|
65
121
|
if (resolved === null)
|
|
66
122
|
continue;
|
|
67
123
|
if (!resolved.exists) {
|
|
@@ -92,6 +148,14 @@ export function desyncFindings(state, cwd) {
|
|
|
92
148
|
});
|
|
93
149
|
}
|
|
94
150
|
}
|
|
95
|
-
return findings;
|
|
151
|
+
return { findings, unverifiedCount };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* SPEC §4 round-trip / desync rule: when an Item's `body` is a markdown file reference (see
|
|
155
|
+
* {@link resolveMarkdownRef}), that file MUST exist and its H1 title MUST match the Item title. A
|
|
156
|
+
* missing file or a title mismatch is a desync finding (MVP reports; it never auto-repairs).
|
|
157
|
+
*/
|
|
158
|
+
export function desyncFindings(state, cwd, options = {}) {
|
|
159
|
+
return evaluateDesync(state, cwd, options).findings;
|
|
96
160
|
}
|
|
97
161
|
//# sourceMappingURL=desync.js.map
|
package/dist/cli/desync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desync.js","sourceRoot":"","sources":["../../src/cli/desync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"desync.js","sourceRoot":"","sources":["../../src/cli/desync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,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,EAAE,oBAAoB,GAAG,WAAW,IAAI,CAAC,KAAK,GAAG;aAC9F,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAA;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAY,EACZ,GAAW,EACX,UAAmC,EAAE;IAErC,OAAO,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAA;AACrD,CAAC"}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface CliIO {
|
|
|
4
4
|
err: (s: string) => void;
|
|
5
5
|
/** Optional process environment injection for adapter/config isolation in embedders and tests. */
|
|
6
6
|
env?: NodeJS.ProcessEnv;
|
|
7
|
+
/** Optional stdin content injection for `--stdin` commands in tests. */
|
|
8
|
+
stdin?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare function runCli(rawArgv: string[], io: CliIO): number | Promise<number>;
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AA2DA,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACxB,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACxB,kGAAkG;IAClG,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAmfD,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4N7E"}
|
package/dist/cli/index.js
CHANGED
|
@@ -6,10 +6,18 @@ 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';
|
|
11
15
|
import { resolveJournalOfReference } from './journal-reference.js';
|
|
12
|
-
import {
|
|
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';
|
|
13
21
|
import { assertItemLink, DomainError } from '../model/item.js';
|
|
14
22
|
import { displayText, formatRows } from '../report/format.js';
|
|
15
23
|
import { Track } from '../track.js';
|
|
@@ -17,19 +25,24 @@ import { BLOCKER_KINDS, BLOCKER_SCOPES, DECISION_KINDS, DISPOSITIONS, EVIDENCE_K
|
|
|
17
25
|
import { ingest } from '../ingest/ingest.js';
|
|
18
26
|
import { applyRestructurePlan } from './restructure-apply.js';
|
|
19
27
|
import { TrackReader } from '../read/contract.js';
|
|
20
|
-
import {
|
|
28
|
+
import { queryText, reportInline, reportText, resolveHandle, statusText } from '../read/commands.js';
|
|
21
29
|
import { auditOwnerTable, formatOwnerTableNoJournalMessage } from '../report/owner-table.js';
|
|
30
|
+
import { buildQualifiedOwnerTable, renderQualifiedOwnerTable } from '../report/owner-table-qualified.js';
|
|
22
31
|
import { STATUS_LEVELS } from '../report/status-by-level.js';
|
|
23
32
|
import { renderSnapshot } from '../report/snapshot.js';
|
|
24
33
|
import { VERSION } from '../version.js';
|
|
25
34
|
import { durableWorkspaceId } from '../workspace-id.js';
|
|
26
|
-
import { desyncFindings } from './desync.js';
|
|
35
|
+
import { desyncFindings, evaluateDesync } from './desync.js';
|
|
27
36
|
const USAGE = `usage: track <command>
|
|
28
37
|
--help | help
|
|
29
38
|
global read/store override: --track-dir <directory-containing-events.jsonl> (or TRACK_DIR)
|
|
30
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
|
|
31
42
|
--version | -v
|
|
32
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 ...
|
|
33
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)
|
|
34
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)
|
|
35
48
|
item reparent <itemId> [--parent <pid>] [--detach]
|
|
@@ -44,8 +57,14 @@ const USAGE = `usage: track <command>
|
|
|
44
57
|
item assign-code <itemId> --code <c> [--client-token <t>]
|
|
45
58
|
item show <itemId>
|
|
46
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>]
|
|
47
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>]
|
|
48
66
|
decision ls [--workspace <w>] [--outcome <pending|go|no-go|deferred>] [--format json|text|md] [--commit <sha>]
|
|
67
|
+
decision number (<decisionId> | --all-unnumbered)
|
|
49
68
|
decision outcome <decisionId> deferred
|
|
50
69
|
decision select <decisionId> <optionId> [--outcome <go|no-go>]
|
|
51
70
|
decision dossier <decisionId> [--context <c>] [--options-json <json> --recommendation <optionId> --rationale <r>]
|
|
@@ -73,6 +92,8 @@ const USAGE = `usage: track <command>
|
|
|
73
92
|
audit [--format json|text]
|
|
74
93
|
focus <decision-id> --workspace <w> [--format terminal|md|html|json] [--baseline-commit <sha>]
|
|
75
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>]
|
|
76
97
|
restructure apply --plan <plan.json>
|
|
77
98
|
ingest <file.jsonl> --workspace <w>
|
|
78
99
|
install-skills --host <claude|codex|gemini|agy|all> [--scope user|project] [--force]
|
|
@@ -97,7 +118,10 @@ function eventsPathOf(trackDir) {
|
|
|
97
118
|
return join(trackDir, 'events.jsonl');
|
|
98
119
|
}
|
|
99
120
|
function store(ctx) {
|
|
100
|
-
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
|
+
});
|
|
101
125
|
}
|
|
102
126
|
function gitHead(cwd) {
|
|
103
127
|
try {
|
|
@@ -424,6 +448,28 @@ function extractTrackDirFlag(argv) {
|
|
|
424
448
|
}
|
|
425
449
|
return trackDirFlag !== undefined ? { trackDirFlag, rest } : { rest };
|
|
426
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
|
+
}
|
|
427
473
|
/**
|
|
428
474
|
* Request-lifecycle Part 1 (Lot L2) — pull a REPEATABLE value flag's occurrences out of argv.
|
|
429
475
|
* `parseFlags` keeps only the LAST occurrence of a repeated key, so `item new --link a --link b`
|
|
@@ -470,7 +516,19 @@ Rebind the exact rendering context with --scope/--period/--since/--until/--now/-
|
|
|
470
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.
|
|
471
517
|
`;
|
|
472
518
|
export function runCli(rawArgv, io) {
|
|
473
|
-
const { trackDirFlag, rest:
|
|
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
|
+
}
|
|
474
532
|
const cmd = argv[0];
|
|
475
533
|
const rest = argv.slice(1);
|
|
476
534
|
if (cmd === '--help' || cmd === 'help' || cmd === undefined) {
|
|
@@ -481,7 +539,7 @@ export function runCli(rawArgv, io) {
|
|
|
481
539
|
io.out(REPORT_USAGE);
|
|
482
540
|
return 0;
|
|
483
541
|
}
|
|
484
|
-
const trackDirEnv = process.env['TRACK_DIR'];
|
|
542
|
+
const trackDirEnv = (io.env ?? process.env)['TRACK_DIR'];
|
|
485
543
|
const resolveOpts = {
|
|
486
544
|
cwd: io.cwd,
|
|
487
545
|
...(trackDirFlag !== undefined ? { flag: trackDirFlag } : {}),
|
|
@@ -499,8 +557,26 @@ export function runCli(rawArgv, io) {
|
|
|
499
557
|
return cmdDecisionLs(rest, {
|
|
500
558
|
io,
|
|
501
559
|
eventsPath: trackDir !== null ? eventsPathOf(trackDir) : eventsPathOf(join(resolve(io.cwd), '.track')),
|
|
560
|
+
writerTokenFile,
|
|
502
561
|
});
|
|
503
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
|
+
}
|
|
504
580
|
switch (cmd) {
|
|
505
581
|
case '--version':
|
|
506
582
|
case '-v':
|
|
@@ -528,13 +604,21 @@ export function runCli(rawArgv, io) {
|
|
|
528
604
|
// PATHS. Git-free AND store-free: it never resolves a `.track` dir (the paths are supplied),
|
|
529
605
|
// so it dispatches here alongside install-skills/workspace-id, before store resolution.
|
|
530
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);
|
|
531
615
|
// READ commands SERVE-EMPTY (launch/serve alignment): they resolve via the non-throwing
|
|
532
616
|
// `resolveTrackDirOrNull`, so an unadopted repo yields rc=0 + an honest-empty view + a stderr
|
|
533
617
|
// `track init` hint, never a boot crash. NEVER creates. A bad EXPLICIT override still throws
|
|
534
618
|
// (user error → the outer catch → rc=1). The reader over a nonexistent log already reads empty.
|
|
535
619
|
case 'report': {
|
|
536
620
|
if (rest.includes('--owner-table')) {
|
|
537
|
-
const ref = resolveJournalOfReference(resolveOpts);
|
|
621
|
+
const ref = resolveJournalOfReference({ ...resolveOpts, processEnv: io.env ?? process.env });
|
|
538
622
|
const ctx = {
|
|
539
623
|
io,
|
|
540
624
|
eventsPath: ref.trackDir !== null
|
|
@@ -607,7 +691,7 @@ export function runCli(rawArgv, io) {
|
|
|
607
691
|
case 'restructure':
|
|
608
692
|
case 'ingest':
|
|
609
693
|
case 'reseal': {
|
|
610
|
-
const ctx = { io, eventsPath: eventsPathOf(resolveTrackDir(resolveOpts)) };
|
|
694
|
+
const ctx = { io, eventsPath: eventsPathOf(resolveTrackDir(resolveOpts)), writerTokenFile };
|
|
611
695
|
switch (cmd) {
|
|
612
696
|
case 'item':
|
|
613
697
|
return cmdItem(rest, ctx);
|
|
@@ -644,7 +728,8 @@ export function runCli(rawArgv, io) {
|
|
|
644
728
|
}
|
|
645
729
|
}
|
|
646
730
|
catch (error) {
|
|
647
|
-
|
|
731
|
+
const rawMsg = error instanceof Error ? error.message : String(error);
|
|
732
|
+
io.err(`error: ${maskSecrets(rawMsg).text}\n`);
|
|
648
733
|
return 1;
|
|
649
734
|
}
|
|
650
735
|
}
|
|
@@ -979,10 +1064,42 @@ function cmdRestructure(args, ctx) {
|
|
|
979
1064
|
catch {
|
|
980
1065
|
throw new DomainError('restructure apply: --plan must be a valid JSON plan file');
|
|
981
1066
|
}
|
|
982
|
-
const res = applyRestructurePlan(ctx.eventsPath, plan, {
|
|
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
|
+
});
|
|
983
1072
|
io.out(`applied ${res.applied} edge(s) of ${res.edges} (${res.alreadyApplied} already applied) [plan ${res.planHash}]\n`);
|
|
984
1073
|
return 0;
|
|
985
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
|
+
}
|
|
986
1103
|
function cmdDecision(args, ctx) {
|
|
987
1104
|
const { io } = ctx;
|
|
988
1105
|
const sub = args[0];
|
|
@@ -1080,7 +1197,7 @@ function cmdDecision(args, ctx) {
|
|
|
1080
1197
|
io.out('ok\n');
|
|
1081
1198
|
return 0;
|
|
1082
1199
|
}
|
|
1083
|
-
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');
|
|
1084
1201
|
return 2;
|
|
1085
1202
|
}
|
|
1086
1203
|
function cmdBlocker(args, ctx) {
|
|
@@ -1219,6 +1336,58 @@ function cmdPriority(args, ctx) {
|
|
|
1219
1336
|
io.err('usage: track priority assess <itemId> --ubv --tc --rr --js\n');
|
|
1220
1337
|
return 2;
|
|
1221
1338
|
}
|
|
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
|
+
}
|
|
1222
1391
|
function cmdDemand(args, ctx) {
|
|
1223
1392
|
const { io } = ctx;
|
|
1224
1393
|
const sub = args[0];
|
|
@@ -1289,7 +1458,7 @@ function cmdDemand(args, ctx) {
|
|
|
1289
1458
|
io.out('ok\n');
|
|
1290
1459
|
return 0;
|
|
1291
1460
|
}
|
|
1292
|
-
io.err('usage: track demand <number|summary|archive|eta>
|
|
1461
|
+
io.err('usage: track demand <raise|number|summary|archive|eta> ...\n');
|
|
1293
1462
|
return 2;
|
|
1294
1463
|
}
|
|
1295
1464
|
function cmdReport(args, ctx, noTrackDir = false, journalRef) {
|
|
@@ -1448,12 +1617,56 @@ function cmdReport(args, ctx, noTrackDir = false, journalRef) {
|
|
|
1448
1617
|
}
|
|
1449
1618
|
const reader = new TrackReader(ctx.eventsPath);
|
|
1450
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;
|
|
1451
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
|
+
}
|
|
1452
1664
|
throw new DomainError(formatOwnerTableNoJournalMessage(io.cwd, journalRef?.reason));
|
|
1453
1665
|
}
|
|
1454
1666
|
const resolvedPolicy = resolveOwnerTablePolicyFile({
|
|
1455
1667
|
flagPolicyPath: opt(flags, 'policy'),
|
|
1456
1668
|
trackDir: dirname(ctx.eventsPath),
|
|
1669
|
+
env: procEnv,
|
|
1457
1670
|
});
|
|
1458
1671
|
const ownerOpts = {
|
|
1459
1672
|
baselineCommit: options.baselineCommit,
|
|
@@ -1464,22 +1677,62 @@ function cmdReport(args, ctx, noTrackDir = false, journalRef) {
|
|
|
1464
1677
|
statePolicyPath: resolvedPolicy.statePolicyPath,
|
|
1465
1678
|
...(resolvedPolicy.policyPath !== undefined ? { policyPath: resolvedPolicy.policyPath } : {}),
|
|
1466
1679
|
};
|
|
1680
|
+
const tableCtx = reader.ownerTableContext(ownerOpts);
|
|
1467
1681
|
if (strict) {
|
|
1468
|
-
const
|
|
1469
|
-
const audit = auditOwnerTable(view, ownerOpts);
|
|
1682
|
+
const audit = auditOwnerTable(tableCtx.view, ownerOpts);
|
|
1470
1683
|
for (const notice of audit.notices ?? []) {
|
|
1471
1684
|
io.err(`Notice: ${notice}\n`);
|
|
1472
1685
|
}
|
|
1473
1686
|
}
|
|
1474
|
-
|
|
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, {
|
|
1475
1719
|
...ownerOpts,
|
|
1476
|
-
strict,
|
|
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 } : {}),
|
|
1477
1728
|
header: {
|
|
1478
1729
|
...(journalRef?.label !== undefined ? { label: journalRef.label } : {}),
|
|
1479
1730
|
resolution: journalRef?.resolution ?? 'dossier',
|
|
1480
1731
|
localOnlyEventCount: journalRef?.localOnlyEventCount ?? 0,
|
|
1732
|
+
...(tableCtx.lastEventAt !== undefined ? { lastEventAt: tableCtx.lastEventAt } : {}),
|
|
1481
1733
|
},
|
|
1482
|
-
}
|
|
1734
|
+
});
|
|
1735
|
+
io.out(renderQualifiedOwnerTable(qualified, format));
|
|
1483
1736
|
return 0;
|
|
1484
1737
|
}
|
|
1485
1738
|
if (inline) {
|
|
@@ -1822,7 +2075,7 @@ function cmdValidate(args, ctx, noStore = false) {
|
|
|
1822
2075
|
const integrity = validate(events, readHead(ctx.eventsPath));
|
|
1823
2076
|
const trackDir = dirname(ctx.eventsPath);
|
|
1824
2077
|
const journalFolder = basename(trackDir) === '.track' ? dirname(trackDir) : trackDir;
|
|
1825
|
-
const desync = desyncFindings(new Track(s).state(), journalFolder);
|
|
2078
|
+
const desync = desyncFindings(new Track(s).state(), journalFolder, { env: io.env ?? process.env });
|
|
1826
2079
|
const findings = [...integrity.findings.map((f) => ({ ...f })), ...desync];
|
|
1827
2080
|
if (findings.length === 0) {
|
|
1828
2081
|
io.out(`OK: ${events.length} events, integrity + desync clean\n`);
|