agentic-workflow-manager 9.7.0 → 9.8.0

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 (114) hide show
  1. package/README.md +5 -1
  2. package/dist/src/commands/doctor.js +4 -2
  3. package/dist/src/commands/export.js +3 -0
  4. package/dist/src/commands/init.js +10 -2
  5. package/dist/src/commands/job/exec-wrapper.js +53 -3
  6. package/dist/src/commands/plan/index.js +124 -6
  7. package/dist/src/commands/registry/add.js +2 -2
  8. package/dist/src/commands/registry/index.js +7 -5
  9. package/dist/src/commands/registry/install-bundles.js +4 -4
  10. package/dist/src/commands/registry/status.js +4 -4
  11. package/dist/src/commands/sensors/bootstrap.js +36 -5
  12. package/dist/src/commands/sensors/compatibility/contract.js +19 -4
  13. package/dist/src/commands/sensors/compatibility/discovery.js +23 -3
  14. package/dist/src/commands/sensors/compatibility/live.js +18 -1
  15. package/dist/src/commands/sensors/compatibility/probe.js +8 -2
  16. package/dist/src/commands/sensors/compatibility/resolve.js +5 -2
  17. package/dist/src/commands/sensors/coverage/evidence.js +19 -10
  18. package/dist/src/commands/sensors/coverage/index.js +11 -2
  19. package/dist/src/commands/sensors/coverage/resolve.js +10 -0
  20. package/dist/src/commands/sensors/exec.js +16 -1
  21. package/dist/src/commands/sensors/migrate.js +62 -2
  22. package/dist/src/commands/sensors/prepare.js +2 -0
  23. package/dist/src/commands/sensors/result.js +2 -0
  24. package/dist/src/commands/sensors/run.js +64 -1
  25. package/dist/src/commands/sensors/status.js +6 -4
  26. package/dist/src/commands/sync.js +2 -1
  27. package/dist/src/commands/update.js +3 -1
  28. package/dist/src/commands/watch/archive-unused.js +138 -0
  29. package/dist/src/commands/watch/generations.js +32 -9
  30. package/dist/src/commands/watch/index.js +108 -2
  31. package/dist/src/commands/watch/init.js +149 -18
  32. package/dist/src/commands/watch/supervisor.js +167 -13
  33. package/dist/src/commands/watch/teardown-driver.js +13 -13
  34. package/dist/src/commands/watch/track-state.js +59 -0
  35. package/dist/src/commands/watch/tracks.js +38 -102
  36. package/dist/src/core/admission/index.js +181 -0
  37. package/dist/src/core/admission/registry-contracts.js +290 -0
  38. package/dist/src/core/bundle-install.js +2 -2
  39. package/dist/src/core/bundles.js +92 -19
  40. package/dist/src/core/diagnostics/context.js +1 -1
  41. package/dist/src/core/export/index.js +1 -1
  42. package/dist/src/core/export/resolve.js +2 -2
  43. package/dist/src/core/journal/fingerprint.js +35 -1
  44. package/dist/src/core/journal/paths.js +11 -0
  45. package/dist/src/core/journal/store.js +146 -4
  46. package/dist/src/core/journal/types.js +35 -1
  47. package/dist/src/core/migration/historical-provenance.js +18 -0
  48. package/dist/src/core/migration/index.js +322 -0
  49. package/dist/src/core/plan/identity.js +75 -0
  50. package/dist/src/core/plan/validate.js +178 -64
  51. package/dist/src/core/reconciliation.js +1 -1
  52. package/dist/src/index.js +46 -39
  53. package/dist/src/utils/grouping.js +1 -1
  54. package/dist/src/utils/registry-view.js +1 -1
  55. package/dist/tests/commands/bundle-diagnostics.test.js +145 -0
  56. package/dist/tests/commands/export.test.js +28 -2
  57. package/dist/tests/commands/job/exec-wrapper.test.js +16 -0
  58. package/dist/tests/commands/job/gate-reconcile.test.js +24 -10
  59. package/dist/tests/commands/multi-agent-targeting.test.js +1 -1
  60. package/dist/tests/commands/pin.test.js +23 -23
  61. package/dist/tests/commands/plan/index.test.js +630 -14
  62. package/dist/tests/commands/sensors/bootstrap.test.js +57 -4
  63. package/dist/tests/commands/sensors/compatibility/contract.test.js +21 -0
  64. package/dist/tests/commands/sensors/compatibility/discovery.test.js +19 -0
  65. package/dist/tests/commands/sensors/compatibility/probe.test.js +14 -1
  66. package/dist/tests/commands/sensors/compatibility/resolve.test.js +17 -0
  67. package/dist/tests/commands/sensors/coverage/evidence.test.js +51 -27
  68. package/dist/tests/commands/sensors/coverage/resolve.test.js +51 -0
  69. package/dist/tests/commands/sensors/exec.test.js +112 -0
  70. package/dist/tests/commands/sensors/run-changed.test.js +11 -0
  71. package/dist/tests/commands/sensors/run.test.js +15 -2
  72. package/dist/tests/commands/sensors/status.test.js +3 -3
  73. package/dist/tests/commands/watch/e2e-crash.test.js +126 -11
  74. package/dist/tests/commands/watch/generations.test.js +113 -4
  75. package/dist/tests/commands/watch/plan-lifecycle.test.js +263 -0
  76. package/dist/tests/commands/watch/supervisor-loop.test.js +247 -49
  77. package/dist/tests/commands/watch/track-finalize.test.js +20 -3
  78. package/dist/tests/commands/watch/track-freeze.test.js +43 -30
  79. package/dist/tests/commands/watch/track-state-dependency.test.js +15 -0
  80. package/dist/tests/commands/watch/watch-init.test.js +244 -0
  81. package/dist/tests/core/admission/index.test.js +87 -0
  82. package/dist/tests/core/bundle-install.test.js +36 -0
  83. package/dist/tests/core/bundles-multiroot.test.js +24 -2
  84. package/dist/tests/core/bundles-overrides.test.js +10 -7
  85. package/dist/tests/core/bundles.test.js +75 -6
  86. package/dist/tests/core/diagnostics/context.test.js +2 -2
  87. package/dist/tests/core/export/engine.test.js +1 -1
  88. package/dist/tests/core/export/resolve.test.js +1 -1
  89. package/dist/tests/core/init/mutation-targets.test.js +1 -1
  90. package/dist/tests/core/init/orchestrator.test.js +1 -1
  91. package/dist/tests/core/init/steps.test.js +1 -1
  92. package/dist/tests/core/journal/fingerprint.test.js +22 -0
  93. package/dist/tests/core/journal/store.test.js +53 -0
  94. package/dist/tests/core/journal/types.test.js +7 -0
  95. package/dist/tests/core/migration/facts.test.js +289 -0
  96. package/dist/tests/core/migration/historical-provenance.test.js +25 -0
  97. package/dist/tests/core/plan/validate.test.js +320 -6
  98. package/dist/tests/core/reconciliation.test.js +1 -1
  99. package/dist/tests/core/sync-profile-atomicity.test.js +1 -1
  100. package/dist/tests/integration/pack-e2e.test.js +4 -1
  101. package/dist/tests/integration/preflight-json-pipe.e2e.test.js +7 -3
  102. package/dist/tests/integration/sensor-bootstrap.e2e.test.js +37 -0
  103. package/dist/tests/integration/sensor-structured-run.e2e.test.js +12 -10
  104. package/dist/tests/providers/injection-config.test.js +14 -6
  105. package/dist/tests/structural/bundle-skill-reference-contract.test.js +56 -0
  106. package/dist/tests/structural/jest-environment-is-isolated.test.js +29 -24
  107. package/dist/tests/structural/native-release-artifacts.test.js +16 -0
  108. package/dist/tests/utils/grouping.test.js +2 -2
  109. package/dist/tests/utils/registry-view.test.js +7 -7
  110. package/package.json +2 -2
  111. package/prebuilds/darwin-arm64/secure_fs.node +0 -0
  112. package/prebuilds/darwin-x64/secure_fs.node +0 -0
  113. package/prebuilds/win32-arm64/secure_fs.node +0 -0
  114. package/prebuilds/win32-x64/secure_fs.node +0 -0
