harness-everything 1.0.0 → 1.1.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +21 -0
- package/ci/mechanism-394-ledger-match.test.js +324 -3
- package/ci/mechanism-496-claude-capture.test.js +342 -0
- package/ci/mechanism-496-codex-capture.test.js +508 -0
- package/ci/mechanism-496-local-error-cli-edges.test.js +234 -0
- package/ci/mechanism-496-local-error-cli.test.js +517 -0
- package/ci/mechanism-496-local-error-store.test.js +731 -0
- package/ci/mechanism-496-opencode-capture.test.js +483 -0
- package/ci/mechanism-496-review-fixes.test.js +278 -0
- package/ci/mechanism-516-agy-post-tool-exit.test.js +472 -0
- package/ci/mechanism-516-agy-stop-revision.test.js +215 -0
- package/hooks/scripts/agy-post-tool.js +79 -16
- package/hooks/scripts/agy-stop.js +63 -10
- package/hooks/scripts/codex-ledger-lesson.js +103 -27
- package/hooks/scripts/ledger-lesson.js +94 -23
- package/hooks/scripts/lib/ledger-match.js +169 -21
- package/hooks/scripts/lib/local-error-source.js +127 -0
- package/hooks/scripts/lib/local-errors.js +597 -0
- package/hooks/scripts/lib/observations.js +1 -1
- package/hooks/scripts/state-persist.js +7 -1
- package/opencode-plugin/index.mjs +86 -1
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +2 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/agy-post-tool.js +79 -16
- package/plugins/harness-everything/hooks/scripts/agy-stop.js +63 -10
- package/plugins/harness-everything/hooks/scripts/codex-ledger-lesson.js +103 -27
- package/plugins/harness-everything/hooks/scripts/ledger-lesson.js +94 -23
- package/plugins/harness-everything/hooks/scripts/lib/ledger-match.js +169 -21
- package/plugins/harness-everything/hooks/scripts/lib/local-error-source.js +127 -0
- package/plugins/harness-everything/hooks/scripts/lib/local-errors.js +597 -0
- package/plugins/harness-everything/hooks/scripts/lib/observations.js +1 -1
- package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -1
- package/plugins/harness-everything/plugin.json +1 -1
- package/sbom.cdx.json +7 -7
- package/scripts/errors-local.js +357 -0
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "harness-everything",
|
|
11
11
|
"source": "./",
|
|
12
12
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
13
|
-
"version": "1.
|
|
13
|
+
"version": "1.1.0",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Miya Daniel"
|
|
16
16
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harness-everything",
|
|
3
3
|
"description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Miya Daniel"
|
|
7
7
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/dyphn1/Harness-everything/compare/v1.0.1...v1.1.0) (2026-11-25)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **errors:** add the local error store and provisional lesson cli ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([7c220a1](https://github.com/dyphn1/Harness-everything/commit/7c220a18d0eb5630e8a9c49fedeb67a97a9806f3))
|
|
10
|
+
* **hooks:** capture claude bash failures and deliver provisional lessons ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([b6ba4bc](https://github.com/dyphn1/Harness-everything/commit/b6ba4bc5804d57ea420603ace51eabe8fa178092))
|
|
11
|
+
* **hooks:** capture codex and opencode shell failures and deliver provisional lessons ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([5cddd27](https://github.com/dyphn1/Harness-everything/commit/5cddd272ae59caf9cfa6872076ed6646beabd372))
|
|
12
|
+
* **hooks:** share the ledger match validator and add a read-only repo match peek ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([a1c6c9a](https://github.com/dyphn1/Harness-everything/commit/a1c6c9a905c6195e428897ce33011cb364ac443e)), closes [#518](https://github.com/dyphn1/Harness-everything/issues/518)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **errors:** prefer newest provisional lessons and tighten the local error cli ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([7bcc66d](https://github.com/dyphn1/Harness-everything/commit/7bcc66d3d127198e049a2a2115eac052e7662aaa))
|
|
17
|
+
* **errors:** redact full authorization values and expire local records on read ([#496](https://github.com/dyphn1/Harness-everything/issues/496)) ([0dfaae2](https://github.com/dyphn1/Harness-everything/commit/0dfaae299bb4ca6a29c3ecfcc207fd1341640951))
|
|
18
|
+
|
|
19
|
+
## [1.0.1](https://github.com/dyphn1/Harness-everything/compare/v1.0.0...v1.0.1) (2026-11-24)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **agy:** bound stop continuation per work revision and normalize post-tool outcomes ([#516](https://github.com/dyphn1/Harness-everything/issues/516)) ([0fd30f5](https://github.com/dyphn1/Harness-everything/commit/0fd30f5f841212495b6278778e541f5e439093b6))
|
|
24
|
+
* **hooks:** match ledger lessons through pipelines and plain redirects ([#518](https://github.com/dyphn1/Harness-everything/issues/518)) ([509e010](https://github.com/dyphn1/Harness-everything/commit/509e01014bfcf8c2b7f3b6071ecf921860d50083))
|
|
25
|
+
|
|
5
26
|
## [1.0.0](https://github.com/dyphn1/Harness-everything/compare/v0.58.0...v1.0.0) (2026-11-24)
|
|
6
27
|
|
|
7
28
|
### ⚠ BREAKING CHANGES
|
|
@@ -170,8 +170,6 @@ test('source and packaged matchers bound simple command sequences and reject uns
|
|
|
170
170
|
];
|
|
171
171
|
const unsupported = [
|
|
172
172
|
"echo 'git commit; echo done'",
|
|
173
|
-
'git commit | cat',
|
|
174
|
-
'cat | git commit',
|
|
175
173
|
'(git commit)',
|
|
176
174
|
'git commit <<EOF\nmessage\nEOF',
|
|
177
175
|
'git commit;',
|
|
@@ -186,6 +184,77 @@ test('source and packaged matchers bound simple command sequences and reject uns
|
|
|
186
184
|
}
|
|
187
185
|
});
|
|
188
186
|
|
|
187
|
+
test('source and packaged matchers recognize pipeline members and literal redirects', () => {
|
|
188
|
+
const expected = { tool: 'shell', executable: 'git', subcommand: 'commit' };
|
|
189
|
+
const supported = [
|
|
190
|
+
'git commit -m "A"',
|
|
191
|
+
'cd /x && git commit -m "A"',
|
|
192
|
+
'git commit --dry-run -m "A"',
|
|
193
|
+
'git commit -m "A" 2>&1',
|
|
194
|
+
'git commit -m "A" 2>&1 | tail -3',
|
|
195
|
+
'git commit -m "A" | cat',
|
|
196
|
+
'echo before | git commit -m "A"',
|
|
197
|
+
'git 2>&1 commit -m "A"',
|
|
198
|
+
'2>errors.log git commit -m "A"',
|
|
199
|
+
'git commit 2>&1 -m "A"',
|
|
200
|
+
'git commit -m "A" >out.log',
|
|
201
|
+
'git commit -m "A" >out#log',
|
|
202
|
+
'git commit -m "A" >> "out file.log"',
|
|
203
|
+
'git commit -m "A" < input.txt',
|
|
204
|
+
'git commit -m "A" &>combined.log',
|
|
205
|
+
'git commit -m "A" 2> errors.log',
|
|
206
|
+
'git commit -m "A | B"',
|
|
207
|
+
'git commit -m A \\| cat',
|
|
208
|
+
'git commit -m "A" # | cat is comment text'
|
|
209
|
+
];
|
|
210
|
+
const unsupported = [
|
|
211
|
+
"echo 'git commit | cat'",
|
|
212
|
+
'echo before > git commit',
|
|
213
|
+
'echo before # git commit | cat',
|
|
214
|
+
'env git commit',
|
|
215
|
+
'git commit |',
|
|
216
|
+
'| git commit',
|
|
217
|
+
'git commit | | cat',
|
|
218
|
+
'git commit |& cat',
|
|
219
|
+
'git commit &',
|
|
220
|
+
'git commit &>>out.log',
|
|
221
|
+
'git commit 2>&-',
|
|
222
|
+
'git commit 2>&1-',
|
|
223
|
+
'git commit 2>&1suffix',
|
|
224
|
+
'2 >errors.log git commit',
|
|
225
|
+
"'2'>errors.log git commit",
|
|
226
|
+
'name2>errors.log git commit',
|
|
227
|
+
'git commit >',
|
|
228
|
+
'git commit > # missing redirect target',
|
|
229
|
+
'git commit >#missing-target',
|
|
230
|
+
'git commit >""',
|
|
231
|
+
'git commit >"$OUT"',
|
|
232
|
+
'git commit >*.log',
|
|
233
|
+
'git commit <<EOF\nmessage\nEOF',
|
|
234
|
+
'git commit <<< message',
|
|
235
|
+
'git commit > >(tee out.log)',
|
|
236
|
+
'cat <(git commit)',
|
|
237
|
+
'(git commit)',
|
|
238
|
+
'echo "$(git commit)"',
|
|
239
|
+
'echo "`git commit`"'
|
|
240
|
+
];
|
|
241
|
+
for (const implementation of [matcher, packagedMatcher]) {
|
|
242
|
+
for (const command of supported) {
|
|
243
|
+
assert.deepEqual(implementation.normalizeGitCommitCommand(command), expected, command);
|
|
244
|
+
const result = implementation.matchLedgerLessons(input({
|
|
245
|
+
event: { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } }
|
|
246
|
+
}));
|
|
247
|
+
assert.deepEqual(result?.ids, ['E-0003'], command);
|
|
248
|
+
}
|
|
249
|
+
for (const command of unsupported) {
|
|
250
|
+
assert.equal(implementation.normalizeGitCommitCommand(command), null, command);
|
|
251
|
+
assert.equal(implementation.matchLedgerLessons(input({
|
|
252
|
+
event: { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } }
|
|
253
|
+
})), null, command);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
189
258
|
test('source and packaged matchers accept an empty Git config value', () => {
|
|
190
259
|
const expected = { tool: 'shell', executable: 'git', subcommand: 'commit' };
|
|
191
260
|
for (const implementation of [matcher, packagedMatcher]) {
|
|
@@ -225,7 +294,6 @@ test('simple command segments select commit lessons without matching quoted text
|
|
|
225
294
|
}
|
|
226
295
|
for (const command of [
|
|
227
296
|
"echo 'git commit; echo done'",
|
|
228
|
-
'git commit | cat',
|
|
229
297
|
'(git commit)',
|
|
230
298
|
'git commit <<EOF\nmessage\nEOF',
|
|
231
299
|
'env git commit'
|
|
@@ -272,6 +340,40 @@ test('failure lessons require a known outcome and an exact diagnostic', () => {
|
|
|
272
340
|
}
|
|
273
341
|
});
|
|
274
342
|
|
|
343
|
+
test('a pipeline keeps the per-session action and failure reminder policy', () => {
|
|
344
|
+
const state = stateDir('pipeline-once');
|
|
345
|
+
const base = input({ stateDir: state, sessionIdentity: 'session:pipeline-once' });
|
|
346
|
+
const action = matcher.matchLedgerLessons(base);
|
|
347
|
+
assert.deepEqual(action?.ids, ['E-0003']);
|
|
348
|
+
assert.equal(matcher.matchLedgerLessons(base), null, 'a duplicate action stays silent');
|
|
349
|
+
|
|
350
|
+
const failureInput = {
|
|
351
|
+
...base,
|
|
352
|
+
event: {
|
|
353
|
+
phase: 'failure',
|
|
354
|
+
tool: 'shell',
|
|
355
|
+
command: 'git commit -m "Bad Subject" 2>&1 | tail -3',
|
|
356
|
+
outcome: { failed: false, output: COMMITLINT_OUTPUT }
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const failure = matcher.matchLedgerLessons(failureInput);
|
|
360
|
+
assert.deepEqual(failure?.ids, ['E-0003'], 'an exact diagnostic can recover a pipeline masked by zero status');
|
|
361
|
+
assert.equal(matcher.matchLedgerLessons(failureInput), null, 'a duplicate failure stays silent');
|
|
362
|
+
|
|
363
|
+
const unknown = matcher.matchLedgerLessons({
|
|
364
|
+
...failureInput,
|
|
365
|
+
sessionIdentity: 'session:pipeline-unknown',
|
|
366
|
+
event: { ...failureInput.event, outcome: { failed: 'unknown', output: COMMITLINT_OUTPUT } }
|
|
367
|
+
});
|
|
368
|
+
assert.equal(unknown, null, 'an unknown pipeline outcome stays silent');
|
|
369
|
+
const redirectedZero = matcher.matchLedgerLessons({
|
|
370
|
+
...failureInput,
|
|
371
|
+
sessionIdentity: 'session:redirected-zero',
|
|
372
|
+
event: { ...failureInput.event, command: 'git commit -m "Bad Subject" 2>&1', outcome: { failed: false, output: COMMITLINT_OUTPUT } }
|
|
373
|
+
});
|
|
374
|
+
assert.equal(redirectedZero, null, 'a redirect alone remains one command and cannot recover a zero status');
|
|
375
|
+
});
|
|
376
|
+
|
|
275
377
|
test('the real generator and runtime accept quoted identity and match scalars', () => {
|
|
276
378
|
const root = workspace('generated quoted record');
|
|
277
379
|
const ledger = path.join(root, '.agents', 'harness-everything', 'errors');
|
|
@@ -594,3 +696,222 @@ test('an unavailable dedupe directory is silent and never falls back', () => {
|
|
|
594
696
|
fs.writeFileSync(blocker, 'not a directory');
|
|
595
697
|
assert.equal(select(input({ stateDir: path.join(blocker, 'session') })), null);
|
|
596
698
|
});
|
|
699
|
+
|
|
700
|
+
test('R-518 P2/P3: unspaced single-char middle pipeline members match and trailing unescaped redirect backslashes are rejected', () => {
|
|
701
|
+
const expected = { tool: 'shell', executable: 'git', subcommand: 'commit' };
|
|
702
|
+
const supported = [
|
|
703
|
+
'x|y|git commit -m "A"',
|
|
704
|
+
'a|b|c|git commit -m "A"',
|
|
705
|
+
'x | y | git commit -m "A"',
|
|
706
|
+
'x||y||git commit -m "A"',
|
|
707
|
+
'git commit -m "A" > out\\\\',
|
|
708
|
+
'git commit -m "A" > "out\\\\"',
|
|
709
|
+
"git commit -m \"A\" > 'out\\'",
|
|
710
|
+
'git commit -m "A" > out\\ file.log'
|
|
711
|
+
];
|
|
712
|
+
const unsupported = [
|
|
713
|
+
'x|||git commit -m "A"',
|
|
714
|
+
'git commit ||| echo done',
|
|
715
|
+
'x| |git commit -m "A"',
|
|
716
|
+
'git commit -m "A" > out\\',
|
|
717
|
+
'git commit -m "A" > \\',
|
|
718
|
+
'git commit -m "A" > out\\\\\\'
|
|
719
|
+
];
|
|
720
|
+
for (const implementation of [matcher, packagedMatcher]) {
|
|
721
|
+
for (const command of supported) {
|
|
722
|
+
assert.deepEqual(implementation.normalizeGitCommitCommand(command), expected, command);
|
|
723
|
+
const result = implementation.matchLedgerLessons(input({
|
|
724
|
+
event: { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } }
|
|
725
|
+
}));
|
|
726
|
+
assert.deepEqual(result?.ids, ['E-0003'], command);
|
|
727
|
+
}
|
|
728
|
+
for (const command of unsupported) {
|
|
729
|
+
assert.equal(implementation.normalizeGitCommitCommand(command), null, command);
|
|
730
|
+
assert.equal(implementation.matchLedgerLessons(input({
|
|
731
|
+
event: { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } }
|
|
732
|
+
})), null, command);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
test('exports validateMatch and read-only peekRepoMatches without taking claims or applying reminder caps', () => {
|
|
738
|
+
for (const implementation of [matcher, packagedMatcher]) {
|
|
739
|
+
assert.equal(typeof implementation.validateMatch, 'function', 'validateMatch is exported');
|
|
740
|
+
assert.deepEqual(implementation.validateMatch({
|
|
741
|
+
actions: [{ tool: 'shell', executable: 'git', subcommand: 'commit' }]
|
|
742
|
+
}), {
|
|
743
|
+
actions: [{ tool: 'shell', executable: 'git', subcommand: 'commit' }]
|
|
744
|
+
});
|
|
745
|
+
assert.throws(() => implementation.validateMatch({ invalidKey: [] }), /invalid match/);
|
|
746
|
+
|
|
747
|
+
assert.equal(typeof implementation.peekRepoMatches, 'function', 'peekRepoMatches is exported');
|
|
748
|
+
|
|
749
|
+
const freshState = stateDir('peek-no-claim');
|
|
750
|
+
const actionInput = input({ stateDir: freshState });
|
|
751
|
+
assert.deepEqual(implementation.peekRepoMatches(actionInput), ['E-0003'], 'first peek returns matching repo id');
|
|
752
|
+
assert.deepEqual(implementation.peekRepoMatches(actionInput), ['E-0003'], 'second peek still returns matching repo id');
|
|
753
|
+
assert.equal(fs.existsSync(freshState), false, 'peek does not create stateDir or write claim files');
|
|
754
|
+
|
|
755
|
+
const delivered = implementation.matchLedgerLessons(actionInput);
|
|
756
|
+
assert.deepEqual(delivered?.ids, ['E-0003'], 'matchLedgerLessons still delivers once after two peeks');
|
|
757
|
+
assert.equal(implementation.matchLedgerLessons(actionInput), null, 'duplicate delivery stays silent');
|
|
758
|
+
assert.deepEqual(implementation.peekRepoMatches(actionInput), ['E-0003'],
|
|
759
|
+
'peek still reports repo match after delivery claim is exhausted');
|
|
760
|
+
|
|
761
|
+
assert.deepEqual(implementation.peekRepoMatches({
|
|
762
|
+
workspaceRoot: GENERATED_E3_ROOT,
|
|
763
|
+
event: {
|
|
764
|
+
phase: 'failure',
|
|
765
|
+
tool: 'shell',
|
|
766
|
+
command: 'git commit -m "Bad Subject"',
|
|
767
|
+
outcome: { failed: true, output: COMMITLINT_OUTPUT }
|
|
768
|
+
}
|
|
769
|
+
}), ['E-0003'], 'peek works for failure phase without sessionIdentity or stateDir');
|
|
770
|
+
|
|
771
|
+
for (const command of ['git status', 'echo "git commit"', '']) {
|
|
772
|
+
assert.deepEqual(implementation.peekRepoMatches({
|
|
773
|
+
workspaceRoot: GENERATED_E3_ROOT,
|
|
774
|
+
event: { phase: 'action', tool: 'shell', command, outcome: { failed: 'unknown' } }
|
|
775
|
+
}), [], `unknown command returns empty: ${command}`);
|
|
776
|
+
}
|
|
777
|
+
assert.deepEqual(implementation.peekRepoMatches(null), [], 'null input fails open to []');
|
|
778
|
+
|
|
779
|
+
const oversizedCue = E3_TEXT.replace(/(^## Cue\r?\n\r?\n)[\s\S]*?(\r?\n\r?\n## What happened)/m,
|
|
780
|
+
(_, start, end) => `${start}${'C'.repeat(1500)}${end}`);
|
|
781
|
+
const oversizedRoot = repoWorkspace('peek oversized repo', { recordText: oversizedCue });
|
|
782
|
+
assert.equal(implementation.matchLedgerLessons(input({ workspaceRoot: oversizedRoot })), null,
|
|
783
|
+
'oversized repo excerpt is skipped by reminder cap in matchLedgerLessons');
|
|
784
|
+
assert.deepEqual(implementation.peekRepoMatches({
|
|
785
|
+
workspaceRoot: oversizedRoot,
|
|
786
|
+
event: { phase: 'action', tool: 'shell', command: 'git commit', outcome: { failed: 'unknown' } }
|
|
787
|
+
}), ['E-0003'], 'peek ignores reminder char cap and still returns repo match');
|
|
788
|
+
|
|
789
|
+
assert.deepEqual(implementation.peekRepoMatches({
|
|
790
|
+
workspaceRoot: workspace('peek no repo'),
|
|
791
|
+
event: { phase: 'action', tool: 'shell', command: 'git commit', outcome: { failed: 'unknown' } },
|
|
792
|
+
provisionalSource: localSource([PROVISIONAL_FIXTURE[0]])
|
|
793
|
+
}), [], 'peek is repo-only and ignores provisionalSource');
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
test('peekRepoMatches keeps every matching repo id across shared signatures while preserving delivery collapse and bounds', () => {
|
|
798
|
+
const syncEnv = Object.fromEntries(Object.entries(process.env).filter(([key]) => key !== 'HARNESS_SYSTEM_ONE_MODE'));
|
|
799
|
+
const buildSameSignatureRepo = (name, count) => {
|
|
800
|
+
const root = workspace(name);
|
|
801
|
+
const ledger = path.join(root, '.agents', 'harness-everything', 'errors');
|
|
802
|
+
for (let index = 1; index <= count; index += 1) {
|
|
803
|
+
const id = `E-${String(index).padStart(4, '0')}`;
|
|
804
|
+
const recordText = index === 1
|
|
805
|
+
? E3_TEXT.replace(/^id:\s*E-0003$/m, 'id: E-0001')
|
|
806
|
+
: E3_TEXT
|
|
807
|
+
.replace(/^id:\s*E-0003$/m, `id: ${id}`)
|
|
808
|
+
.replace(/^## Lesson\r?\n\r?\n[\s\S]*?(?=\r?\n\r?\n## Evidence)/m,
|
|
809
|
+
`## Lesson\n\nSAME_SIGNATURE_SECOND_LESSON_SENTINEL_${id}`);
|
|
810
|
+
write(path.join(ledger, `${id}-commitlint-subject.md`), recordText);
|
|
811
|
+
}
|
|
812
|
+
const generated = spawnSync(process.execPath, [ERRORS_SYNC, '--root', root], {
|
|
813
|
+
cwd: ROOT,
|
|
814
|
+
env: syncEnv,
|
|
815
|
+
encoding: 'utf8'
|
|
816
|
+
});
|
|
817
|
+
assert.equal(generated.status, 0, generated.stderr);
|
|
818
|
+
return { root, ledger };
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
const pair = buildSameSignatureRepo('peek-same-sig-pair', 2);
|
|
822
|
+
const single = buildSameSignatureRepo('peek-same-sig-single', 1);
|
|
823
|
+
const pairIndexPath = path.join(pair.ledger, 'index.jsonl');
|
|
824
|
+
const pairRows = fs.readFileSync(pairIndexPath, 'utf8').trim().split('\n');
|
|
825
|
+
|
|
826
|
+
const reversedRoot = workspace('peek-same-sig-reversed');
|
|
827
|
+
const reversedLedger = path.join(reversedRoot, '.agents', 'harness-everything', 'errors');
|
|
828
|
+
for (const file of fs.readdirSync(pair.ledger)) {
|
|
829
|
+
if (file.endsWith('.md')) {
|
|
830
|
+
write(path.join(reversedLedger, file), fs.readFileSync(path.join(pair.ledger, file), 'utf8'));
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
write(path.join(reversedLedger, 'index.jsonl'), `${[...pairRows].reverse().join('\n')}\n`);
|
|
834
|
+
|
|
835
|
+
const duplicateIdRoot = workspace('peek-same-sig-dup-id');
|
|
836
|
+
const duplicateIdLedger = path.join(duplicateIdRoot, '.agents', 'harness-everything', 'errors');
|
|
837
|
+
for (const file of fs.readdirSync(pair.ledger)) {
|
|
838
|
+
if (file.endsWith('.md')) {
|
|
839
|
+
write(path.join(duplicateIdLedger, file), fs.readFileSync(path.join(pair.ledger, file), 'utf8'));
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
write(path.join(duplicateIdLedger, 'index.jsonl'), `${[pairRows[0], pairRows[0], pairRows[1]].join('\n')}\n`);
|
|
843
|
+
|
|
844
|
+
const atCap = buildSameSignatureRepo('peek-same-sig-cap-32', 32);
|
|
845
|
+
const overCap = buildSameSignatureRepo('peek-same-sig-over-33', 33);
|
|
846
|
+
const expected32 = Array.from({ length: 32 }, (_, idx) => `E-${String(idx + 1).padStart(4, '0')}`);
|
|
847
|
+
|
|
848
|
+
const actionEvent = { phase: 'action', tool: 'shell', command: 'git commit', outcome: { failed: 'unknown' } };
|
|
849
|
+
const failureEvent = {
|
|
850
|
+
phase: 'failure',
|
|
851
|
+
tool: 'shell',
|
|
852
|
+
command: 'git commit -m "Bad Subject"',
|
|
853
|
+
outcome: { failed: true, output: COMMITLINT_OUTPUT }
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
for (const implementation of [matcher, packagedMatcher]) {
|
|
857
|
+
assert.deepEqual(
|
|
858
|
+
implementation.peekRepoMatches({ workspaceRoot: pair.root, event: actionEvent }),
|
|
859
|
+
['E-0001', 'E-0002'],
|
|
860
|
+
'peek returns both ids for two same-signature repo records at action'
|
|
861
|
+
);
|
|
862
|
+
assert.deepEqual(
|
|
863
|
+
implementation.peekRepoMatches({ workspaceRoot: pair.root, event: failureEvent }),
|
|
864
|
+
['E-0001', 'E-0002'],
|
|
865
|
+
'peek returns both ids for two same-signature repo records at failure'
|
|
866
|
+
);
|
|
867
|
+
assert.deepEqual(
|
|
868
|
+
implementation.peekRepoMatches({ workspaceRoot: reversedRoot, event: actionEvent }),
|
|
869
|
+
['E-0001', 'E-0002'],
|
|
870
|
+
'peek keeps deterministic id order regardless of index order'
|
|
871
|
+
);
|
|
872
|
+
assert.deepEqual(
|
|
873
|
+
implementation.peekRepoMatches({ workspaceRoot: duplicateIdRoot, event: actionEvent }),
|
|
874
|
+
['E-0001', 'E-0002'],
|
|
875
|
+
'peek deduplicates repeated id rows'
|
|
876
|
+
);
|
|
877
|
+
|
|
878
|
+
const baselineDelivery = implementation.matchLedgerLessons(input({
|
|
879
|
+
workspaceRoot: single.root,
|
|
880
|
+
stateDir: stateDir('delivery-single'),
|
|
881
|
+
event: actionEvent
|
|
882
|
+
}));
|
|
883
|
+
const pairDelivery = implementation.matchLedgerLessons(input({
|
|
884
|
+
workspaceRoot: pair.root,
|
|
885
|
+
stateDir: stateDir('delivery-pair'),
|
|
886
|
+
event: actionEvent
|
|
887
|
+
}));
|
|
888
|
+
assert.deepEqual(pairDelivery?.ids, ['E-0001'], 'delivery still collapses same-signature records to one lesson');
|
|
889
|
+
assert.equal(pairDelivery?.text, baselineDelivery?.text, 'delivery text for same-signature pair is unchanged');
|
|
890
|
+
assert.ok(!pairDelivery?.text.includes('SAME_SIGNATURE_SECOND_LESSON_SENTINEL'),
|
|
891
|
+
'second same-signature lesson is not delivered');
|
|
892
|
+
|
|
893
|
+
const pairFailureDelivery = implementation.matchLedgerLessons(input({
|
|
894
|
+
workspaceRoot: pair.root,
|
|
895
|
+
stateDir: stateDir('delivery-pair-failure'),
|
|
896
|
+
event: failureEvent
|
|
897
|
+
}));
|
|
898
|
+
const baselineFailureDelivery = implementation.matchLedgerLessons(input({
|
|
899
|
+
workspaceRoot: single.root,
|
|
900
|
+
stateDir: stateDir('delivery-single-failure'),
|
|
901
|
+
event: failureEvent
|
|
902
|
+
}));
|
|
903
|
+
assert.deepEqual(pairFailureDelivery?.ids, ['E-0001'], 'failure delivery still collapses same-signature records');
|
|
904
|
+
assert.equal(pairFailureDelivery?.text, baselineFailureDelivery?.text, 'failure delivery text is unchanged');
|
|
905
|
+
|
|
906
|
+
assert.deepEqual(
|
|
907
|
+
implementation.peekRepoMatches({ workspaceRoot: atCap.root, event: actionEvent }),
|
|
908
|
+
expected32,
|
|
909
|
+
'peek returns all 32 unique ids up to the candidate bound'
|
|
910
|
+
);
|
|
911
|
+
assert.deepEqual(
|
|
912
|
+
implementation.peekRepoMatches({ workspaceRoot: overCap.root, event: actionEvent }),
|
|
913
|
+
[],
|
|
914
|
+
'peek enforces the 32-candidate bound by failing open above cap'
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
});
|