harness-everything 1.1.1 → 1.2.1
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 +18 -0
- package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/README.md +32 -0
- package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/claude-records.json +1 -0
- package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/codex-hook-trace.txt +24 -0
- package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/opencode-records.json +1 -0
- package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/probe.sh +16 -0
- package/ci/mechanism-496-local-error-store.test.js +188 -5
- package/ci/mechanism-498-local-store-promote.test.js +402 -0
- package/ci/mechanism-498-local-store-scan.test.js +582 -0
- package/error-ledger-bootstrap/SKILL.md +1 -1
- package/error-ledger-bootstrap/references/workflow.md +15 -1
- package/error-ledger-bootstrap/scripts/promote.js +145 -9
- package/error-ledger-bootstrap/scripts/scan.js +394 -3
- package/hooks/scripts/lib/local-errors.js +24 -7
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -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/lib/local-errors.js +24 -7
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +15 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +145 -9
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +394 -3
- package/sbom.cdx.json +7 -7
|
@@ -7,10 +7,14 @@ const fs = require('node:fs');
|
|
|
7
7
|
const os = require('node:os');
|
|
8
8
|
const path = require('node:path');
|
|
9
9
|
|
|
10
|
-
const USAGE = 'usage: node scan.js --root <repo> [--out <dir>] [--no-memory] [--memory <path>]... [--instructions <path>]... [--tracker <file.json>]... [--hide-ledger] [--home <dir>] [--json]';
|
|
10
|
+
const USAGE = 'usage: node scan.js --root <repo> [--out <dir>] [--no-memory] [--memory <path>]... [--instructions <path>]... [--tracker <file.json>]... [--source local-store --destination harness|project] [--hide-ledger] [--home <dir>] [--json]';
|
|
11
11
|
const HASH = /^[0-9a-f]{40}$/i;
|
|
12
|
-
const SOURCE_STATUSES = new Set(['used', 'missing', 'disabled', 'unverified']);
|
|
12
|
+
const SOURCE_STATUSES = new Set(['used', 'missing', 'disabled', 'unverified', 'unavailable']);
|
|
13
13
|
const GIT_MAX_BUFFER = 32 * 1024 * 1024;
|
|
14
|
+
const LEDGER_INDEX_MAX_BYTES = 512 * 1024;
|
|
15
|
+
const LOCAL_IDENTIFIER = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
16
|
+
const PROVISIONAL_ID = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
17
|
+
const RECORD_ID = /^E-\d{4,}$/;
|
|
14
18
|
|
|
15
19
|
function failure(message, exitCode = 2) {
|
|
16
20
|
const error = new Error(message);
|
|
@@ -21,7 +25,7 @@ function failure(message, exitCode = 2) {
|
|
|
21
25
|
function parseArgs(args) {
|
|
22
26
|
const options = { memory: [], instructions: [], tracker: [], noMemory: false, hideLedger: false, json: false };
|
|
23
27
|
const seen = new Set();
|
|
24
|
-
const values = new Set(['--root', '--out', '--home', '--memory', '--instructions', '--tracker']);
|
|
28
|
+
const values = new Set(['--root', '--out', '--home', '--memory', '--instructions', '--tracker', '--source', '--destination']);
|
|
25
29
|
for (let i = 0; i < args.length; i++) {
|
|
26
30
|
const arg = args[i];
|
|
27
31
|
if (arg === '--no-memory' || arg === '--hide-ledger' || arg === '--json') {
|
|
@@ -44,6 +48,12 @@ function parseArgs(args) {
|
|
|
44
48
|
options[arg.slice(2)] = value;
|
|
45
49
|
}
|
|
46
50
|
if (!options.root) failure(`--root is required; ${USAGE}`);
|
|
51
|
+
if (options.source !== undefined && options.source !== 'local-store') failure(`unknown source: ${options.source}`);
|
|
52
|
+
if (options.source === 'local-store' && !options.destination) failure('--destination is required for --source local-store');
|
|
53
|
+
if (options.destination !== undefined && options.source !== 'local-store') failure('--destination requires --source local-store');
|
|
54
|
+
if (options.destination !== undefined && !['harness', 'project'].includes(options.destination)) {
|
|
55
|
+
failure(`invalid --destination: ${options.destination}`);
|
|
56
|
+
}
|
|
47
57
|
return options;
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -444,6 +454,369 @@ function collectSources(options, root, home, files, historyCandidates) {
|
|
|
444
454
|
return { sources, candidates };
|
|
445
455
|
}
|
|
446
456
|
|
|
457
|
+
function localStoreRef(workspaceKey, provisionalId) {
|
|
458
|
+
const key = JSON.stringify([workspaceKey, provisionalId]);
|
|
459
|
+
return `p-local-${crypto.createHash('sha256').update(key).digest('hex')}`;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function workspaceRef(workspaceKey) {
|
|
463
|
+
return `w-local-${crypto.createHash('sha256').update(workspaceKey).digest('hex')}`;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function validLocalRecord(record, workspaceKey, store) {
|
|
467
|
+
if (!record || typeof record !== 'object' || Array.isArray(record) ||
|
|
468
|
+
record.schemaVersion !== store.SCHEMA_VERSION ||
|
|
469
|
+
!['occurrence', 'provisional-lesson'].includes(record.kind) ||
|
|
470
|
+
record.workspaceKey !== workspaceKey ||
|
|
471
|
+
typeof record.provisionalId !== 'string' || !PROVISIONAL_ID.test(record.provisionalId) || /^E-/i.test(record.provisionalId) ||
|
|
472
|
+
!store.DESTINATIONS.includes(record.destination) ||
|
|
473
|
+
typeof record.signature !== 'string' || !LOCAL_IDENTIFIER.test(record.signature) ||
|
|
474
|
+
typeof record.createdAt !== 'string' || !Number.isFinite(Date.parse(record.createdAt))) return false;
|
|
475
|
+
if (record.kind === 'occurrence') {
|
|
476
|
+
return record.source === 'tool-failure' && ['claude', 'codex', 'opencode', 'unknown'].includes(record.host) &&
|
|
477
|
+
store.COMMAND_CLASSES.includes(record.commandClass) &&
|
|
478
|
+
(record.exitCode === null || Number.isSafeInteger(record.exitCode)) &&
|
|
479
|
+
(record.sessionKey === null || /^[a-f0-9]{24}$/.test(record.sessionKey)) &&
|
|
480
|
+
(record.toolUseId === null || /^[a-f0-9]{24}$/.test(record.toolUseId)) &&
|
|
481
|
+
typeof record.outputExcerpt === 'string' && Buffer.byteLength(record.outputExcerpt, 'utf8') <= store.LIMITS.maxExcerptBytes &&
|
|
482
|
+
Array.isArray(record.matchedLedgerIds) && record.matchedLedgerIds.length <= store.LIMITS.maxMatchedLedgerIds &&
|
|
483
|
+
record.matchedLedgerIds.every(id => typeof id === 'string' && (RECORD_ID.test(id) || LOCAL_IDENTIFIER.test(id)));
|
|
484
|
+
}
|
|
485
|
+
try {
|
|
486
|
+
store.validateMatch(record.match);
|
|
487
|
+
} catch (_) { return false; }
|
|
488
|
+
return typeof record.lesson === 'string' && record.lesson.trim().length > 0 &&
|
|
489
|
+
Buffer.byteLength(record.lesson, 'utf8') <= store.LIMITS.maxLessonChars &&
|
|
490
|
+
(record.cue === undefined || (typeof record.cue === 'string' && Buffer.byteLength(record.cue, 'utf8') <= store.LIMITS.maxCueChars)) &&
|
|
491
|
+
(record.issueUrl === null || typeof record.issueUrl === 'string') &&
|
|
492
|
+
(record.promotionId === null || (typeof record.promotionId === 'string' && RECORD_ID.test(record.promotionId)));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function validLocalStoreReader(store) {
|
|
496
|
+
try {
|
|
497
|
+
if (!store || typeof store !== 'object' || Array.isArray(store)) return false;
|
|
498
|
+
const destinations = store.DESTINATIONS;
|
|
499
|
+
const commandClasses = store.COMMAND_CLASSES;
|
|
500
|
+
const limits = store.LIMITS;
|
|
501
|
+
const validEnum = (values, required) => Array.isArray(values) &&
|
|
502
|
+
required.every(value => values.includes(value)) &&
|
|
503
|
+
values.every((value, index) => typeof value === 'string' && value.length > 0 && values.indexOf(value) === index);
|
|
504
|
+
return Number.isSafeInteger(store.SCHEMA_VERSION) && store.SCHEMA_VERSION > 0 &&
|
|
505
|
+
typeof store.INDEX_FILE === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(store.INDEX_FILE) &&
|
|
506
|
+
typeof store.INDEX_KIND === 'string' && store.INDEX_KIND.length > 0 &&
|
|
507
|
+
validEnum(destinations, ['harness', 'project', 'unknown']) &&
|
|
508
|
+
validEnum(commandClasses, ['git', 'gh', 'test', 'build', 'package', 'shell']) &&
|
|
509
|
+
limits !== null && typeof limits === 'object' && !Array.isArray(limits) &&
|
|
510
|
+
['maxIndexBytes', 'maxExcerptBytes', 'maxMatchedLedgerIds', 'maxLessonChars', 'maxCueChars']
|
|
511
|
+
.every(name => Number.isSafeInteger(limits[name]) && limits[name] > 0) &&
|
|
512
|
+
['getStorePath', 'resolveWorkspaceKey', 'listRecords', 'validateMatch']
|
|
513
|
+
.every(name => typeof store[name] === 'function');
|
|
514
|
+
} catch (_) { return false; }
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function inspectLocalStore(file, store) {
|
|
518
|
+
let stat;
|
|
519
|
+
try { stat = fs.lstatSync(file); }
|
|
520
|
+
catch (cause) {
|
|
521
|
+
return cause.code === 'ENOENT'
|
|
522
|
+
? { status: 'missing', reason: 'index-missing' }
|
|
523
|
+
: { status: 'unverified', reason: 'store-unreadable' };
|
|
524
|
+
}
|
|
525
|
+
if (stat.isSymbolicLink() || !stat.isFile()) return { status: 'unverified', reason: 'store-unreadable' };
|
|
526
|
+
if (stat.size > store.LIMITS.maxIndexBytes) return { status: 'unverified', reason: 'store-corrupt' };
|
|
527
|
+
let envelope;
|
|
528
|
+
try {
|
|
529
|
+
const bytes = fs.readFileSync(file);
|
|
530
|
+
if (bytes.length > store.LIMITS.maxIndexBytes) return { status: 'unverified', reason: 'store-corrupt' };
|
|
531
|
+
envelope = JSON.parse(bytes.toString('utf8'));
|
|
532
|
+
} catch (_) { return { status: 'unverified', reason: 'store-corrupt' }; }
|
|
533
|
+
if (!envelope || typeof envelope !== 'object' || Array.isArray(envelope) || !Array.isArray(envelope.records)) {
|
|
534
|
+
return { status: 'unverified', reason: 'store-corrupt' };
|
|
535
|
+
}
|
|
536
|
+
if (envelope.schemaVersion !== store.SCHEMA_VERSION || envelope.kind !== store.INDEX_KIND) {
|
|
537
|
+
return { status: 'unverified', reason: 'store-unsupported' };
|
|
538
|
+
}
|
|
539
|
+
return { status: 'used', rowCount: envelope.records.length };
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function inspectDestinationLedger(root, store) {
|
|
543
|
+
const errors = path.join(root, '.agents', 'harness-everything', 'errors');
|
|
544
|
+
let errorsStat;
|
|
545
|
+
try { errorsStat = fs.lstatSync(errors); }
|
|
546
|
+
catch (cause) {
|
|
547
|
+
return cause.code === 'ENOENT'
|
|
548
|
+
? { status: 'unverified', reason: 'ledger-missing', rows: [] }
|
|
549
|
+
: { status: 'unverified', reason: 'ledger-unreadable', rows: [] };
|
|
550
|
+
}
|
|
551
|
+
if (errorsStat.isSymbolicLink() || !errorsStat.isDirectory()) return { status: 'unverified', reason: 'ledger-unreadable', rows: [] };
|
|
552
|
+
let realErrors;
|
|
553
|
+
try { realErrors = canonical(errors); }
|
|
554
|
+
catch (_) { return { status: 'unverified', reason: 'ledger-unreadable', rows: [] }; }
|
|
555
|
+
if (!isWithin(root, realErrors)) return { status: 'unverified', reason: 'ledger-unreadable', rows: [] };
|
|
556
|
+
|
|
557
|
+
const file = path.join(realErrors, 'index.jsonl');
|
|
558
|
+
let stat;
|
|
559
|
+
try { stat = fs.lstatSync(file); }
|
|
560
|
+
catch (cause) {
|
|
561
|
+
return cause.code === 'ENOENT'
|
|
562
|
+
? { status: 'unverified', reason: 'ledger-missing', rows: [] }
|
|
563
|
+
: { status: 'unverified', reason: 'ledger-unreadable', rows: [] };
|
|
564
|
+
}
|
|
565
|
+
if (stat.isSymbolicLink() || !stat.isFile()) return { status: 'unverified', reason: 'ledger-unreadable', rows: [] };
|
|
566
|
+
if (stat.size > LEDGER_INDEX_MAX_BYTES) return { status: 'unverified', reason: 'ledger-corrupt', rows: [] };
|
|
567
|
+
|
|
568
|
+
let text;
|
|
569
|
+
try {
|
|
570
|
+
text = fs.readFileSync(file, 'utf8');
|
|
571
|
+
if (Buffer.byteLength(text, 'utf8') > LEDGER_INDEX_MAX_BYTES) return { status: 'unverified', reason: 'ledger-corrupt', rows: [] };
|
|
572
|
+
} catch (_) { return { status: 'unverified', reason: 'ledger-unreadable', rows: [] }; }
|
|
573
|
+
|
|
574
|
+
const lines = text.split(/\r?\n/);
|
|
575
|
+
if (lines.at(-1) === '') lines.pop();
|
|
576
|
+
if (lines.length > 512 || lines.some(line => !line.trim())) return { status: 'unverified', reason: 'ledger-corrupt', rows: [] };
|
|
577
|
+
const rows = [];
|
|
578
|
+
const ids = new Set();
|
|
579
|
+
try {
|
|
580
|
+
for (const line of lines) {
|
|
581
|
+
const row = JSON.parse(line);
|
|
582
|
+
if (!row || typeof row !== 'object' || Array.isArray(row) ||
|
|
583
|
+
typeof row.id !== 'string' || !RECORD_ID.test(row.id) || ids.has(row.id) ||
|
|
584
|
+
typeof row.signature !== 'string' || !LOCAL_IDENTIFIER.test(row.signature) ||
|
|
585
|
+
typeof row.file !== 'string' || !new RegExp(`^\\.agents/harness-everything/errors/${row.id}-[a-z0-9-]+\\.md$`).test(row.file)) {
|
|
586
|
+
throw new Error('invalid index row');
|
|
587
|
+
}
|
|
588
|
+
let match = null;
|
|
589
|
+
if (Object.hasOwn(row, 'match')) {
|
|
590
|
+
match = store.validateMatch(row.match);
|
|
591
|
+
if (typeof row.matchBinding !== 'string' || !/^[a-f0-9]{64}$/.test(row.matchBinding)) throw new Error('invalid match binding');
|
|
592
|
+
} else if (Object.hasOwn(row, 'matchBinding')) throw new Error('invalid match binding');
|
|
593
|
+
ids.add(row.id);
|
|
594
|
+
rows.push({ id: row.id, signature: row.signature, match });
|
|
595
|
+
}
|
|
596
|
+
} catch (_) { return { status: 'unverified', reason: 'ledger-corrupt', rows: [] }; }
|
|
597
|
+
return { status: 'verified', rows };
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function canonicalMatch(match, store) {
|
|
601
|
+
const validated = store.validateMatch(match);
|
|
602
|
+
const normalized = {};
|
|
603
|
+
for (const phase of ['actions', 'failures']) {
|
|
604
|
+
if (!validated[phase]) continue;
|
|
605
|
+
normalized[phase] = validated[phase].map(rule => ({
|
|
606
|
+
...rule,
|
|
607
|
+
...(rule.diagnostics ? { diagnostics: [...rule.diagnostics].sort() } : {})
|
|
608
|
+
})).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
|
|
609
|
+
}
|
|
610
|
+
return JSON.stringify(normalized);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function destinationDedupe(signature, match, ledger, store) {
|
|
614
|
+
if (ledger.status !== 'verified') {
|
|
615
|
+
return { status: 'unverified', classIds: [], matchedBy: [], newClassEligible: false };
|
|
616
|
+
}
|
|
617
|
+
const matches = new Map();
|
|
618
|
+
const localMatch = match ? canonicalMatch(match, store) : null;
|
|
619
|
+
for (const row of ledger.rows) {
|
|
620
|
+
const methods = [];
|
|
621
|
+
if (row.signature === signature) methods.push('signature');
|
|
622
|
+
if (localMatch && row.match && canonicalMatch(row.match, store) === localMatch) methods.push('whole-rule');
|
|
623
|
+
if (methods.length) matches.set(row.id, new Set([...(matches.get(row.id) || []), ...methods]));
|
|
624
|
+
}
|
|
625
|
+
const classIds = [...matches.keys()].sort();
|
|
626
|
+
const matchedBy = [...new Set([...matches.values()].flatMap(methods => [...methods]))].sort();
|
|
627
|
+
return {
|
|
628
|
+
status: classIds.length > 1 ? 'ambiguous' : classIds.length === 1 ? 'existing' : 'none',
|
|
629
|
+
classIds,
|
|
630
|
+
matchedBy,
|
|
631
|
+
newClassEligible: classIds.length === 0
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function localCandidate(title, signature, records, match, ledger, store, destination) {
|
|
636
|
+
const candidate = makeCandidate({
|
|
637
|
+
title,
|
|
638
|
+
signature,
|
|
639
|
+
sites: [],
|
|
640
|
+
sources: records.map(record => ({
|
|
641
|
+
type: 'local-store',
|
|
642
|
+
kind: record.kind,
|
|
643
|
+
ref: localStoreRef(record.workspaceKey, record.provisionalId),
|
|
644
|
+
destination,
|
|
645
|
+
signature: record.signature,
|
|
646
|
+
...(record.kind === 'occurrence' ? { commandClass: record.commandClass } : {})
|
|
647
|
+
}))
|
|
648
|
+
});
|
|
649
|
+
candidate.local = {
|
|
650
|
+
evidenceReadiness: 'needs-evidence',
|
|
651
|
+
occurrenceCount: records.filter(record => record.kind === 'occurrence').length,
|
|
652
|
+
dedupe: destinationDedupe(signature, match, ledger, store)
|
|
653
|
+
};
|
|
654
|
+
return candidate;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
function collectLocalStore(options, root) {
|
|
658
|
+
const fallbackWorkspaceRef = workspaceRef(root);
|
|
659
|
+
const emptyCounts = { workspaceRecords: 0, lessons: 0, occurrences: 0, candidates: 0, destinationMismatch: 0, unknownDestination: 0, malformed: 0, suppressedOccurrences: 0 };
|
|
660
|
+
let store;
|
|
661
|
+
try { store = require(path.join(__dirname, '..', '..', 'hooks', 'scripts', 'lib', 'local-errors.js')); }
|
|
662
|
+
catch (_) {
|
|
663
|
+
const ledger = { status: 'unverified', reason: 'ledger-not-checked' };
|
|
664
|
+
return {
|
|
665
|
+
source: sourceStatus('local-store', 'workspace', 'unavailable', {
|
|
666
|
+
reason: 'reader-unavailable', workspaceRef: fallbackWorkspaceRef, destination: options.destination,
|
|
667
|
+
ledgerStatus: ledger.status, ledgerReason: ledger.reason,
|
|
668
|
+
counts: { workspaceRecords: 0, lessons: 0, occurrences: 0, candidates: 0, destinationMismatch: 0, unknownDestination: 0, malformed: 0, suppressedOccurrences: 0 }
|
|
669
|
+
}),
|
|
670
|
+
candidates: []
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
if (!validLocalStoreReader(store)) {
|
|
674
|
+
return {
|
|
675
|
+
source: sourceStatus('local-store', 'workspace', 'unavailable', {
|
|
676
|
+
reason: 'reader-contract-incomplete', workspaceRef: fallbackWorkspaceRef, destination: options.destination,
|
|
677
|
+
ledgerStatus: 'unverified', ledgerReason: 'ledger-not-checked', counts: emptyCounts
|
|
678
|
+
}),
|
|
679
|
+
candidates: []
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
let workspaceKey;
|
|
684
|
+
try { workspaceKey = store.resolveWorkspaceKey({ workspaceRoot: root }); }
|
|
685
|
+
catch (_) {
|
|
686
|
+
return {
|
|
687
|
+
source: sourceStatus('local-store', 'workspace', 'unverified', {
|
|
688
|
+
reason: 'workspace-unavailable', workspaceRef: fallbackWorkspaceRef, destination: options.destination,
|
|
689
|
+
ledgerStatus: 'unverified', ledgerReason: 'ledger-not-checked',
|
|
690
|
+
counts: emptyCounts
|
|
691
|
+
}),
|
|
692
|
+
candidates: []
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
const ref = workspaceRef(workspaceKey);
|
|
696
|
+
const hostBinding = ['HARNESS_WORKSPACE_ROOT', 'CLAUDE_PROJECT_DIR', 'CODEX_PROJECT_DIR']
|
|
697
|
+
.some(name => typeof process.env[name] === 'string' && process.env[name].trim());
|
|
698
|
+
if (hostBinding) {
|
|
699
|
+
let hostKey;
|
|
700
|
+
try { hostKey = store.resolveWorkspaceKey({}, { env: process.env }); }
|
|
701
|
+
catch (_) {
|
|
702
|
+
return {
|
|
703
|
+
source: sourceStatus('local-store', 'workspace', 'unverified', {
|
|
704
|
+
reason: 'workspace-binding-unavailable', workspaceRef: ref, destination: options.destination,
|
|
705
|
+
ledgerStatus: 'unverified', ledgerReason: 'ledger-not-checked',
|
|
706
|
+
counts: emptyCounts
|
|
707
|
+
}),
|
|
708
|
+
candidates: []
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
if (hostKey !== workspaceKey) {
|
|
712
|
+
return {
|
|
713
|
+
source: sourceStatus('local-store', 'workspace', 'unverified', {
|
|
714
|
+
reason: 'workspace-binding-mismatch', workspaceRef: ref, destination: options.destination,
|
|
715
|
+
ledgerStatus: 'unverified', ledgerReason: 'ledger-not-checked',
|
|
716
|
+
counts: emptyCounts
|
|
717
|
+
}),
|
|
718
|
+
candidates: []
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
let storePath;
|
|
724
|
+
try { storePath = store.getStorePath().file; }
|
|
725
|
+
catch (_) {
|
|
726
|
+
return {
|
|
727
|
+
source: sourceStatus('local-store', 'workspace', 'unverified', {
|
|
728
|
+
reason: 'store-unreadable', workspaceRef: ref, destination: options.destination,
|
|
729
|
+
ledgerStatus: 'unverified', ledgerReason: 'ledger-not-checked',
|
|
730
|
+
counts: emptyCounts
|
|
731
|
+
}),
|
|
732
|
+
candidates: []
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
const diagnostic = inspectLocalStore(storePath, store);
|
|
736
|
+
const ledger = inspectDestinationLedger(root, store);
|
|
737
|
+
if (diagnostic.status !== 'used') {
|
|
738
|
+
return {
|
|
739
|
+
source: sourceStatus('local-store', 'workspace', diagnostic.status, {
|
|
740
|
+
reason: diagnostic.reason, workspaceRef: ref, destination: options.destination,
|
|
741
|
+
ledgerStatus: ledger.status, ...(ledger.reason ? { ledgerReason: ledger.reason } : {}), counts: emptyCounts
|
|
742
|
+
}),
|
|
743
|
+
candidates: []
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
let records;
|
|
748
|
+
try {
|
|
749
|
+
records = store.listRecords({ workspaceRoot: root, workspaceKey });
|
|
750
|
+
} catch (_) {
|
|
751
|
+
return {
|
|
752
|
+
source: sourceStatus('local-store', 'workspace', 'unverified', {
|
|
753
|
+
reason: 'reader-failed', workspaceRef: ref, destination: options.destination,
|
|
754
|
+
ledgerStatus: ledger.status, ...(ledger.reason ? { ledgerReason: ledger.reason } : {}), counts: emptyCounts
|
|
755
|
+
}),
|
|
756
|
+
candidates: []
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
const scoped = Array.isArray(records) ? records.filter(record => record && record.workspaceKey === workspaceKey) : [];
|
|
760
|
+
let malformed = Array.isArray(records) ? 0 : 1;
|
|
761
|
+
const valid = [];
|
|
762
|
+
const seen = new Set();
|
|
763
|
+
for (const record of scoped) {
|
|
764
|
+
const key = `${record.kind}:${record.provisionalId}`;
|
|
765
|
+
if (!validLocalRecord(record, workspaceKey, store) || seen.has(key)) {
|
|
766
|
+
malformed += 1;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
seen.add(key);
|
|
770
|
+
valid.push(record);
|
|
771
|
+
}
|
|
772
|
+
const idKinds = new Map();
|
|
773
|
+
for (const record of valid) {
|
|
774
|
+
const kinds = idKinds.get(record.provisionalId) || new Set();
|
|
775
|
+
kinds.add(record.kind);
|
|
776
|
+
idKinds.set(record.provisionalId, kinds);
|
|
777
|
+
}
|
|
778
|
+
const collisions = new Set([...idKinds].filter(([, kinds]) => kinds.size > 1).map(([id]) => id));
|
|
779
|
+
const unambiguous = valid.filter(record => {
|
|
780
|
+
if (!collisions.has(record.provisionalId)) return true;
|
|
781
|
+
malformed += 1;
|
|
782
|
+
return false;
|
|
783
|
+
});
|
|
784
|
+
const counts = { ...emptyCounts, workspaceRecords: unambiguous.length, malformed };
|
|
785
|
+
const selected = [];
|
|
786
|
+
for (const record of unambiguous) {
|
|
787
|
+
if (record.destination === 'unknown') { counts.unknownDestination += 1; continue; }
|
|
788
|
+
if (record.destination !== options.destination) { counts.destinationMismatch += 1; continue; }
|
|
789
|
+
selected.push(record);
|
|
790
|
+
if (record.kind === 'provisional-lesson') counts.lessons += 1;
|
|
791
|
+
else counts.occurrences += 1;
|
|
792
|
+
}
|
|
793
|
+
const lessons = selected.filter(record => record.kind === 'provisional-lesson');
|
|
794
|
+
const covered = new Set(lessons.map(record => record.signature));
|
|
795
|
+
const candidates = lessons.map(record => localCandidate(
|
|
796
|
+
'Local provisional lesson', record.signature, [record], record.match, ledger, store, options.destination
|
|
797
|
+
));
|
|
798
|
+
const occurrences = new Map();
|
|
799
|
+
for (const record of selected.filter(record => record.kind === 'occurrence')) {
|
|
800
|
+
if (covered.has(record.signature)) { counts.suppressedOccurrences += 1; continue; }
|
|
801
|
+
const group = occurrences.get(record.signature) || [];
|
|
802
|
+
group.push(record);
|
|
803
|
+
occurrences.set(record.signature, group);
|
|
804
|
+
}
|
|
805
|
+
for (const [signature, group] of occurrences) {
|
|
806
|
+
candidates.push(localCandidate('Local tool-failure lead', signature, group, null, ledger, store, options.destination));
|
|
807
|
+
}
|
|
808
|
+
counts.candidates = candidates.length;
|
|
809
|
+
const status = malformed || scoped.length === 0 ? 'unverified' : 'used';
|
|
810
|
+
const reason = collisions.size ? 'provisional-id-collision' : malformed ? 'malformed-records' : scoped.length === 0 ? 'empty-reader-result' : undefined;
|
|
811
|
+
return {
|
|
812
|
+
source: sourceStatus('local-store', 'workspace', status, {
|
|
813
|
+
...(reason ? { reason } : {}), workspaceRef: ref, destination: options.destination,
|
|
814
|
+
ledgerStatus: ledger.status, ...(ledger.reason ? { ledgerReason: ledger.reason } : {}), counts
|
|
815
|
+
}),
|
|
816
|
+
candidates
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
|
|
447
820
|
function addAttachments(candidates, files, root, hideLedger) {
|
|
448
821
|
const testFiles = files.filter(file => {
|
|
449
822
|
const base = path.posix.basename(file);
|
|
@@ -498,10 +871,23 @@ function markdownReport(report) {
|
|
|
498
871
|
for (const source of report.sources) {
|
|
499
872
|
const label = source.ref || (source.refs && source.refs.join(', ')) || source.origin;
|
|
500
873
|
lines.push(`- \`${source.type}\` (${source.origin}) — **${source.status}** — ${label}${source.reason ? ` — ${source.reason}` : ''}${source.verified === undefined ? '' : ` — verified: ${source.verified}`}${source.verificationRef ? ` — verification: ${source.verificationRef}` : ''}`);
|
|
874
|
+
if (source.type === 'local-store') {
|
|
875
|
+
lines.push(` - Workspace ref: \`${source.workspaceRef}\``, ` - Destination: \`${source.destination}\``,
|
|
876
|
+
` - Records: ${source.counts.workspaceRecords}; lessons: ${source.counts.lessons}; occurrences: ${source.counts.occurrences}; candidates: ${source.counts.candidates}`,
|
|
877
|
+
` - Destination mismatches: ${source.counts.destinationMismatch}; unknown destinations: ${source.counts.unknownDestination}; malformed: ${source.counts.malformed}; suppressed occurrences: ${source.counts.suppressedOccurrences}`,
|
|
878
|
+
` - Destination ledger dedupe: **${source.ledgerStatus}**${source.ledgerReason ? ` — ${source.ledgerReason}` : ''}`);
|
|
879
|
+
}
|
|
501
880
|
}
|
|
502
881
|
lines.push('', '## Candidates', '');
|
|
503
882
|
for (const item of report.candidates) {
|
|
504
883
|
lines.push(`### ${item.title}`, '', `- ID: \`${item.id}\``, `- Kind: \`${item.kind}\``, `- Domain: \`${item.domain}\``, `- Signature: \`${item.signature}\``, `- Status: **${item.status}**`, `- Sites: ${item.sites.length ? item.sites.map(site => `\`${site}\``).join(', ') : 'none'}`, '- Sources:');
|
|
884
|
+
if (item.local) {
|
|
885
|
+
lines.push(`- Evidence readiness: **${item.local.evidenceReadiness}**`,
|
|
886
|
+
`- Occurrence count: ${item.local.occurrenceCount}`,
|
|
887
|
+
`- Destination dedupe: **${item.local.dedupe.status}**${item.local.dedupe.classIds.length ? ` — ${item.local.dedupe.classIds.map(id => `\`${id}\``).join(', ')}` : ''}`,
|
|
888
|
+
`- Exact match signals: ${item.local.dedupe.matchedBy.length ? item.local.dedupe.matchedBy.join(', ') : 'none'}`,
|
|
889
|
+
`- New-class dedupe eligible: ${item.local.dedupe.newClassEligible}`);
|
|
890
|
+
}
|
|
505
891
|
for (const source of item.sources) {
|
|
506
892
|
lines.push(` - \`${source.type}\` ${source.ref || source.path || source.sha}${source.path && source.sha ? ` — ${source.sha}` : ''}${source.subject ? ` — ${source.subject}` : ''}`);
|
|
507
893
|
}
|
|
@@ -597,6 +983,11 @@ function scan(options) {
|
|
|
597
983
|
const historyCandidates = parseHistory(root, options.hideLedger);
|
|
598
984
|
const files = repoFiles(root);
|
|
599
985
|
const selected = collectSources(options, root, home, files, historyCandidates);
|
|
986
|
+
if (options.source === 'local-store') {
|
|
987
|
+
const local = collectLocalStore(options, root);
|
|
988
|
+
selected.sources.push(local.source);
|
|
989
|
+
selected.candidates.push(...local.candidates);
|
|
990
|
+
}
|
|
600
991
|
const candidates = [...new Map([...historyCandidates, ...selected.candidates].map(item => [item.id, item])).values()];
|
|
601
992
|
addAttachments(candidates, files, root, options.hideLedger);
|
|
602
993
|
for (const item of candidates) {
|
package/sbom.cdx.json
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
"$schema": "https://cyclonedx.org/schema/bom-1.7.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.7",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:4d2c7e1b-2804-5ea7-9a87-bee3a22e4e60",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-11-
|
|
8
|
+
"timestamp": "2026-11-26T01:54:59.250Z",
|
|
9
9
|
"tools": [
|
|
10
10
|
{
|
|
11
11
|
"vendor": "Harness Everything",
|
|
12
12
|
"name": "generate-sbom.js",
|
|
13
|
-
"version": "1.
|
|
13
|
+
"version": "1.2.1"
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"component": {
|
|
17
17
|
"type": "application",
|
|
18
|
-
"bom-ref": "pkg:npm/harness-everything@1.
|
|
18
|
+
"bom-ref": "pkg:npm/harness-everything@1.2.1",
|
|
19
19
|
"name": "harness-everything",
|
|
20
|
-
"version": "1.
|
|
21
|
-
"purl": "pkg:npm/harness-everything@1.
|
|
20
|
+
"version": "1.2.1",
|
|
21
|
+
"purl": "pkg:npm/harness-everything@1.2.1"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"components": [
|
|
@@ -2033,7 +2033,7 @@
|
|
|
2033
2033
|
]
|
|
2034
2034
|
},
|
|
2035
2035
|
{
|
|
2036
|
-
"ref": "pkg:npm/harness-everything@1.
|
|
2036
|
+
"ref": "pkg:npm/harness-everything@1.2.1",
|
|
2037
2037
|
"dependsOn": [
|
|
2038
2038
|
"pkg:npm/%40commitlint/cli@19.8.1",
|
|
2039
2039
|
"pkg:npm/%40commitlint/config-conventional@19.8.1",
|