agentic-workflow-manager 9.7.1 → 9.9.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.
- package/README.md +5 -1
- package/dist/src/commands/job/exec-wrapper.js +53 -3
- package/dist/src/commands/job/gate.js +18 -0
- package/dist/src/commands/job/index.js +61 -0
- package/dist/src/commands/model-policy/index.js +73 -0
- package/dist/src/commands/plan/index.js +182 -7
- package/dist/src/commands/sensors/bootstrap.js +36 -5
- package/dist/src/commands/sensors/compatibility/contract.js +19 -4
- package/dist/src/commands/sensors/compatibility/discovery.js +23 -3
- package/dist/src/commands/sensors/compatibility/live.js +18 -1
- package/dist/src/commands/sensors/compatibility/probe.js +8 -2
- package/dist/src/commands/sensors/compatibility/resolve.js +5 -2
- package/dist/src/commands/sensors/coverage/evidence.js +19 -10
- package/dist/src/commands/sensors/coverage/index.js +11 -2
- package/dist/src/commands/sensors/coverage/resolve.js +10 -0
- package/dist/src/commands/sensors/exec.js +16 -1
- package/dist/src/commands/sensors/migrate.js +62 -2
- package/dist/src/commands/sensors/prepare.js +2 -0
- package/dist/src/commands/sensors/result.js +2 -0
- package/dist/src/commands/sensors/run.js +64 -1
- package/dist/src/commands/sensors/status.js +6 -4
- package/dist/src/commands/watch/apply.js +32 -0
- package/dist/src/commands/watch/archive-unused.js +138 -0
- package/dist/src/commands/watch/generations.js +32 -9
- package/dist/src/commands/watch/index.js +108 -2
- package/dist/src/commands/watch/init.js +149 -18
- package/dist/src/commands/watch/supervisor.js +167 -13
- package/dist/src/commands/watch/teardown-driver.js +13 -13
- package/dist/src/commands/watch/track-state.js +59 -0
- package/dist/src/commands/watch/tracks.js +38 -102
- package/dist/src/core/admission/index.js +231 -0
- package/dist/src/core/admission/registry-contracts.js +290 -0
- package/dist/src/core/journal/fingerprint.js +35 -1
- package/dist/src/core/journal/paths.js +11 -0
- package/dist/src/core/journal/requests.js +1 -1
- package/dist/src/core/journal/store.js +146 -4
- package/dist/src/core/journal/types.js +57 -2
- package/dist/src/core/migration/historical-provenance.js +18 -0
- package/dist/src/core/migration/index.js +322 -0
- package/dist/src/core/model-policy/canonical.js +18 -0
- package/dist/src/core/model-policy/capabilities.js +197 -0
- package/dist/src/core/model-policy/capability-types.js +2 -0
- package/dist/src/core/model-policy/journal.js +124 -0
- package/dist/src/core/model-policy/paths.js +12 -0
- package/dist/src/core/model-policy/resolve.js +116 -0
- package/dist/src/core/model-policy/store.js +182 -0
- package/dist/src/core/model-policy/types.js +2 -0
- package/dist/src/core/model-policy/validate.js +112 -0
- package/dist/src/core/plan/identity.js +77 -0
- package/dist/src/core/plan/validate.js +191 -78
- package/dist/src/index.js +2 -0
- package/dist/tests/commands/job/exec-wrapper.test.js +16 -0
- package/dist/tests/commands/job/gate-reconcile.test.js +40 -10
- package/dist/tests/commands/job/gate.test.js +9 -0
- package/dist/tests/commands/job/routing-report-cli.test.js +46 -0
- package/dist/tests/commands/job/routing.test.js +11 -0
- package/dist/tests/commands/model-policy/index.test.js +57 -0
- package/dist/tests/commands/pin.test.js +23 -23
- package/dist/tests/commands/plan/index.test.js +682 -14
- package/dist/tests/commands/sensors/bootstrap.test.js +57 -4
- package/dist/tests/commands/sensors/compatibility/contract.test.js +21 -0
- package/dist/tests/commands/sensors/compatibility/discovery.test.js +19 -0
- package/dist/tests/commands/sensors/compatibility/probe.test.js +14 -1
- package/dist/tests/commands/sensors/compatibility/resolve.test.js +17 -0
- package/dist/tests/commands/sensors/coverage/evidence.test.js +51 -27
- package/dist/tests/commands/sensors/coverage/resolve.test.js +51 -0
- package/dist/tests/commands/sensors/exec.test.js +112 -0
- package/dist/tests/commands/sensors/run-changed.test.js +11 -0
- package/dist/tests/commands/sensors/run.test.js +15 -2
- package/dist/tests/commands/sensors/status.test.js +3 -3
- package/dist/tests/commands/watch/apply.test.js +12 -0
- package/dist/tests/commands/watch/e2e-crash.test.js +126 -11
- package/dist/tests/commands/watch/generations.test.js +113 -4
- package/dist/tests/commands/watch/plan-lifecycle.test.js +263 -0
- package/dist/tests/commands/watch/supervisor-loop.test.js +247 -49
- package/dist/tests/commands/watch/track-finalize.test.js +20 -3
- package/dist/tests/commands/watch/track-freeze.test.js +43 -30
- package/dist/tests/commands/watch/track-state-dependency.test.js +15 -0
- package/dist/tests/commands/watch/watch-init.test.js +244 -0
- package/dist/tests/core/admission/index.test.js +140 -0
- package/dist/tests/core/journal/fingerprint.test.js +22 -0
- package/dist/tests/core/journal/store.test.js +53 -0
- package/dist/tests/core/journal/types.test.js +7 -0
- package/dist/tests/core/migration/facts.test.js +289 -0
- package/dist/tests/core/migration/historical-provenance.test.js +25 -0
- package/dist/tests/core/model-policy/capabilities.test.js +365 -0
- package/dist/tests/core/model-policy/journal.test.js +46 -0
- package/dist/tests/core/model-policy/policy.test.js +47 -0
- package/dist/tests/core/model-policy/resolve.test.js +111 -0
- package/dist/tests/core/model-policy/store.test.js +177 -0
- package/dist/tests/core/plan/validate.test.js +360 -8
- package/dist/tests/core/secure-fs/native-bridge.test.js +81 -4
- package/dist/tests/integration/pack-e2e.test.js +4 -1
- package/dist/tests/integration/preflight-json-pipe.e2e.test.js +7 -3
- package/dist/tests/integration/sensor-bootstrap.e2e.test.js +37 -0
- package/dist/tests/integration/sensor-structured-run.e2e.test.js +12 -10
- package/dist/tests/providers/injection-config.test.js +14 -6
- package/dist/tests/structural/directory-fsync-is-single-source.test.js +97 -0
- package/dist/tests/structural/jest-environment-is-isolated.test.js +29 -24
- package/dist/tests/structural/native-release-artifacts.test.js +30 -0
- package/package.json +4 -3
- package/prebuilds/darwin-arm64/secure_fs.node +0 -0
- package/prebuilds/darwin-x64/secure_fs.node +0 -0
- package/prebuilds/linux-arm64/secure_fs.node +0 -0
- package/prebuilds/linux-x64/secure_fs.node +0 -0
- package/prebuilds/win32-arm64/secure_fs.node +0 -0
- package/prebuilds/win32-x64/secure_fs.node +0 -0
|
@@ -8,6 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const fingerprint_1 = require("../../../src/core/journal/fingerprint");
|
|
11
|
+
const types_1 = require("../../../src/core/journal/types");
|
|
11
12
|
function git(cwd, ...args) {
|
|
12
13
|
(0, child_process_1.execFileSync)('git', ['-c', 'user.email=t@t.t', '-c', 'user.name=t', '-c', 'commit.gpgsign=false', ...args], { cwd });
|
|
13
14
|
}
|
|
@@ -96,6 +97,27 @@ describe('computeFingerprint', () => {
|
|
|
96
97
|
expect(() => (0, fingerprint_1.computeFingerprint)(repo, ['npm', 'test'], [], '.')).not.toThrow();
|
|
97
98
|
});
|
|
98
99
|
});
|
|
100
|
+
describe('reconcileUnattendedRecovery', () => {
|
|
101
|
+
test.each([
|
|
102
|
+
['journal', { journal: null, journalCorrupt: true }, 'repair-journal'],
|
|
103
|
+
['binding', { plan: { path: 'other.md' } }, 'rebind-plan'],
|
|
104
|
+
['git', { git: 'changed' }, 'reconcile-git'],
|
|
105
|
+
['verdicts', { verdicts: 'missing' }, 'repair-verdicts'],
|
|
106
|
+
['tests', { tests: 'fail' }, 'run-tests'],
|
|
107
|
+
['sensors', { sensors: 'missing' }, 'run-sensors'],
|
|
108
|
+
['ready', {}, 'select-work'],
|
|
109
|
+
])('covers recovery action %s', (_name, overrides, nextAction) => {
|
|
110
|
+
const journal = { ...(0, types_1.emptyState)('main'), schema: 2, planBinding: { path: 'docs/plan.md', digest: 'a'.repeat(64), schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' } };
|
|
111
|
+
const input = { journal, journalCorrupt: false, plan: journal.planBinding, git: 'current', activeJobIds: [], tests: 'pass', sensors: 'pass', verdicts: 'current', ...overrides };
|
|
112
|
+
expect((0, fingerprint_1.reconcileUnattendedRecovery)(input).nextAction).toBe(nextAction);
|
|
113
|
+
});
|
|
114
|
+
test('reuses active obligations before later verdict repair', () => {
|
|
115
|
+
const journal = { ...(0, types_1.emptyState)('main'), schema: 2, planBinding: { path: 'docs/plan.md', digest: 'a'.repeat(64), schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-15T00:00:00.000Z' } };
|
|
116
|
+
const input = { journal, journalCorrupt: false, plan: journal.planBinding, git: 'current', activeJobIds: ['job-b', 'job-a', 'job-a'], tests: 'pass', sensors: 'pass', verdicts: 'current' };
|
|
117
|
+
expect((0, fingerprint_1.reconcileUnattendedRecovery)(input)).toEqual({ state: 'ready', nextAction: 'reconcile-active-jobs', activeJobIds: ['job-a', 'job-b'], diagnostics: [] });
|
|
118
|
+
expect((0, fingerprint_1.reconcileUnattendedRecovery)({ ...input, verdicts: 'missing' })).toEqual({ state: 'ready', nextAction: 'reconcile-active-jobs', activeJobIds: ['job-a', 'job-b'], diagnostics: [] });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
99
121
|
/** Defense-in-depth (post-implementation-qa, follow-up a Task 20): el `git()`
|
|
100
122
|
* interno de este archivo backea `computeFingerprint`, invocado en CADA tick
|
|
101
123
|
* del supervisor via `FingerprintNow`/`computeGate` (job/gate.ts). Sin stdio
|
|
@@ -27,6 +27,11 @@ describe('journal store', () => {
|
|
|
27
27
|
expect(r.corrupt).toBe(false);
|
|
28
28
|
expect(r.state.revision).toBe(0);
|
|
29
29
|
});
|
|
30
|
+
test('initJournal es idempotente cuando el arbol de journal ya existe', () => {
|
|
31
|
+
(0, store_1.initJournal)(repo, 'rama');
|
|
32
|
+
expect(() => (0, store_1.initJournal)(repo, 'rama')).not.toThrow();
|
|
33
|
+
expect((0, store_1.readJournal)(repo, 'rama')).toMatchObject({ corrupt: false, state: { revision: 0 } });
|
|
34
|
+
});
|
|
30
35
|
test('writeJournal incrementa revision y rechaza revision vieja (R1.2)', () => {
|
|
31
36
|
(0, store_1.initJournal)(repo, 'rama');
|
|
32
37
|
const s1 = (0, store_1.readJournal)(repo, 'rama').state;
|
|
@@ -51,6 +56,46 @@ describe('journal store', () => {
|
|
|
51
56
|
fs_1.default.writeFileSync((0, paths_1.statePath)(repo, 'rama'), '{roto'); // sintaxis invalida
|
|
52
57
|
expect((0, store_1.readJournal)(repo, 'rama').corrupt).toBe(true);
|
|
53
58
|
});
|
|
59
|
+
test('rechaza un state.json symlink sin leer el destino externo', () => {
|
|
60
|
+
(0, store_1.initJournal)(repo, 'rama');
|
|
61
|
+
const outside = path_1.default.join(repo, 'outside.json');
|
|
62
|
+
fs_1.default.writeFileSync(outside, fs_1.default.readFileSync((0, paths_1.statePath)(repo, 'rama')));
|
|
63
|
+
fs_1.default.rmSync((0, paths_1.statePath)(repo, 'rama'));
|
|
64
|
+
fs_1.default.symlinkSync(outside, (0, paths_1.statePath)(repo, 'rama'));
|
|
65
|
+
expect((0, store_1.readJournal)(repo, 'rama')).toMatchObject({ state: null, corrupt: true });
|
|
66
|
+
});
|
|
67
|
+
test('initJournal rechaza un padre .awm symlink sin crear journal fuera del repo', () => {
|
|
68
|
+
const outside = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-store-outside-'));
|
|
69
|
+
try {
|
|
70
|
+
fs_1.default.symlinkSync(outside, path_1.default.join(repo, '.awm'));
|
|
71
|
+
expect(() => (0, store_1.initJournal)(repo, 'rama')).toThrow(/symlink/i);
|
|
72
|
+
expect(fs_1.default.existsSync(path_1.default.join(outside, 'journal'))).toBe(false);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
fs_1.default.rmSync(outside, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
test.each([
|
|
79
|
+
['.awm', (root) => path_1.default.join(root, '.awm')],
|
|
80
|
+
['journal', (root) => path_1.default.join(root, '.awm', 'journal')],
|
|
81
|
+
['branch', (root) => (0, paths_1.journalDir)(root, 'rama')],
|
|
82
|
+
['requests', (root) => (0, paths_1.requestsDir)(root, 'rama')],
|
|
83
|
+
['acks', (root) => (0, paths_1.acksDir)(root, 'rama')],
|
|
84
|
+
['logs', (root) => (0, paths_1.logsDir)(root, 'rama')],
|
|
85
|
+
['export', (root) => (0, paths_1.exportDir)(root, 'rama')],
|
|
86
|
+
])('initJournal rechaza el segmento symlink %s', (_name, segment) => {
|
|
87
|
+
const outside = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'awm-store-outside-'));
|
|
88
|
+
const target = segment(repo);
|
|
89
|
+
try {
|
|
90
|
+
fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
|
|
91
|
+
fs_1.default.symlinkSync(outside, target);
|
|
92
|
+
expect(() => (0, store_1.initJournal)(repo, 'rama')).toThrow(/symlink/i);
|
|
93
|
+
expect(fs_1.default.readdirSync(outside)).toEqual([]);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
fs_1.default.rmSync(outside, { recursive: true, force: true });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
54
99
|
test('normaliza campos aditivos de snapshots schema 1 sin certificar evidencia legacy', () => {
|
|
55
100
|
(0, store_1.initJournal)(repo, 'rama');
|
|
56
101
|
const legacy = (0, store_1.readJournal)(repo, 'rama').state;
|
|
@@ -74,6 +119,14 @@ describe('journal store', () => {
|
|
|
74
119
|
expect(JSON.parse(lines[0]).kind).toBe('generation-launched');
|
|
75
120
|
expect(typeof JSON.parse(lines[0]).at).toBe('string');
|
|
76
121
|
});
|
|
122
|
+
test('appendEvent no sigue un events.jsonl symlink externo', () => {
|
|
123
|
+
(0, store_1.initJournal)(repo, 'rama');
|
|
124
|
+
const outside = path_1.default.join(repo, 'outside-events.jsonl');
|
|
125
|
+
fs_1.default.writeFileSync(outside, 'outside\n');
|
|
126
|
+
fs_1.default.symlinkSync(outside, (0, paths_1.eventsPath)(repo, 'rama'));
|
|
127
|
+
(0, store_1.appendEvent)(repo, 'rama', { kind: 'must-not-escape' });
|
|
128
|
+
expect(fs_1.default.readFileSync(outside, 'utf8')).toBe('outside\n');
|
|
129
|
+
});
|
|
77
130
|
test('writeJournal rechaza un estado propuesto con forma invalida, nunca lo persiste (R1.6)', () => {
|
|
78
131
|
(0, store_1.initJournal)(repo, 'rama');
|
|
79
132
|
const s = (0, store_1.readJournal)(repo, 'rama').state;
|
|
@@ -22,6 +22,13 @@ describe('journal types', () => {
|
|
|
22
22
|
expect(s.requiredVerifiers).toEqual([]);
|
|
23
23
|
expect(s.dispatches).toEqual([]);
|
|
24
24
|
});
|
|
25
|
+
test('binding metadata rejects persisted plan bodies and unversioned execution commitments', () => {
|
|
26
|
+
const state = { ...(0, types_1.emptyState)('main'), schema: 2, planBinding: { path: 'docs/plan.md', digest: 'a'.repeat(64), schema: 'compact-slices/v1', executionMode: 'desatendido', boundAt: '2026-09-16' } };
|
|
27
|
+
expect((0, types_1.isWellFormedState)(state)).toBe(true);
|
|
28
|
+
expect((0, types_1.isWellFormedState)({ ...state, planBinding: { ...state.planBinding, snapshot: 'private source body' } })).toBe(false);
|
|
29
|
+
expect((0, types_1.isWellFormedState)({ ...state, planBinding: { ...state.planBinding, executionDigest: 'b'.repeat(64) } })).toBe(false);
|
|
30
|
+
expect((0, types_1.isWellFormedState)({ ...state, planBinding: { ...state.planBinding, executionDigest: 'b'.repeat(64), executionIdentitySchema: 'awm-plan-execution/v1' } })).toBe(true);
|
|
31
|
+
});
|
|
25
32
|
test('isWellFormedState rechaza no-objetos y shapes rotos (R1.6)', () => {
|
|
26
33
|
expect((0, types_1.isWellFormedState)(null)).toBe(false);
|
|
27
34
|
expect((0, types_1.isWellFormedState)(42)).toBe(false);
|
|
@@ -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
|
+
});
|