@@ -0,0 +1,289 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const child_process_1 = require("child_process");
10
+ const migration_1 = require("../../../src/core/migration");
11
+ const store_1 = require("../../../src/core/journal/store");
12
+ const fingerprint_1 = require("../../../src/core/journal/fingerprint");
13
+ describe('collectMigrationFacts', () => {
14
+ it.each([
15
+ ['https://sentinel-user:sentinel-password@github.com/Kodria/agentic-workflow/issues/126'],
16
+ ['https://github.com:443/Kodria/agentic-workflow/issues/126'],
17
+ ['https://github.com/Kodria/agentic-workflow/issues/126?secret=sentinel'],
18
+ ['https://github.com/Kodria/agentic-workflow/issues/126#sentinel'],
19
+ ['https://github.com/Kodria/agentic-workflow/issues/126\n'],
20
+ ['https://github.com/Kodria/agentic-workflow/issues/126', `https://github.com/Kodria/agentic-workflow/issues/${'1'.repeat(4096)}`],
21
+ Array(129).fill('https://github.com/Kodria/agentic-workflow/issues/126'),
22
+ ['https://github.com/Kodria/agentic-workflow/issues/126', 'https://github.com/Kodria/agentic-workflow/issues/148', 'https://sentinel:secret@github.com/Kodria/agentic-workflow/issues/149'],
23
+ ])('rejects unsafe or unbounded issue links before reading either collector root (%#)', (...links) => {
24
+ expect(() => (0, migration_1.collectMigrationFacts)('x.md', '/nonexistent-migration-root', links)).toThrow(/issue #126/);
25
+ expect(() => (0, migration_1.collectIssue148HistoricalFacts)('/nonexistent-migration-root', links)).toThrow(/issue #126/);
26
+ });
27
+ test('does not export a record-injection completion API', () => {
28
+ // The only public entrypoint derives evidence from the local journal.
29
+ expect(require('../../../src/core/migration').reconcileTaskEvidence).toBeUndefined();
30
+ });
31
+ it('does not certify a task from a Git commit without durable test and review evidence', () => {
32
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-'));
33
+ try {
34
+ fs_1.default.mkdirSync(path_1.default.join(root, 'docs', 'plans'), { recursive: true });
35
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), '### Task 1: historical\n');
36
+ (0, child_process_1.execFileSync)('git', ['init'], { cwd: root });
37
+ (0, child_process_1.execFileSync)('git', ['config', 'user.email', 'test@example.invalid'], { cwd: root });
38
+ (0, child_process_1.execFileSync)('git', ['config', 'user.name', 'Test'], { cwd: root });
39
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
40
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'historical task'], { cwd: root });
41
+ const report = (0, migration_1.collectMigrationFacts)('docs/plans/old.md', root, ['https://github.com/Kodria/agentic-workflow/issues/126']);
42
+ expect(report.state).toBe('planning-required');
43
+ expect(report.tasks).toEqual([{ id: '1', state: 'unstarted', missing: [] }]);
44
+ expect(report.facts.every(fact => /\/issues\/126$/.test(fact.issue126))).toBe(true);
45
+ }
46
+ finally {
47
+ fs_1.default.rmSync(root, { recursive: true, force: true });
48
+ }
49
+ });
50
+ it('rejects a task commit that omits a declared Files entry', () => {
51
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-files-'));
52
+ try {
53
+ fs_1.default.mkdirSync(path_1.default.join(root, 'docs', 'plans'), { recursive: true });
54
+ fs_1.default.writeFileSync(path_1.default.join(root, 'first.txt'), 'first');
55
+ fs_1.default.writeFileSync(path_1.default.join(root, 'second.txt'), 'second');
56
+ (0, child_process_1.execFileSync)('git', ['init', '-q', '-b', 'master'], { cwd: root });
57
+ (0, child_process_1.execFileSync)('git', ['config', 'user.email', 't@e.invalid'], { cwd: root });
58
+ (0, child_process_1.execFileSync)('git', ['config', 'user.name', 'T'], { cwd: root });
59
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
60
+ (0, child_process_1.execFileSync)('git', ['commit', '-qm', 'first'], { cwd: root });
61
+ fs_1.default.writeFileSync(path_1.default.join(root, 'second.txt'), 'second changed');
62
+ (0, child_process_1.execFileSync)('git', ['add', 'second.txt'], { cwd: root });
63
+ (0, child_process_1.execFileSync)('git', ['commit', '-qm', 'second'], { cwd: root });
64
+ const sha = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
65
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), `### Task 1: historical\nCommit: ${sha}\n**Files:**\n- Modify: \`first.txt\`\n- Modify: \`second.txt\`\n\n### Task 2: later\n`);
66
+ const planPath = 'docs/plans/old.md';
67
+ const digest = require('crypto').createHash('sha256').update(fs_1.default.readFileSync(path_1.default.join(root, planPath), 'utf8')).digest('hex');
68
+ (0, store_1.initBoundJournal)(root, 'master', { path: planPath, digest, schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' });
69
+ const state = (0, store_1.readJournal)(root, 'master').state;
70
+ state.tasks = [{ id: '1', title: 't', status: 'done', attempts: 1, verificationPlan: [{ id: 'test:1', kind: 'test' }, { id: 'sensor:1', kind: 'sensors' }], reviewObligations: [{ id: 'spec:1', taskId: '1', kind: 'spec', verdictId: 'v1' }, { id: 'quality:1', taskId: '1', kind: 'quality', verdictId: 'v2' }] }];
71
+ const job = (id) => ({ id, fingerprint: 'f', commandDigest: 'd', argv: ['node'], cwd: '.', paths: ['second.txt'], expandedPaths: ['second.txt'], executionState: 'exited', observationState: 'progressing', verdict: 'pass', phaseTimestamps: {}, satisfies: [id] });
72
+ state.jobs = { test: job('test:1'), sensor: job('sensor:1') };
73
+ state.verdicts = [{ id: 'v1', obligationId: 'spec:1', result: 'pass', detail: 'ok', receivedAt: '2026-09-15T01:00:00.000Z', fingerprint: 'f', argv: [], paths: [], cwd: '.' }, { id: 'v2', obligationId: 'quality:1', result: 'pass', detail: 'ok', receivedAt: '2026-09-15T01:00:00.000Z', fingerprint: 'f', argv: [], paths: [], cwd: '.' }];
74
+ (0, store_1.writeJournal)(root, 'master', state);
75
+ expect((0, migration_1.collectMigrationFacts)(planPath, root, ['https://github.com/Kodria/agentic-workflow/issues/126']).tasks[0]).toMatchObject({ state: 'pending', missing: expect.arrayContaining(['commit']) });
76
+ }
77
+ finally {
78
+ fs_1.default.rmSync(root, { recursive: true, force: true });
79
+ }
80
+ });
81
+ it('rejects material facts without the durable #126 link', () => {
82
+ expect(() => (0, migration_1.collectMigrationFacts)('x.md', process.cwd(), ['https://github.com/Kodria/agentic-workflow/issues/148'])).toThrow('issue #126');
83
+ });
84
+ it('rejects a plan reached through a parent symlink', () => {
85
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-link-'));
86
+ const outside = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-outside-'));
87
+ try {
88
+ fs_1.default.writeFileSync(path_1.default.join(outside, 'plan.md'), '### Task 1: x\n');
89
+ fs_1.default.symlinkSync(outside, path_1.default.join(root, 'docs'));
90
+ expect(() => (0, migration_1.collectMigrationFacts)('docs/plan.md', root, ['https://github.com/Kodria/agentic-workflow/issues/126'])).toThrow(/contained bounded regular file/);
91
+ }
92
+ finally {
93
+ fs_1.default.rmSync(root, { recursive: true, force: true });
94
+ fs_1.default.rmSync(outside, { recursive: true, force: true });
95
+ }
96
+ });
97
+ it.each(['current', 'combined-job', 'semantic-kind', 'spoofed-kind', 'content', 'deleted', 'index', 'head', 'argv', 'cwd', 'paths', 'binding', 'review-argv', 'empty-expansion', 'live-job'])('requires current schema-2 evidence (%s)', (change) => {
98
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-journal-'));
99
+ try {
100
+ fs_1.default.mkdirSync(path_1.default.join(root, 'docs', 'plans'), { recursive: true });
101
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), `### Task 1: historical\nCommit: ${'a'.repeat(40)}\n`);
102
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task.txt'), 'verified source');
103
+ (0, child_process_1.execFileSync)('git', ['init', '-q', '-b', 'master'], { cwd: root });
104
+ (0, child_process_1.execFileSync)('git', ['config', 'user.email', 't@e.invalid'], { cwd: root });
105
+ (0, child_process_1.execFileSync)('git', ['config', 'user.name', 'T'], { cwd: root });
106
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
107
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 't'], { cwd: root });
108
+ const sha = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
109
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), `### Task 1: historical\nCommit: ${sha}\nFiles:\n- task.txt\n`);
110
+ (0, store_1.initBoundJournal)(root, 'master', { path: 'docs/plans/old.md', digest: require('crypto').createHash('sha256').update(fs_1.default.readFileSync(path_1.default.join(root, 'docs/plans/old.md'), 'utf8')).digest('hex'), schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' });
111
+ const state = (0, store_1.readJournal)(root, 'master').state;
112
+ state.tasks = [{ id: '1', title: 't', status: 'done', attempts: 1, verificationPlan: [{ id: 'test:1', kind: 'test' }, { id: 'sensor:1', kind: 'sensors' }], reviewObligations: [{ id: 'spec:1', taskId: '1', kind: 'spec', verdictId: 'v1' }, { id: 'quality:1', taskId: '1', kind: 'quality', verdictId: 'v2' }] }];
113
+ const argv = [process.execPath, '-e', 'process.exit(0)'];
114
+ const paths = ['task.txt'];
115
+ const observed = (0, fingerprint_1.computeFingerprint)(root, argv, paths, '.');
116
+ const job = (id, satisfies) => ({ id, ...observed, argv: [...argv], cwd: '.', paths: [...paths], executionState: 'exited', observationState: 'progressing', verdict: 'pass', phaseTimestamps: {}, satisfies });
117
+ state.jobs = { t: job('t', ['test:1']), s: job('s', ['sensor:1']) };
118
+ if (change === 'combined-job')
119
+ state.jobs = { t: job('t', ['test:1', 'sensor:1']) };
120
+ if (change === 'semantic-kind') {
121
+ state.tasks[0].verificationPlan[0].id = 'unit';
122
+ state.tasks[0].verificationPlan[1].id = 'quality-gate';
123
+ state.jobs.t.satisfies = ['unit'];
124
+ state.jobs.s.satisfies = ['quality-gate'];
125
+ }
126
+ if (change === 'spoofed-kind')
127
+ for (const item of state.tasks[0].verificationPlan)
128
+ item.kind = 'lint';
129
+ state.verdicts = ['v1', 'v2'].map((id, index) => ({ id, obligationId: index === 0 ? 'spec:1' : 'quality:1', result: 'pass', detail: 'ok', receivedAt: '2026-09-15T01:00:00.000Z', fingerprint: observed.fingerprint, argv: [...argv], paths: [...paths], cwd: '.' }));
130
+ if (change === 'content')
131
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task.txt'), 'changed source');
132
+ if (change === 'deleted')
133
+ fs_1.default.unlinkSync(path_1.default.join(root, 'task.txt'));
134
+ if (change === 'index') {
135
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task.txt'), 'staged change');
136
+ (0, child_process_1.execFileSync)('git', ['add', 'task.txt'], { cwd: root });
137
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task.txt'), 'verified source');
138
+ }
139
+ if (change === 'head')
140
+ (0, child_process_1.execFileSync)('git', ['commit', '--allow-empty', '-qm', 'unrelated HEAD'], { cwd: root });
141
+ if (change === 'argv')
142
+ state.jobs.t.argv.push('--changed');
143
+ if (change === 'cwd') {
144
+ fs_1.default.mkdirSync(path_1.default.join(root, 'subdir'));
145
+ state.jobs.t.cwd = 'subdir';
146
+ }
147
+ if (change === 'paths')
148
+ state.jobs.t.paths = ['missing.txt'];
149
+ if (change === 'binding')
150
+ state.planBinding.digest = '0'.repeat(64);
151
+ if (change === 'review-argv')
152
+ state.verdicts[1].argv.push('--changed');
153
+ if (change === 'empty-expansion') {
154
+ const empty = (0, fingerprint_1.computeFingerprint)(root, argv, ['missing.txt'], '.');
155
+ for (const entry of Object.values(state.jobs))
156
+ Object.assign(entry, empty, { paths: ['missing.txt'] });
157
+ for (const entry of state.verdicts)
158
+ Object.assign(entry, { fingerprint: empty.fingerprint, paths: ['missing.txt'] });
159
+ }
160
+ if (change === 'live-job')
161
+ state.jobs.t.executionState = 'running';
162
+ (0, store_1.writeJournal)(root, 'master', state);
163
+ const report = (0, migration_1.collectMigrationFacts)('docs/plans/old.md', root, ['https://github.com/Kodria/agentic-workflow/issues/126']);
164
+ if (['current', 'combined-job', 'semantic-kind'].includes(change)) {
165
+ expect(report).toMatchObject({ state: 'supported-completion' });
166
+ expect(report.tasks[0]).toMatchObject({ state: 'completed' });
167
+ }
168
+ else {
169
+ expect(report.state).not.toBe('supported-completion');
170
+ expect(report.tasks[0]?.state).not.toBe('completed');
171
+ }
172
+ }
173
+ finally {
174
+ fs_1.default.rmSync(root, { recursive: true, force: true });
175
+ }
176
+ });
177
+ it('does not let Task 2 borrow a shared verifier identifier from Task 1', () => {
178
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-foreign-task-'));
179
+ try {
180
+ fs_1.default.mkdirSync(path_1.default.join(root, 'docs', 'plans'), { recursive: true });
181
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), '### Task 1: first\nFiles:\n- docs/plans/old.md\n\n### Task 2: second\nFiles:\n- task-2.txt\n');
182
+ (0, child_process_1.execFileSync)('git', ['init'], { cwd: root });
183
+ (0, child_process_1.execFileSync)('git', ['config', 'user.email', 't@e.invalid'], { cwd: root });
184
+ (0, child_process_1.execFileSync)('git', ['config', 'user.name', 'T'], { cwd: root });
185
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
186
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'task 1'], { cwd: root });
187
+ const taskOneCommit = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
188
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task-2.txt'), 'task 2');
189
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
190
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'task 2'], { cwd: root });
191
+ const taskTwoCommit = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
192
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), `### Task 1: first\nCommit: ${taskOneCommit}\nFiles:\n- docs/plans/old.md\n\n### Task 2: second\nCommit: ${taskTwoCommit}\nFiles:\n- task-2.txt\n`);
193
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
194
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'record obligations'], { cwd: root });
195
+ const planPath = 'docs/plans/old.md';
196
+ const digest = require('crypto').createHash('sha256').update(fs_1.default.readFileSync(path_1.default.join(root, planPath), 'utf8')).digest('hex');
197
+ (0, store_1.initBoundJournal)(root, 'master', { path: planPath, digest, schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' });
198
+ const state = (0, store_1.readJournal)(root, 'master').state;
199
+ const task = (id) => ({ id, title: id, status: 'done', attempts: 1, verificationPlan: [{ id: 'test:shared', kind: 'test' }, { id: 'sensor:shared', kind: 'sensors' }], reviewObligations: [{ id: `spec:${id}`, taskId: id, kind: 'spec', verdictId: `v-spec-${id}` }, { id: `quality:${id}`, taskId: id, kind: 'quality', verdictId: `v-quality-${id}` }] });
200
+ state.tasks = [task('1'), task('2')];
201
+ const argv = ['node'];
202
+ const paths = ['docs/plans/old.md', 'task-2.txt'];
203
+ const observed = (0, fingerprint_1.computeFingerprint)(root, argv, paths, '.');
204
+ const job = (id, satisfies) => ({ id, ...observed, argv: [...argv], cwd: '.', paths: [...paths], executionState: 'exited', observationState: 'progressing', verdict: 'pass', phaseTimestamps: {}, satisfies });
205
+ state.jobs = { test: job('test', ['test:shared']), sensor: job('sensor', ['sensor:shared']) };
206
+ state.verdicts = state.tasks.flatMap(taskState => taskState.reviewObligations.map(obligation => ({ id: obligation.verdictId, obligationId: obligation.id, result: 'pass', detail: 'ok', receivedAt: '2026-09-15T01:00:00.000Z', fingerprint: observed.fingerprint, argv: [...argv], paths: [...paths], cwd: '.' })));
207
+ (0, store_1.writeJournal)(root, 'master', state);
208
+ const report = (0, migration_1.collectMigrationFacts)(planPath, root, ['https://github.com/Kodria/agentic-workflow/issues/126']);
209
+ expect(report.tasks.find(taskState => taskState.id === '1')).toMatchObject({ state: 'pending' });
210
+ expect(report.tasks.find(taskState => taskState.id === '2')).toMatchObject({ state: 'pending' });
211
+ }
212
+ finally {
213
+ fs_1.default.rmSync(root, { recursive: true, force: true });
214
+ }
215
+ });
216
+ it('rejects a job that satisfies otherwise exclusive verifiers from two tasks', () => {
217
+ const root = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-migration-multi-satisfies-'));
218
+ try {
219
+ fs_1.default.mkdirSync(path_1.default.join(root, 'docs', 'plans'), { recursive: true });
220
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), '### Task 1: first\nFiles:\n- docs/plans/old.md\n\n### Task 2: second\nFiles:\n- task-2.txt\n');
221
+ (0, child_process_1.execFileSync)('git', ['init'], { cwd: root });
222
+ (0, child_process_1.execFileSync)('git', ['config', 'user.email', 't@e.invalid'], { cwd: root });
223
+ (0, child_process_1.execFileSync)('git', ['config', 'user.name', 'T'], { cwd: root });
224
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
225
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'task 1'], { cwd: root });
226
+ const taskOneCommit = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
227
+ fs_1.default.writeFileSync(path_1.default.join(root, 'task-2.txt'), 'task 2');
228
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
229
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'task 2'], { cwd: root });
230
+ const taskTwoCommit = (0, child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
231
+ fs_1.default.writeFileSync(path_1.default.join(root, 'docs', 'plans', 'old.md'), `### Task 1: first\nCommit: ${taskOneCommit}\nFiles:\n- docs/plans/old.md\n\n### Task 2: second\nCommit: ${taskTwoCommit}\nFiles:\n- task-2.txt\n`);
232
+ (0, child_process_1.execFileSync)('git', ['add', '.'], { cwd: root });
233
+ (0, child_process_1.execFileSync)('git', ['commit', '-m', 'record obligations'], { cwd: root });
234
+ const planPath = 'docs/plans/old.md';
235
+ const digest = require('crypto').createHash('sha256').update(fs_1.default.readFileSync(path_1.default.join(root, planPath), 'utf8')).digest('hex');
236
+ (0, store_1.initBoundJournal)(root, 'master', { path: planPath, digest, schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' });
237
+ const state = (0, store_1.readJournal)(root, 'master').state;
238
+ const task = (id) => ({ id, title: id, status: 'done', attempts: 1, verificationPlan: [{ id: `test:${id}`, kind: 'test' }, { id: `sensor:${id}`, kind: 'sensors' }], reviewObligations: [{ id: `spec:${id}`, taskId: id, kind: 'spec', verdictId: `v-spec-${id}` }, { id: `quality:${id}`, taskId: id, kind: 'quality', verdictId: `v-quality-${id}` }] });
239
+ state.tasks = [task('1'), task('2')];
240
+ const argv = ['node'];
241
+ const paths = ['docs/plans/old.md', 'task-2.txt'];
242
+ const observed = (0, fingerprint_1.computeFingerprint)(root, argv, paths, '.');
243
+ const job = (id, satisfies) => ({ id, ...observed, argv: [...argv], cwd: '.', paths: [...paths], executionState: 'exited', observationState: 'progressing', verdict: 'pass', phaseTimestamps: {}, satisfies });
244
+ state.jobs = { multi: job('multi', ['test:1', 'test:2']), sensorOne: job('sensorOne', ['sensor:1']), sensorTwo: job('sensorTwo', ['sensor:2']) };
245
+ state.verdicts = state.tasks.flatMap(taskState => taskState.reviewObligations.map(obligation => ({ id: obligation.verdictId, obligationId: obligation.id, result: 'pass', detail: 'ok', receivedAt: '2026-09-15T01:00:00.000Z', fingerprint: observed.fingerprint, argv: [...argv], paths: [...paths], cwd: '.' })));
246
+ (0, store_1.writeJournal)(root, 'master', state);
247
+ const report = (0, migration_1.collectMigrationFacts)(planPath, root, ['https://github.com/Kodria/agentic-workflow/issues/126']);
248
+ expect(report.tasks).toEqual([
249
+ { id: '1', state: 'pending', missing: ['tests'] },
250
+ { id: '2', state: 'pending', missing: ['tests'] },
251
+ ]);
252
+ expect(report.facts.filter(fact => fact.jobId === 'multi')).toEqual([]);
253
+ }
254
+ finally {
255
+ fs_1.default.rmSync(root, { recursive: true, force: true });
256
+ }
257
+ });
258
+ });
259
+ describe('collectIssue148HistoricalFacts', () => {
260
+ it('requires the admitted sibling, canonical branch, and rejects incomplete digest/ledger provenance', () => {
261
+ const parent = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-historical-parent-'));
262
+ const current = path_1.default.join(parent, 'codex-issue-126-compact-only');
263
+ const historical = path_1.default.join(parent, 'codex-issue-148-awm-facts');
264
+ const cwd = jest.spyOn(process, 'cwd').mockReturnValue(current);
265
+ try {
266
+ fs_1.default.mkdirSync(current);
267
+ fs_1.default.mkdirSync(path_1.default.join(historical, 'docs', 'plans'), { recursive: true });
268
+ fs_1.default.writeFileSync(path_1.default.join(historical, 'docs', 'plans', '2026-09-14-awm-facts-plan.md'), `### Task 1: facts\n- [x] reviewed\n\n### Task 2: quality\n${Array.from({ length: 12 }, (_, index) => `\n### Task ${index + 3}: unstarted\n`).join('')}`);
269
+ (0, child_process_1.execFileSync)('git', ['init', '-q', '-b', 'codex/issue-148-awm-facts'], { cwd: historical });
270
+ (0, child_process_1.execFileSync)('git', ['-c', 'user.email=t@e.invalid', '-c', 'user.name=T', 'add', '.'], { cwd: historical });
271
+ (0, child_process_1.execFileSync)('git', ['-c', 'user.email=t@e.invalid', '-c', 'user.name=T', 'commit', '-qm', 'fixture'], { cwd: historical });
272
+ expect(() => (0, migration_1.collectIssue148HistoricalFacts)(current, ['https://github.com/Kodria/agentic-workflow/issues/126', 'https://github.com/Kodria/agentic-workflow/issues/148'])).toThrow(/admitted issue-148 sibling/);
273
+ const report = (0, migration_1.collectIssue148HistoricalFacts)(historical, ['https://github.com/Kodria/agentic-workflow/issues/126', 'https://github.com/Kodria/agentic-workflow/issues/148']);
274
+ expect(report).toMatchObject({ state: 'blocked', diagnostics: ['issue-148 historical provenance is incomplete or inconsistent'] });
275
+ expect(report.tasks).toEqual([
276
+ { id: '1', state: 'pending', missing: ['historical-completion-provenance'] },
277
+ { id: '2', state: 'pending', missing: ['quality-review'] },
278
+ ...Array.from({ length: 12 }, (_, index) => ({ id: String(index + 3), state: 'unstarted', missing: [] })),
279
+ ]);
280
+ fs_1.default.writeFileSync(path_1.default.join(historical, 'docs', 'plans', '2026-09-14-awm-facts-plan.md'), '### Task 1: unchecked\n\n### Task 2: later\n- [x] unrelated check\n');
281
+ expect((0, migration_1.collectIssue148HistoricalFacts)(historical, ['https://github.com/Kodria/agentic-workflow/issues/126', 'https://github.com/Kodria/agentic-workflow/issues/148']).tasks[0])
282
+ .toEqual({ id: '1', state: 'unstarted', missing: [] });
283
+ }
284
+ finally {
285
+ cwd.mockRestore();
286
+ fs_1.default.rmSync(parent, { recursive: true, force: true });
287
+ }
288
+ });
289
+ });
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const historical_provenance_1 = require("../../../src/core/migration/historical-provenance");
4
+ const spec = { ts: '2026-09-14T21:53:36.988Z', branch: 'codex/issue-148-awm-facts', phase: 'review', source_skill: 'requesting-code-review', polarity: 'win', signature: 'facts-command-placeholder-traversal', ref: 'cli/src/core/facts/contract.ts:75' };
5
+ const quality = { ...spec, ts: '2026-09-14T22:02:34.749Z', signature: 'facts-contract-json-and-literal-validation', ref: 'cli/src/core/facts/contract.ts:37' };
6
+ describe('audited issue148 native review provenance', () => {
7
+ test('recovers only the exact already-existing audited events, not a new verdict', () => {
8
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([spec, quality])).toBe(true);
9
+ });
10
+ test.each(['ts', 'branch', 'phase', 'source_skill', 'polarity', 'signature', 'ref'])('does not borrow a different specification event (%s)', field => {
11
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([{ ...spec, [field]: 'different' }, quality])).toBe(false);
12
+ });
13
+ test.each(['ts', 'branch', 'phase', 'source_skill', 'polarity', 'signature', 'ref'])('does not borrow a different quality event (%s)', field => {
14
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([spec, { ...quality, [field]: 'different' }])).toBe(false);
15
+ });
16
+ test('requires both distinct events and rejects later task-owned adverse evidence', () => {
17
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([quality])).toBe(false);
18
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([spec])).toBe(false);
19
+ expect((0, historical_provenance_1.hasIssue148ReviewProvenance)([spec, quality, { ...quality, ts: '2026-09-15T00:00:00.000Z', polarity: 'finding' }])).toBe(false);
20
+ });
21
+ test('validates the public input shape', () => {
22
+ expect(() => (0, historical_provenance_1.hasIssue148ReviewProvenance)(null)).toThrow(/array/);
23
+ expect(() => (0, historical_provenance_1.hasIssue148ReviewProvenance)([null])).toThrow(/record/);
24
+ });
25
+ });