@holmes-lab/holmes-kit 0.31.2 → 0.32.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/CHANGELOG.md +54 -0
- package/README.md +1 -0
- package/dist/.build-id +1 -1
- package/dist/holmes/mcp/handlers/maintenance-analysis.js +16 -3
- package/dist/holmes/mcp/handlers/maintenance-evidence.d.ts +6 -0
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +163 -4
- package/dist/holmes/mcp/handlers/requirement-triage.js +26 -18
- package/dist/holmes/mcp/handlers.d.ts +169 -4
- package/dist/holmes/mcp/maintenance-analyze.d.ts +19 -0
- package/dist/holmes/mcp/maintenance-analyze.js +113 -7
- package/dist/holmes/mcp/maintenance-evidence.d.ts +25 -0
- package/dist/holmes/mcp/maintenance-evidence.js +52 -1
- package/dist/holmes/mcp/tool-schemas.js +3 -1
- package/dist/holmes/review/requirement-triage.d.ts +19 -1
- package/dist/holmes/review/requirement-triage.js +113 -12
- package/dist/holmes/rtm/localize.d.ts +7 -0
- package/dist/holmes/rtm/localize.js +10 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { type TestEvidence } from '../review/test-evidence';
|
|
|
9
9
|
import { type LanguageGap } from '../cpg/language-capability';
|
|
10
10
|
export declare const MAINTENANCE_ANALYSIS_SCHEMA = "maintenance-analysis/1.13";
|
|
11
11
|
export declare const MAINTENANCE_ANALYSIS_EXTRACTOR = "holmes-graph-fusion/1.13";
|
|
12
|
+
export declare const CONFIDENCE_NOTE: string;
|
|
12
13
|
/**
|
|
13
14
|
* The evidence kinds an ablation arm can actually produce. Completeness is measured by asking each
|
|
14
15
|
* arm which of these it FILLED — the first cut hardcoded 1 / 2 / 2+n, so "enhanced beats current"
|
|
@@ -159,6 +160,14 @@ export interface MaintenanceAnalysisInput {
|
|
|
159
160
|
scannedFiles: number;
|
|
160
161
|
skippedFiles: readonly string[];
|
|
161
162
|
unsupportedLanguages: readonly string[];
|
|
163
|
+
/**
|
|
164
|
+
* @implements A-SPEC-741 — paths of the files behind `unsupportedLanguages`, so a language counts
|
|
165
|
+
* against THIS request when one of its unreadable files shares a request term (the Ruby
|
|
166
|
+
* `legacy_session.rb` for "isolate the session"). Absent: only changed files and request paths count.
|
|
167
|
+
*/
|
|
168
|
+
unsupportedFiles?: readonly string[];
|
|
169
|
+
/** @implements A-SPEC-741 — the handler capped `unsupportedFiles`; every language then counts. */
|
|
170
|
+
unsupportedFilesTruncated?: boolean;
|
|
162
171
|
historyStatus?: 'available' | 'unavailable' | 'not-requested';
|
|
163
172
|
};
|
|
164
173
|
}
|
|
@@ -177,6 +186,16 @@ export interface MaintenanceAnalysis {
|
|
|
177
186
|
* nobody has a hypothesis for why it inverts.
|
|
178
187
|
*/
|
|
179
188
|
confidence: number;
|
|
189
|
+
/**
|
|
190
|
+
* @implements A-SPEC-740
|
|
191
|
+
* The standing of `confidence`, stated where the number is read — the tool description says it
|
|
192
|
+
* once, but a caller reading this object or a persisted artifact never sees that. A constant
|
|
193
|
+
* `false`: lifting the request-unrelated coverage gates turns 120/120 replay cases into 0.95 at
|
|
194
|
+
* 0.467/0.383 top-1 accuracy (Phase A, 2026-09-30). Only a passing calibration measurement,
|
|
195
|
+
* shipped as its own requirement, may turn it true.
|
|
196
|
+
*/
|
|
197
|
+
confidenceCalibrated: false;
|
|
198
|
+
confidenceNote: string;
|
|
180
199
|
/**
|
|
181
200
|
* @implements A-SPEC-375
|
|
182
201
|
* A-SPECs worth citing, when the request cited nothing. Empty when it already did.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ANALYZE_TEXT_CAP = exports.ANALYZE_LIST_CAP = exports.PRIMARY_TIER_WIDTH = exports.EVIDENCE_DIMENSIONS = exports.MAINTENANCE_ANALYSIS_EXTRACTOR = exports.MAINTENANCE_ANALYSIS_SCHEMA = void 0;
|
|
3
|
+
exports.ANALYZE_TEXT_CAP = exports.ANALYZE_LIST_CAP = exports.PRIMARY_TIER_WIDTH = exports.EVIDENCE_DIMENSIONS = exports.CONFIDENCE_NOTE = exports.MAINTENANCE_ANALYSIS_EXTRACTOR = exports.MAINTENANCE_ANALYSIS_SCHEMA = void 0;
|
|
4
4
|
exports.unquoteGitPath = unquoteGitPath;
|
|
5
5
|
exports.analyzeMaintenance = analyzeMaintenance;
|
|
6
6
|
exports.boundAnalysis = boundAnalysis;
|
|
7
|
-
// @implements A-SPEC-725, A-SPEC-310
|
|
7
|
+
// @implements A-SPEC-745, A-SPEC-741, A-SPEC-740, A-SPEC-725, A-SPEC-310
|
|
8
8
|
// @implements A-SPEC-295
|
|
9
9
|
// @implements A-SPEC-294
|
|
10
10
|
// @implements A-SPEC-293
|
|
@@ -48,6 +48,19 @@ const defuse_symbols_1 = require("../rtm/defuse-symbols");
|
|
|
48
48
|
// artifacts are only comparable when this string matches.
|
|
49
49
|
exports.MAINTENANCE_ANALYSIS_SCHEMA = 'maintenance-analysis/1.13';
|
|
50
50
|
exports.MAINTENANCE_ANALYSIS_EXTRACTOR = 'holmes-graph-fusion/1.13';
|
|
51
|
+
// @implements A-SPEC-741 — tokens for the unreadable-file relevance rule: split on non-alphanumerics
|
|
52
|
+
// and camelCase, lower-cased, length >= 2, NO stop list (a file named `test.sh` or `db.rb` is named).
|
|
53
|
+
function rawTokens(text) {
|
|
54
|
+
return text.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length >= 2);
|
|
55
|
+
}
|
|
56
|
+
/** @implements A-SPEC-741 — words a request uses when it is about a language the scanner cannot read. */
|
|
57
|
+
const LANGUAGE_NAMES = {
|
|
58
|
+
'.sh': ['shell', 'bash', 'sh'], '.rb': ['ruby', 'rails'], '.php': ['php'], '.kt': ['kotlin'], '.kts': ['kotlin'],
|
|
59
|
+
'.swift': ['swift'], '.scala': ['scala'], '.ex': ['elixir'], '.exs': ['elixir'], '.lua': ['lua'],
|
|
60
|
+
};
|
|
61
|
+
// @implements A-SPEC-740
|
|
62
|
+
exports.CONFIDENCE_NOTE = 'confidence is not calibrated: it counts which kinds of evidence were present, '
|
|
63
|
+
+ 'does not predict accuracy, and must not be used to weight answers or to narrow a test scope.';
|
|
51
64
|
/**
|
|
52
65
|
* The evidence kinds an ablation arm can actually produce. Completeness is measured by asking each
|
|
53
66
|
* arm which of these it FILLED — the first cut hardcoded 1 / 2 / 2+n, so "enhanced beats current"
|
|
@@ -589,6 +602,10 @@ function analyzeMaintenance(input) {
|
|
|
589
602
|
}
|
|
590
603
|
frontier = next;
|
|
591
604
|
}
|
|
605
|
+
// Every frontier node is recorded as a stop, including those with no further callers (about half,
|
|
606
|
+
// measured 2026-09-30). A-SPEC-741 first recorded only the ones with unexplored callers; the replay
|
|
607
|
+
// then narrowed 12/120 scopes and 10 of them missed a test the commit changed — the conservative
|
|
608
|
+
// record was masking narrowing from anchors that do not cover the tests, so it stays.
|
|
592
609
|
for (const id of frontier)
|
|
593
610
|
stoppedAt.push({ id, reason: 'depth' });
|
|
594
611
|
const transitive = sortedUnique([...transitiveIds].map(codeQualifiedName).filter((qn) => !direct.includes(qn)));
|
|
@@ -740,6 +757,73 @@ function analyzeMaintenance(input) {
|
|
|
740
757
|
// coexisted with tier `unit`, empty coverage gaps, and no `unknowns` line at all.
|
|
741
758
|
const truncationReasons = sortedUnique(stoppedAt.map((stop) => stop.reason));
|
|
742
759
|
const truncationMarkers = sortedUnique(stoppedAt.map((stop) => `impact-truncated:${stop.reason}:${stop.id}`));
|
|
760
|
+
// @implements A-SPEC-741 — an unsupported language is a gap about THIS change only when the change
|
|
761
|
+
// names it: a changed file with that extension, or a path in the request that ends with it. A CI
|
|
762
|
+
// `.sh` script elsewhere in the tree pinned 455/455 analyses here to `ambiguous` + `full` from
|
|
763
|
+
// 2026-09-03 on. An entry that is not an extension (`not-enumerated(non-git)`) means the analysis
|
|
764
|
+
// could not look at all, so it always counts.
|
|
765
|
+
// A third way in: an unreadable file whose path shares a request term may be the very target the
|
|
766
|
+
// analysis cannot see — `src/legacy_session.rb` for "isolate the session".
|
|
767
|
+
// Review round 1 (2026-09-30): where the rule cannot judge it leans to "relevant" — a false
|
|
768
|
+
// "unrelated" is false confidence. Raw tokens (length >= 2, no stop list: `ci`, `db`, `test` are
|
|
769
|
+
// names), a prefix match from 4 characters (`session`/`sessions`), trailing punctuation stripped
|
|
770
|
+
// from request paths (`ci.sh.`), any non-ASCII letter in the request (a Korean or Japanese request
|
|
771
|
+
// cannot be compared with ASCII paths), and a capped path list all count as "about the change".
|
|
772
|
+
const requestLower = input.request.toLowerCase();
|
|
773
|
+
// Review round 2: a Set, capped — a 500 KB request cost 2.9 s against 5,000 paths when the tokens were
|
|
774
|
+
// an array compared inside the per-file loop.
|
|
775
|
+
// Round 3: de-duplicate FIRST, then cap — a pasted log of repeated lines pushed the file's name past
|
|
776
|
+
// a cap taken over raw tokens.
|
|
777
|
+
// Round 4: tokens over 64 characters (a pasted hex blob, a minified line) are not words.
|
|
778
|
+
const requestTokens = new Set([...new Set(rawTokens(input.request).filter((t) => t.length <= 64))].slice(0, 4096));
|
|
779
|
+
const requestStems = new Set([...requestTokens].filter((t) => t.length >= 5).map((t) => t.slice(0, 5)));
|
|
780
|
+
// Every prefix (>= 4 chars) of every request token, so "a path token is a prefix of a request word"
|
|
781
|
+
// (`auth` / `authentication`) is one lookup instead of a scan.
|
|
782
|
+
// Built on first use only — most analyses never reach the path condition (round 4).
|
|
783
|
+
let requestPrefixes = null;
|
|
784
|
+
const prefixes = () => {
|
|
785
|
+
if (requestPrefixes === null) {
|
|
786
|
+
requestPrefixes = new Set();
|
|
787
|
+
for (const t of requestTokens)
|
|
788
|
+
for (let n = 4; n <= t.length; n++)
|
|
789
|
+
requestPrefixes.add(t.slice(0, n));
|
|
790
|
+
}
|
|
791
|
+
return requestPrefixes;
|
|
792
|
+
};
|
|
793
|
+
const tokenMeetsRequest = (token) => {
|
|
794
|
+
if (requestTokens.has(token))
|
|
795
|
+
return true;
|
|
796
|
+
if (token.length >= 4 && prefixes().has(token))
|
|
797
|
+
return true; // path token ⊑ request word
|
|
798
|
+
for (let n = 4; n < token.length; n++)
|
|
799
|
+
if (requestTokens.has(token.slice(0, n)))
|
|
800
|
+
return true; // request word ⊑ path token
|
|
801
|
+
return token.length >= 5 && requestStems.has(token.slice(0, 5));
|
|
802
|
+
};
|
|
803
|
+
// A LETTER outside ASCII (Hangul, Kana, …) — not an em dash or a curly quote, which every commit subject here uses.
|
|
804
|
+
const requestIsNonAscii = /(?![\x00-\x7f])\p{L}/u.test(input.request);
|
|
805
|
+
const pathsCapped = input.coverage.unsupportedFilesTruncated === true;
|
|
806
|
+
const relevantUnsupported = input.coverage.unsupportedLanguages.filter((language) => {
|
|
807
|
+
if (!language.startsWith('.'))
|
|
808
|
+
return true;
|
|
809
|
+
const ext = language.toLowerCase();
|
|
810
|
+
if ((input.changedFiles ?? []).some((file) => file.toLowerCase().endsWith(ext)))
|
|
811
|
+
return true;
|
|
812
|
+
// A path token ending with the extension: `scripts/ci-local.sh`, not a bare word `sh`.
|
|
813
|
+
if (requestLower.split(/[^\w./-]+/).map((token) => token.replace(/[.,;:!?]+$/, ''))
|
|
814
|
+
.some((token) => token.length > ext.length && token.endsWith(ext)))
|
|
815
|
+
return true;
|
|
816
|
+
// Review round 2: a request that names the language itself (`.sh`, `shell`, `kotlin`) is about it.
|
|
817
|
+
if (requestTokens.has(ext.slice(1)) || (LANGUAGE_NAMES[ext] ?? []).some((name) => requestTokens.has(name)))
|
|
818
|
+
return true;
|
|
819
|
+
const files = (input.coverage.unsupportedFiles ?? []).filter((file) => file.toLowerCase().endsWith(ext));
|
|
820
|
+
if (pathsCapped || (requestIsNonAscii && files.length > 0))
|
|
821
|
+
return true;
|
|
822
|
+
// Every token of the path — folders too (`app/session/store.rb`) — exact, or sharing a 5-letter stem.
|
|
823
|
+
return files.some((file) => rawTokens(file.slice(0, -ext.length)).some(tokenMeetsRequest));
|
|
824
|
+
});
|
|
825
|
+
// The TEST SCOPE keeps every language (A-SPEC-741 revision): relevance decides the classification
|
|
826
|
+
// only. Dropping the unrelated ones from the scope let anchor-based narrowing miss tests on replay.
|
|
743
827
|
const unresolvedCoverage = [
|
|
744
828
|
...input.coverage.skippedFiles,
|
|
745
829
|
...input.coverage.unsupportedLanguages.map((language) => `unsupported:${language}`),
|
|
@@ -759,16 +843,23 @@ function analyzeMaintenance(input) {
|
|
|
759
843
|
.sort((a, b) => b.date.localeCompare(a.date) || a.commit.localeCompare(b.commit));
|
|
760
844
|
const skippedFiles = sortedUnique(input.coverage.skippedFiles);
|
|
761
845
|
const unsupportedLanguages = sortedUnique(input.coverage.unsupportedLanguages);
|
|
762
|
-
|
|
763
|
-
|
|
846
|
+
// @implements A-SPEC-741 — the classification gate holds only gaps about the change. A truncated
|
|
847
|
+
// walk bounds how far the TEST SCOPE can be trusted (it stays in `unresolvedCoverage`, which forces
|
|
848
|
+
// `full`); it says nothing about whether the request maps to an existing requirement.
|
|
849
|
+
const coverageGaps = skippedFiles.length > 0 || relevantUnsupported.length > 0
|
|
850
|
+
|| input.coverage.scannedFiles === 0;
|
|
764
851
|
const stale = input.basis.loadedBuild !== input.basis.diskBuild;
|
|
765
852
|
const unknowns = [];
|
|
766
853
|
if (input.coverage.scannedFiles === 0)
|
|
767
854
|
unknowns.push('No source files were represented in the analyzed graph.');
|
|
768
855
|
if (skippedFiles.length > 0)
|
|
769
856
|
unknowns.push(`Skipped files are outside the evidence basis: ${skippedFiles.join(', ')}`);
|
|
770
|
-
if (unsupportedLanguages.length > 0)
|
|
771
|
-
|
|
857
|
+
if (unsupportedLanguages.length > 0) {
|
|
858
|
+
const outside = unsupportedLanguages.filter((language) => !relevantUnsupported.includes(language));
|
|
859
|
+
unknowns.push(`Unsupported languages are outside the evidence basis: ${unsupportedLanguages.join(', ')}`
|
|
860
|
+
+ (outside.length > 0 ? ` (${outside.join(', ')} judged outside this change for the classification: no changed file, request path or path-sharing file names it; the test scope still counts it)` : '')
|
|
861
|
+
+ (pathsCapped ? ' (the list of unreadable files was capped, so every language counts as about this change)' : ''));
|
|
862
|
+
}
|
|
772
863
|
if (truncationMarkers.length > 0) {
|
|
773
864
|
unknowns.push(`Impact closure was truncated (${truncationReasons.join(', ')}) at ${stoppedAt.length} node(s): callers beyond the bound were never explored, so the transitive impact is a lower bound, not a complete set. Stopped at ${stoppedAt.map((stop) => stop.id).join(', ')}.`);
|
|
774
865
|
}
|
|
@@ -936,17 +1027,32 @@ function analyzeMaintenance(input) {
|
|
|
936
1027
|
+ `scan (libraries and builtins) and ${edgeAmbiguous} are ambiguous. Impact traversal uses only `
|
|
937
1028
|
+ `the resolved ones.`);
|
|
938
1029
|
}
|
|
1030
|
+
// @implements A-SPEC-745 — the same set as `specIds`, emitted in relevance order: the response
|
|
1031
|
+
// bound keeps ten, and id order made those ten A-SPEC-100 and its neighbours for every request.
|
|
1032
|
+
// Cited first, then by the rank of the first candidate file that anchors the spec, then by id.
|
|
1033
|
+
const specRank = new Map();
|
|
1034
|
+
for (const id of (0, localize_1.citationsIn)(input.request, new Set(specIds)).cited)
|
|
1035
|
+
specRank.set(id, -1);
|
|
1036
|
+
const anchorsOf = new Map(scanned.map((file) => [file.sourcePath, file.implementsSpecs]));
|
|
1037
|
+
candidates.forEach((candidate, index) => {
|
|
1038
|
+
for (const id of anchorsOf.get(candidate.file) ?? [])
|
|
1039
|
+
if (!specRank.has(id))
|
|
1040
|
+
specRank.set(id, index);
|
|
1041
|
+
});
|
|
1042
|
+
const relevanceOrderedSpecs = [...specIds].sort((a, b) => (specRank.get(a) ?? Infinity) - (specRank.get(b) ?? Infinity) || a.localeCompare(b));
|
|
939
1043
|
const evidence = {
|
|
940
1044
|
schemaVersion: exports.MAINTENANCE_ANALYSIS_SCHEMA,
|
|
941
1045
|
extractorVersion: exports.MAINTENANCE_ANALYSIS_EXTRACTOR,
|
|
942
1046
|
classification,
|
|
943
1047
|
confidence,
|
|
1048
|
+
confidenceCalibrated: false,
|
|
1049
|
+
confidenceNote: exports.CONFIDENCE_NOTE,
|
|
944
1050
|
citationCandidates,
|
|
945
1051
|
callEdges,
|
|
946
1052
|
candidates,
|
|
947
1053
|
...(semanticAlternates !== undefined ? { semanticAlternates } : {}),
|
|
948
1054
|
rerankPool,
|
|
949
|
-
candidateSpecs:
|
|
1055
|
+
candidateSpecs: relevanceOrderedSpecs,
|
|
950
1056
|
impacts: {
|
|
951
1057
|
files: localizedFiles,
|
|
952
1058
|
tiers: { primary: primaryTier, secondary: secondaryTier },
|
|
@@ -27,6 +27,11 @@ export interface EvidenceArtifact {
|
|
|
27
27
|
extractorVersion: string;
|
|
28
28
|
classification: string;
|
|
29
29
|
confidence: number;
|
|
30
|
+
/**
|
|
31
|
+
* @implements A-SPEC-740 — optional on purpose: an artifact recorded before the marker existed is
|
|
32
|
+
* just as uncalibrated, and the schema string stays 1.4 so calibration still reads it.
|
|
33
|
+
*/
|
|
34
|
+
confidenceCalibrated?: false;
|
|
30
35
|
graphBasis: MaintenanceAnalysis['graphBasis'];
|
|
31
36
|
predicted: {
|
|
32
37
|
files: string[];
|
|
@@ -58,6 +63,9 @@ export interface EvidenceArtifact {
|
|
|
58
63
|
/** The caller walk stopped at a bound: the transitive set is a lower bound, not a complete one. */
|
|
59
64
|
impactTruncated: boolean;
|
|
60
65
|
testScopeTier: string;
|
|
66
|
+
/** @implements A-SPEC-744 — why the scope was what it was; optional so older artifacts still read. */
|
|
67
|
+
testScopeReason?: string;
|
|
68
|
+
testScopeCauses?: string[];
|
|
61
69
|
/** Files reachable only through a call edge — affected, but never analysed as edit candidates. */
|
|
62
70
|
impactedFiles: string[];
|
|
63
71
|
/**
|
|
@@ -170,7 +178,24 @@ export interface Calibration {
|
|
|
170
178
|
falseNegatives: number;
|
|
171
179
|
minSamples: number;
|
|
172
180
|
status: 'measured' | 'insufficient-data';
|
|
181
|
+
/**
|
|
182
|
+
* @implements A-SPEC-744 — how often each cause made a persisted scope `full`. `unrecorded` counts
|
|
183
|
+
* artifacts written before the causes were kept: they are not evidence for any cause.
|
|
184
|
+
*/
|
|
185
|
+
scopeCauses: {
|
|
186
|
+
full: number;
|
|
187
|
+
narrow: number;
|
|
188
|
+
unrecorded: number;
|
|
189
|
+
causes: Record<string, number>;
|
|
190
|
+
};
|
|
173
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* @implements A-SPEC-744
|
|
194
|
+
* The named reasons a test scope is `full`, read from its structured fields — never parsed out of the
|
|
195
|
+
* sentence. 455 persisted analyses were all `full` and none said why; the investigation that followed
|
|
196
|
+
* needed a 120-commit replay to answer a question the analysis had already known.
|
|
197
|
+
*/
|
|
198
|
+
export declare function scopeCauses(scope: MaintenanceAnalysis['testScope']): string[];
|
|
174
199
|
/**
|
|
175
200
|
* Reliability bins plus a Brier score. `minSamples` is the honesty knob: below it a bin reports
|
|
176
201
|
* `insufficient-data` and a null accuracy, because one sample in a bin yields a 0 or a 1 that looks
|
|
@@ -41,8 +41,9 @@ exports.readArtifacts = readArtifacts;
|
|
|
41
41
|
exports.recordOutcome = recordOutcome;
|
|
42
42
|
exports.openArtifacts = openArtifacts;
|
|
43
43
|
exports.closeOpenArtifacts = closeOpenArtifacts;
|
|
44
|
+
exports.scopeCauses = scopeCauses;
|
|
44
45
|
exports.computeCalibration = computeCalibration;
|
|
45
|
-
// @implements A-SPEC-724.1, A-SPEC-271
|
|
46
|
+
// @implements A-SPEC-744, A-SPEC-740, A-SPEC-724.1, A-SPEC-271
|
|
46
47
|
// @implements A-SPEC-268
|
|
47
48
|
const fs = __importStar(require("node:fs"));
|
|
48
49
|
const path = __importStar(require("node:path"));
|
|
@@ -85,6 +86,7 @@ function artifactFrom(analysis, recordedAt, fileDigests = {}) {
|
|
|
85
86
|
extractorVersion: analysis.extractorVersion,
|
|
86
87
|
classification: analysis.classification,
|
|
87
88
|
confidence: analysis.confidence,
|
|
89
|
+
confidenceCalibrated: false,
|
|
88
90
|
graphBasis: analysis.graphBasis,
|
|
89
91
|
predicted: {
|
|
90
92
|
files: sortedUnique(analysis.impacts.files),
|
|
@@ -103,6 +105,8 @@ function artifactFrom(analysis, recordedAt, fileDigests = {}) {
|
|
|
103
105
|
},
|
|
104
106
|
impactTruncated: analysis.impactBounds.stoppedAt.length > 0,
|
|
105
107
|
testScopeTier: analysis.testScope.tier,
|
|
108
|
+
testScopeReason: analysis.testScope.reason,
|
|
109
|
+
testScopeCauses: scopeCauses(analysis.testScope),
|
|
106
110
|
impactedFiles: [...analysis.impacts.impactedFiles],
|
|
107
111
|
securityAssessed: analysis.constraints.security.assessed,
|
|
108
112
|
compatibilityAssessed: analysis.constraints.compatibility.assessed,
|
|
@@ -257,7 +261,53 @@ function closeOpenArtifacts(dir, actual, recordedAt, since) {
|
|
|
257
261
|
}
|
|
258
262
|
return { closed };
|
|
259
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* @implements A-SPEC-744
|
|
266
|
+
* The named reasons a test scope is `full`, read from its structured fields — never parsed out of the
|
|
267
|
+
* sentence. 455 persisted analyses were all `full` and none said why; the investigation that followed
|
|
268
|
+
* needed a 120-commit replay to answer a question the analysis had already known.
|
|
269
|
+
*/
|
|
270
|
+
function scopeCauses(scope) {
|
|
271
|
+
if (scope.tier !== 'full')
|
|
272
|
+
return [];
|
|
273
|
+
const out = new Set();
|
|
274
|
+
for (const entry of scope.unresolvedFiles ?? []) {
|
|
275
|
+
out.add(entry.startsWith('unsupported:') ? 'unsupported-language'
|
|
276
|
+
: entry.startsWith('impact-truncated:') ? 'impact-truncated' : 'unresolved-file');
|
|
277
|
+
}
|
|
278
|
+
if ((scope.architectureTouched ?? []).length > 0)
|
|
279
|
+
out.add('architecture-document');
|
|
280
|
+
if ((scope.obligationGaps ?? []).length > 0)
|
|
281
|
+
out.add('obligation-gap');
|
|
282
|
+
if (scope.coverageGaps.length > 0)
|
|
283
|
+
out.add('coverage-gap');
|
|
284
|
+
if (scope.hitsFoundational)
|
|
285
|
+
out.add('foundational-requirement');
|
|
286
|
+
// Review round 1: the scope computation's "impacted specs but no anchored tests" branch was being
|
|
287
|
+
// named blast-radius, pointing remediation at the wrong knob.
|
|
288
|
+
if (out.size === 0)
|
|
289
|
+
out.add(scope.impactedTestFiles.length === 0 ? 'no-anchored-tests' : 'blast-radius');
|
|
290
|
+
return [...out].sort();
|
|
291
|
+
}
|
|
260
292
|
const BIN_EDGES = [0, 0.2, 0.4, 0.6, 0.8, 1];
|
|
293
|
+
function scopeCauseTally(artifacts) {
|
|
294
|
+
const tally = { full: 0, narrow: 0, unrecorded: 0, causes: {} };
|
|
295
|
+
for (const artifact of artifacts) {
|
|
296
|
+
const recorded = artifact.uncertainty?.testScopeCauses;
|
|
297
|
+
if (!Array.isArray(recorded)) {
|
|
298
|
+
tally.unrecorded++;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (artifact.uncertainty.testScopeTier !== 'full') {
|
|
302
|
+
tally.narrow++;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
tally.full++;
|
|
306
|
+
for (const cause of new Set(recorded))
|
|
307
|
+
tally.causes[cause] = (tally.causes[cause] ?? 0) + 1;
|
|
308
|
+
}
|
|
309
|
+
return tally;
|
|
310
|
+
}
|
|
261
311
|
/**
|
|
262
312
|
* Reliability bins plus a Brier score. `minSamples` is the honesty knob: below it a bin reports
|
|
263
313
|
* `insufficient-data` and a null accuracy, because one sample in a bin yields a 0 or a 1 that looks
|
|
@@ -316,5 +366,6 @@ function computeCalibration(artifacts, opts = {}) {
|
|
|
316
366
|
falseNegatives,
|
|
317
367
|
minSamples,
|
|
318
368
|
status: correctness.length >= minSamples ? 'measured' : 'insufficient-data',
|
|
369
|
+
scopeCauses: scopeCauseTally(artifacts),
|
|
319
370
|
};
|
|
320
371
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOOL_SCHEMAS = exports.HOOK_ENFORCED_TOOLS = void 0;
|
|
4
|
-
// @implements A-SPEC-736, A-SPEC-735, A-SPEC-729, A-SPEC-719, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627, A-SPEC-713
|
|
4
|
+
// @implements A-SPEC-743, A-SPEC-736, A-SPEC-735, A-SPEC-729, A-SPEC-719, A-SPEC-720, A-SPEC-718, A-SPEC-703, A-SPEC-629, A-SPEC-628, A-SPEC-623, A-SPEC-277, A-SPEC-624, A-SPEC-627, A-SPEC-713
|
|
5
5
|
// @implements A-SPEC-495 — the maintenance_analyze description carries the semantic-evidence
|
|
6
6
|
// consumer contract (sem-verify / semCos / semanticAlternates) beside the anti-prediction warning.
|
|
7
7
|
// @implements A-SPEC-642
|
|
@@ -417,6 +417,8 @@ exports.TOOL_SCHEMAS = {
|
|
|
417
417
|
prompt: str('User requirement or requested behavior to compare with governed requirement lineages.'),
|
|
418
418
|
topK: num('Maximum displayed candidate lineages (default 10, clamped to 1..20).'),
|
|
419
419
|
persist: bool('Write a content-addressed requirement-triage evidence artifact and record its issuance on the provenance ledger (single-use REQ intake evidence). Default false.'),
|
|
420
|
+
// @implements A-SPEC-743
|
|
421
|
+
detail: { type: 'string', enum: ['summary', 'full'], description: 'Default summary: each candidate document is { id, type, title, status, dependsOn }. full adds every document\'s frontmatter and sections (hundreds of KB on a large store). The verdict is the same either way.' },
|
|
420
422
|
},
|
|
421
423
|
required: ['root', 'prompt'],
|
|
422
424
|
},
|
|
@@ -25,9 +25,11 @@ export interface RequirementTriageInput {
|
|
|
25
25
|
semanticCandidates?: readonly RequirementSemanticCandidate[];
|
|
26
26
|
/** Omit for the BM25-only comparison arm; configured cold/unavailable coverage is disclosed. */
|
|
27
27
|
semantic?: {
|
|
28
|
-
state: 'covered' | 'cold' | 'unavailable' | 'not-adopted';
|
|
28
|
+
state: 'covered' | 'partial' | 'cold' | 'unavailable' | 'not-adopted';
|
|
29
29
|
covered: number;
|
|
30
30
|
total: number;
|
|
31
|
+
unlineaged?: number;
|
|
32
|
+
missingLineages?: string[];
|
|
31
33
|
};
|
|
32
34
|
/** The read-only published RTM graph lane. Any unavailable/stale state is disclosed as ambiguity. */
|
|
33
35
|
graph?: {
|
|
@@ -59,3 +61,19 @@ export declare const canonicalRequirementDocument: typeof canonicalRequirementDo
|
|
|
59
61
|
* Retrieval only admits candidates. The verdict requires independent content and operational facts.
|
|
60
62
|
*/
|
|
61
63
|
export declare function triageRequirements(input: RequirementTriageInput): RequirementTriageResult;
|
|
64
|
+
/**
|
|
65
|
+
* @implements A-SPEC-742
|
|
66
|
+
* Requirement-vector coverage over the documents that CAN carry a vector: those with a REQ lineage.
|
|
67
|
+
* A legacy T-SPEC under a C-SPEC has none, is never looked up and never warmed, so counting it in the
|
|
68
|
+
* denominator made `covered` unreachable — every triage in this repository was `ambiguous` (Phase A,
|
|
69
|
+
* 2026-09-30). `partial` is usable evidence: a lexical-only run is already adequate for a verdict,
|
|
70
|
+
* and some vectors are strictly more than none. `cold` — configured, nothing covered — is an inert
|
|
71
|
+
* layer (REQ-682) and stays inadequate.
|
|
72
|
+
*/
|
|
73
|
+
export declare function requirementSemanticCoverage(documents: readonly RequirementDocument[], hasVector: (doc: RequirementDocument, lineageId: string) => boolean): {
|
|
74
|
+
eligible: number;
|
|
75
|
+
covered: number;
|
|
76
|
+
unlineaged: number;
|
|
77
|
+
missingLineages: string[];
|
|
78
|
+
state: 'covered' | 'partial' | 'cold';
|
|
79
|
+
};
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.canonicalRequirementDocument = void 0;
|
|
4
4
|
exports.triageRequirements = triageRequirements;
|
|
5
|
-
|
|
5
|
+
exports.requirementSemanticCoverage = requirementSemanticCoverage;
|
|
6
|
+
// @implements A-SPEC-713.1, A-SPEC-742, A-SPEC-713
|
|
6
7
|
/** Pure, conservative lifecycle triage over governed requirement documents. */
|
|
7
8
|
const semantic_retrieval_1 = require("./semantic-retrieval");
|
|
9
|
+
const localize_1 = require("../rtm/localize");
|
|
8
10
|
const vector_coverage_1 = require("../semantic/vector-coverage");
|
|
9
11
|
/** Re-exported for triage callers; the cache contract belongs to vector coverage. */
|
|
10
12
|
exports.canonicalRequirementDocument = vector_coverage_1.canonicalRequirementDocument;
|
|
@@ -29,6 +31,22 @@ function rootOf(id, byId) {
|
|
|
29
31
|
}
|
|
30
32
|
return null;
|
|
31
33
|
}
|
|
34
|
+
/** @implements A-SPEC-713.1 — what BM25 and content support read: a document's title and sections. */
|
|
35
|
+
function scoringText(doc) {
|
|
36
|
+
// Round 4: bodies only — every spec shares its headings (Objective, Behavior, Files to Touch, …).
|
|
37
|
+
const bodies = Object.entries(doc.sections ?? {}).sort(([a], [b]) => a.localeCompare(b)).map(([, body]) => body);
|
|
38
|
+
return [doc.title, ...bodies].join('\n');
|
|
39
|
+
}
|
|
40
|
+
function rankCompare(a, b, cited) {
|
|
41
|
+
const byCitation = Number(cited.has(b.reqId)) - Number(cited.has(a.reqId));
|
|
42
|
+
if (byCitation !== 0)
|
|
43
|
+
return byCitation;
|
|
44
|
+
const sa = a.semanticScore ?? -Infinity;
|
|
45
|
+
const sb = b.semanticScore ?? -Infinity;
|
|
46
|
+
if (sa !== sb)
|
|
47
|
+
return sb > sa ? 1 : -1;
|
|
48
|
+
return b.lexicalScore - a.lexicalScore || a.reqId.localeCompare(b.reqId);
|
|
49
|
+
}
|
|
32
50
|
function bm25(query, docs) {
|
|
33
51
|
const terms = docs.map((text) => (0, semantic_retrieval_1.normalisedTerms)(text));
|
|
34
52
|
const avg = terms.reduce((n, row) => n + row.length, 0) / (terms.length || 1);
|
|
@@ -54,9 +72,43 @@ function bm25(query, docs) {
|
|
|
54
72
|
* Retrieval only admits candidates. The verdict requires independent content and operational facts.
|
|
55
73
|
*/
|
|
56
74
|
function triageRequirements(input) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
const result = triageCore(input);
|
|
76
|
+
// @implements A-SPEC-742 — a partially covered layer decides, and says what it lacked.
|
|
77
|
+
if (input.semantic?.state !== 'partial')
|
|
78
|
+
return result;
|
|
79
|
+
return { ...result, uncertainty: [...result.uncertainty, `semantic-partial:${Math.max(0, input.semantic.total - input.semantic.covered)}`] };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @implements A-SPEC-742
|
|
83
|
+
* Requirement-vector coverage over the documents that CAN carry a vector: those with a REQ lineage.
|
|
84
|
+
* A legacy T-SPEC under a C-SPEC has none, is never looked up and never warmed, so counting it in the
|
|
85
|
+
* denominator made `covered` unreachable — every triage in this repository was `ambiguous` (Phase A,
|
|
86
|
+
* 2026-09-30). `partial` is usable evidence: a lexical-only run is already adequate for a verdict,
|
|
87
|
+
* and some vectors are strictly more than none. `cold` — configured, nothing covered — is an inert
|
|
88
|
+
* layer (REQ-682) and stays inadequate.
|
|
89
|
+
*/
|
|
90
|
+
function requirementSemanticCoverage(documents, hasVector) {
|
|
91
|
+
const byId = new Map(documents.map((d) => [d.id, d]));
|
|
92
|
+
let eligible = 0;
|
|
93
|
+
let covered = 0;
|
|
94
|
+
const missing = new Set();
|
|
95
|
+
for (const doc of documents) {
|
|
96
|
+
const lineageId = rootOf(doc.id, byId);
|
|
97
|
+
if (lineageId === null)
|
|
98
|
+
continue;
|
|
99
|
+
eligible++;
|
|
100
|
+
if (hasVector(doc, lineageId))
|
|
101
|
+
covered++;
|
|
102
|
+
else
|
|
103
|
+
missing.add(lineageId);
|
|
104
|
+
}
|
|
105
|
+
// Review round 1: zero eligible is `cold`, never a vacuous `covered` (0 === 0).
|
|
106
|
+
const state = covered === 0 ? 'cold' : covered === eligible ? 'covered' : 'partial';
|
|
107
|
+
return { eligible, covered, unlineaged: documents.length - eligible, missingLineages: [...missing].sort().slice(0, 20), state };
|
|
108
|
+
}
|
|
109
|
+
function triageCore(input) {
|
|
110
|
+
// @implements A-SPEC-713.1 — ids are pointers, not content: they order (citation) but never score.
|
|
111
|
+
const promptTerms = [...new Set((0, semantic_retrieval_1.normalisedTerms)((0, localize_1.withoutCitations)(input.prompt)))];
|
|
60
112
|
const governed = input.documents.filter((d) => d.type === 'REQ' || d.type === 'H-SPEC' || d.type === 'A-SPEC' || d.type === 'T-SPEC');
|
|
61
113
|
if (governed.length === 0)
|
|
62
114
|
return { verdict: 'ambiguous', candidates: [], reasons: ['empty-or-unreadable-corpus'], uncertainty: ['empty-or-unreadable-corpus'] };
|
|
@@ -72,10 +124,18 @@ function triageRequirements(input) {
|
|
|
72
124
|
}
|
|
73
125
|
if (lineages.size === 0)
|
|
74
126
|
return { verdict: 'ambiguous', candidates: [], reasons: ['no-readable-lineage'], uncertainty: ['no-readable-lineage'] };
|
|
127
|
+
// @implements A-SPEC-713.1 — a lineage the request names ranks first (only ORDERS, never scores).
|
|
128
|
+
const citedLineages = new Set((0, localize_1.citationsIn)(input.prompt, new Set(governed.map((d) => d.id))).cited
|
|
129
|
+
.map((id) => rootOf(id, byId)).filter((root) => root !== null));
|
|
130
|
+
// Review round 3: an id-only prompt still lists the lineages it names.
|
|
131
|
+
if (promptTerms.length === 0 && citedLineages.size === 0)
|
|
132
|
+
return { verdict: 'ambiguous', candidates: [], reasons: ['empty-prompt'], uncertainty: ['empty-prompt'] };
|
|
75
133
|
const documents = [...lineages.entries()].map(([reqId, docs]) => ({
|
|
76
134
|
reqId,
|
|
77
135
|
docs: [...docs].sort((a, b) => a.id.localeCompare(b.id)),
|
|
78
|
-
|
|
136
|
+
// Review round 3: titles and sections only — the vector-cache text's `id:`/`lineage:`/`status:`
|
|
137
|
+
// header let "REQ 742", "the 742 rows", "spec" or "status" score (the cache text is unchanged).
|
|
138
|
+
text: docs.map(scoringText).join('\n'),
|
|
79
139
|
})).sort((a, b) => a.reqId.localeCompare(b.reqId));
|
|
80
140
|
const lexical = bm25(promptTerms, documents.map((d) => d.text));
|
|
81
141
|
const semantic = new Map();
|
|
@@ -88,7 +148,8 @@ function triageRequirements(input) {
|
|
|
88
148
|
}
|
|
89
149
|
const allCandidates = documents.map((row, i) => {
|
|
90
150
|
const semanticScore = semantic.get(row.reqId);
|
|
91
|
-
|
|
151
|
+
const cited = citedLineages.has(row.reqId);
|
|
152
|
+
if (lexical[i] <= 0 && semanticScore === undefined && !cited)
|
|
92
153
|
return null;
|
|
93
154
|
const textLower = row.text.toLowerCase();
|
|
94
155
|
const contentTerms = promptTerms.filter((term) => textLower.includes(term));
|
|
@@ -96,6 +157,7 @@ function triageRequirements(input) {
|
|
|
96
157
|
const approved = row.docs.length === 4 && row.docs.every((d) => d.status === 'approved');
|
|
97
158
|
const anchors = [...new Set(operational.implementationAnchors ?? [])].sort();
|
|
98
159
|
const reasons = [
|
|
160
|
+
...(cited ? ['cited'] : []),
|
|
99
161
|
...(lexical[i] > 0 ? ['bm25'] : []),
|
|
100
162
|
...(semanticScore !== undefined ? ['semantic-candidate'] : []),
|
|
101
163
|
...(contentTerms.length > 0 ? ['content-supported'] : ['content-unsupported']),
|
|
@@ -108,11 +170,14 @@ function triageRequirements(input) {
|
|
|
108
170
|
...(semanticScore !== undefined ? { semanticScore } : {}), contentTerms, approved,
|
|
109
171
|
implementationAnchors: anchors, freshGreenTests: operational.freshGreenTests === true, reasons };
|
|
110
172
|
}).filter((candidate) => candidate !== null)
|
|
111
|
-
.
|
|
112
|
-
|
|
173
|
+
// @implements A-SPEC-713.1 — cited, then the semantic channel where the lineage has a vector, then
|
|
174
|
+
// BM25. `max(BM25, cosine)` compared two scales: cosine counted only when BM25 was zero, while on
|
|
175
|
+
// the replay the semantic top was right 2–2.5× as often as the lexical top when they disagreed.
|
|
176
|
+
// With no vector anywhere (a lexical-only run) this is the lexical order it always was.
|
|
177
|
+
.sort((a, b) => rankCompare(a, b, citedLineages));
|
|
113
178
|
const candidates = allCandidates.slice(0, rankLimit(input.topK));
|
|
114
179
|
const semanticInadequate = input.semantic !== undefined
|
|
115
|
-
&& input.semantic.state !== 'covered' && input.semantic.state !== 'not-adopted';
|
|
180
|
+
&& input.semantic.state !== 'covered' && input.semantic.state !== 'partial' && input.semantic.state !== 'not-adopted';
|
|
116
181
|
const graphInadequate = input.graph !== undefined && input.graph.state !== 'current';
|
|
117
182
|
if (graphInadequate)
|
|
118
183
|
return { verdict: 'ambiguous', candidates, reasons: ['graph-coverage-inadequate'], uncertainty: ['graph-coverage-inadequate'] };
|
|
@@ -121,11 +186,47 @@ function triageRequirements(input) {
|
|
|
121
186
|
if (allCandidates.length === 0)
|
|
122
187
|
return { verdict: 'new', candidates, reasons: ['semantic-coverage-not-required-for-bm25-baseline'], uncertainty: ['semantic-coverage-not-required-for-bm25-baseline'] };
|
|
123
188
|
const top = allCandidates[0];
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
189
|
+
// @implements A-SPEC-713.1 — ties are judged on scores alone, whatever is cited, and a lineage with
|
|
190
|
+
// no vector ties on the semantic side (a coverage gap is not evidence against it). Checked first: a
|
|
191
|
+
// tie is the more specific explanation for an ambiguous answer.
|
|
192
|
+
const tied = allCandidates.filter((c) => c.lexicalScore === top.lexicalScore
|
|
193
|
+
&& (c.semanticScore === undefined || top.semanticScore === undefined || c.semanticScore === top.semanticScore));
|
|
194
|
+
// @implements A-SPEC-713.1 — a confident verdict needs two channels on the same lineage. Replay:
|
|
195
|
+
// agreement → right 0.46–0.79; disagreement → the lexical top right 0.12–0.16; every gold-new case
|
|
196
|
+
// disagreed, and an existing-change verdict refuses a new REQ at intake. A channel names a lineage
|
|
197
|
+
// only when its top is unique (and, lexically, above zero). A citation only ORDERS (review round 1:
|
|
198
|
+
// "unlike REQ-2", an id in a URL or `S-1` in prose are mentions, not evidence): it counts only when it
|
|
199
|
+
// is the single cited lineage and a channel also tops it.
|
|
200
|
+
let agreementReason = null;
|
|
201
|
+
if (tied.length <= 1) {
|
|
202
|
+
const uniqueTop = (list, score) => {
|
|
203
|
+
const sorted = [...list].sort((a, b) => score(b) - score(a));
|
|
204
|
+
if (sorted.length === 0 || (sorted.length > 1 && score(sorted[0]) === score(sorted[1])))
|
|
205
|
+
return null;
|
|
206
|
+
return sorted[0];
|
|
207
|
+
};
|
|
208
|
+
// Round 4: a term every lineage contains cannot tell lineages apart — the lexical channel names a
|
|
209
|
+
// lineage only through at least one term that some lineage lacks.
|
|
210
|
+
// With a single lineage there is nothing to tell apart, so the rule does not apply.
|
|
211
|
+
const everywhere = new Set(documents.length < 2 ? [] : promptTerms.filter((term) => documents.every((d) => d.text.toLowerCase().includes(term))));
|
|
212
|
+
const lexicalTop = uniqueTop(allCandidates.filter((c) => c.lexicalScore > 0 && c.contentTerms.some((t) => !everywhere.has(t))), (c) => c.lexicalScore);
|
|
213
|
+
const withVector = allCandidates.filter((c) => c.semanticScore !== undefined);
|
|
214
|
+
const semanticTop = uniqueTop(withVector, (c) => c.semanticScore);
|
|
215
|
+
// Round 3: a citation never counts toward agreement — "(unrelated to REQ-1)" plus one channel on
|
|
216
|
+
// REQ-1 decided REQ-1. Both channels (or, lexical-only, the lexical one) must name a lineage, and it
|
|
217
|
+
// must be the first-ranked one.
|
|
218
|
+
const agreed = withVector.length > 0
|
|
219
|
+
? (lexicalTop !== null && semanticTop !== null && lexicalTop.reqId === semanticTop.reqId ? lexicalTop.reqId : null)
|
|
220
|
+
: (lexicalTop?.reqId ?? null);
|
|
221
|
+
if (agreed === null)
|
|
222
|
+
agreementReason = withVector.length > 0 || !citedLineages.has(top.reqId) ? 'channels-disagree' : 'citation-unbacked';
|
|
223
|
+
else if (agreed !== top.reqId)
|
|
224
|
+
agreementReason = 'citation-unbacked';
|
|
225
|
+
}
|
|
226
|
+
if (tied.length > 1 || agreementReason !== null || top.contentTerms.length === 0 || top.reasons.includes('contradictory-evidence')) {
|
|
127
227
|
const uncertainty = [
|
|
128
228
|
...(tied.length > 1 ? ['tied-candidates'] : []),
|
|
229
|
+
...(agreementReason !== null ? [agreementReason] : []),
|
|
129
230
|
...(top.contentTerms.length === 0 ? ['candidate-content-unsupported'] : []),
|
|
130
231
|
...(top.reasons.includes('contradictory-evidence') ? ['contradictory-evidence'] : []),
|
|
131
232
|
];
|
|
@@ -32,6 +32,13 @@ export interface LocalizationReport {
|
|
|
32
32
|
*/
|
|
33
33
|
unknownCitations: string[];
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @implements A-SPEC-713.1 — the text with every id spelling this extractor recognises removed. An id
|
|
37
|
+
* is a pointer, not content: scored as words, the number inside `REQ-742` made lineage 742 the lexical
|
|
38
|
+
* top of any prompt that merely mentioned it ("not REQ-742", a ticket URL). Same pattern, so the
|
|
39
|
+
* two cannot drift.
|
|
40
|
+
*/
|
|
41
|
+
export declare function withoutCitations(text: string): string;
|
|
35
42
|
export declare function citationsIn(text: string, known: ReadonlySet<string>): {
|
|
36
43
|
cited: string[];
|
|
37
44
|
unknown: string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withoutCitations = withoutCitations;
|
|
3
4
|
exports.citationsIn = citationsIn;
|
|
4
5
|
exports.significantTerms = significantTerms;
|
|
5
6
|
exports.bigramUnspaced = bigramUnspaced;
|
|
@@ -14,6 +15,15 @@ exports.localizeIssue = localizeIssue;
|
|
|
14
15
|
// SCORING population stays A-SPEC-limited below, so an ADR never admits or reorders a file).
|
|
15
16
|
const CITATION = /\b(?:(A-SPEC|H-SPEC|T-SPEC|C-SPEC|ADR|REQ)-(\d+(?:\.\d+)?)|S-(\d+(?:\.\d+)?))\b/gi;
|
|
16
17
|
const CITABLE_KINDS = ['REQ', 'H-SPEC', 'A-SPEC', 'T-SPEC', 'C-SPEC', 'ADR'];
|
|
18
|
+
/**
|
|
19
|
+
* @implements A-SPEC-713.1 — the text with every id spelling this extractor recognises removed. An id
|
|
20
|
+
* is a pointer, not content: scored as words, the number inside `REQ-742` made lineage 742 the lexical
|
|
21
|
+
* top of any prompt that merely mentioned it ("not REQ-742", a ticket URL). Same pattern, so the
|
|
22
|
+
* two cannot drift.
|
|
23
|
+
*/
|
|
24
|
+
function withoutCitations(text) {
|
|
25
|
+
return text.replace(CITATION, ' ');
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* @implements A-SPEC-273
|
|
19
29
|
* How much a citation is worth, normalized by the file's anchor count exactly as the lexical spec
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "@implements A-SPEC-209",
|
|
3
3
|
"name": "@holmes-lab/holmes-kit",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.32.0",
|
|
5
5
|
"description": "Holmes-Kit — deterministic Agentic Software Engineering (ASE) harness with causal traceability (spec chain + D-CPG + RTM + phase guardrail)",
|
|
6
6
|
"main": "dist/holmes/mcp/server.js",
|
|
7
7
|
"types": "dist/holmes/mcp/server.d.ts",
|