@aldus-runtime/regression 0.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/LICENSE +201 -0
- package/NOTICE +21 -0
- package/dist/blindspots.d.ts +107 -0
- package/dist/blindspots.d.ts.map +1 -0
- package/dist/blindspots.js +169 -0
- package/dist/blindspots.js.map +1 -0
- package/dist/corpus.d.ts +184 -0
- package/dist/corpus.d.ts.map +1 -0
- package/dist/corpus.js +254 -0
- package/dist/corpus.js.map +1 -0
- package/dist/errors.d.ts +44 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics.d.ts +134 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +125 -0
- package/dist/metrics.js.map +1 -0
- package/dist/policy.d.ts +140 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +148 -0
- package/dist/policy.js.map +1 -0
- package/dist/promotion.d.ts +108 -0
- package/dist/promotion.d.ts.map +1 -0
- package/dist/promotion.js +130 -0
- package/dist/promotion.js.map +1 -0
- package/dist/report.d.ts +42 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +116 -0
- package/dist/report.js.map +1 -0
- package/dist/scope.d.ts +57 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +81 -0
- package/dist/scope.js.map +1 -0
- package/package.json +49 -0
- package/src/blindspots.ts +199 -0
- package/src/corpus.ts +311 -0
- package/src/errors.ts +49 -0
- package/src/index.ts +104 -0
- package/src/metrics.ts +293 -0
- package/src/policy.ts +267 -0
- package/src/promotion.ts +336 -0
- package/src/report.ts +154 -0
- package/src/scope.ts +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Aldus
|
|
2
|
+
Copyright 2026 Jam Chen
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this software except in compliance with the License. You may obtain a copy of
|
|
6
|
+
the License in the LICENSE file distributed with this software, or at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Aldus is currently owned as personal work and has not been assigned to a
|
|
11
|
+
separate legal entity. If ownership is transferred, this file and the related
|
|
12
|
+
copyright statements will be updated at that time.
|
|
13
|
+
|
|
14
|
+
No third-party code is bundled, inlined, or vendored into any published Aldus
|
|
15
|
+
package. Dependencies are resolved at install time and reach the consumer under
|
|
16
|
+
their own licenses, from their own publishers. The dependency audit is recorded
|
|
17
|
+
in THIRD-PARTY-NOTICES.md.
|
|
18
|
+
|
|
19
|
+
This NOTICE file exists by the project's choice rather than by obligation:
|
|
20
|
+
Apache-2.0 section 4(d) governs the preservation of a NOTICE file when the work
|
|
21
|
+
already carries one, and does not itself require that one be created.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The known-blind-spot registry (architecture contract §12.1, §9.3).
|
|
3
|
+
*
|
|
4
|
+
* §12.1 lists "known blind spots" among what evaluator promotion must consider, and §9.3 makes
|
|
5
|
+
* negative knowledge first-class: "Known failed approaches, unsafe transformations, evaluator
|
|
6
|
+
* blind spots, and provider limitations SHOULD be first-class pack content. Learning does not
|
|
7
|
+
* mean storing only successful examples."
|
|
8
|
+
*
|
|
9
|
+
* A blind spot is a failure mode an evaluator is *known* not to catch. It matters to promotion
|
|
10
|
+
* precisely because the corpus does not contain it — so metrics computed over the corpus are not
|
|
11
|
+
* evidence against a blind spot, they are evidence that the corpus did not look. An evaluator
|
|
12
|
+
* with an open blind spot in a slice should never read as promotable in that slice, however good
|
|
13
|
+
* its numbers are.
|
|
14
|
+
*
|
|
15
|
+
* ### Relationship to Knowledge Packs
|
|
16
|
+
*
|
|
17
|
+
* `KnowledgePackManifest.negativeKnowledge` (WP-09) holds *resource paths* — Core indexes them
|
|
18
|
+
* and never parses what is behind them (§1.2, §9.1). This registry holds the structured,
|
|
19
|
+
* machine-checkable records that gate promotion. They are complementary: a pack points at the
|
|
20
|
+
* prose describing a blind spot, and this registry carries the part a policy can evaluate.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from "zod";
|
|
23
|
+
import { type ScopeSelector } from "./scope.js";
|
|
24
|
+
/** How a blind spot has been dealt with. */
|
|
25
|
+
export declare const BLIND_SPOT_STATUSES: readonly [
|
|
26
|
+
/** Demonstrated and unaddressed. Disqualifies promotion in scope. */
|
|
27
|
+
"open",
|
|
28
|
+
/** Addressed, with the mitigation recorded. */
|
|
29
|
+
"mitigated",
|
|
30
|
+
/**
|
|
31
|
+
* Known, unmitigated, and deliberately tolerated.
|
|
32
|
+
*
|
|
33
|
+
* Distinct from `mitigated` because it is a decision, not a fix — and it must stay visible in
|
|
34
|
+
* the promotion report so tolerating it is a standing choice rather than a forgotten one.
|
|
35
|
+
*/
|
|
36
|
+
"accepted"];
|
|
37
|
+
/** @see BLIND_SPOT_STATUSES */
|
|
38
|
+
export type BlindSpotStatus = (typeof BLIND_SPOT_STATUSES)[number];
|
|
39
|
+
/** A failure mode an evaluator is known not to catch. */
|
|
40
|
+
export declare const blindSpotSchema: z.ZodObject<{
|
|
41
|
+
blindSpotId: z.ZodString;
|
|
42
|
+
evaluatorId: z.ZodString;
|
|
43
|
+
description: z.ZodString;
|
|
44
|
+
scope: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
45
|
+
category: z.ZodOptional<z.ZodString>;
|
|
46
|
+
severity: z.ZodOptional<z.ZodString>;
|
|
47
|
+
status: z.ZodEnum<{
|
|
48
|
+
accepted: "accepted";
|
|
49
|
+
mitigated: "mitigated";
|
|
50
|
+
open: "open";
|
|
51
|
+
}>;
|
|
52
|
+
evidenceCaseIds: z.ZodArray<z.ZodString>;
|
|
53
|
+
mitigation: z.ZodOptional<z.ZodString>;
|
|
54
|
+
recordedBy: z.ZodObject<{
|
|
55
|
+
kind: z.ZodEnum<{
|
|
56
|
+
agent: "agent";
|
|
57
|
+
human: "human";
|
|
58
|
+
system: "system";
|
|
59
|
+
worker: "worker";
|
|
60
|
+
}>;
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
63
|
+
backendId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
sessionRef: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
recordedAt: z.ZodISODateTime;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/** @see blindSpotSchema */
|
|
69
|
+
export type BlindSpot = z.infer<typeof blindSpotSchema>;
|
|
70
|
+
/**
|
|
71
|
+
* An in-memory, serialisable set of blind-spot records.
|
|
72
|
+
*
|
|
73
|
+
* Deliberately not file-backed. Persistence is the caller's choice — these records belong
|
|
74
|
+
* alongside an adopter's Knowledge Packs (§9.3), and binding the registry to one storage
|
|
75
|
+
* implementation would put a storage dependency in a package that only needs to read a list.
|
|
76
|
+
*/
|
|
77
|
+
export declare class BlindSpotRegistry {
|
|
78
|
+
#private;
|
|
79
|
+
/** Build a registry from records, validating each. */
|
|
80
|
+
static from(records: readonly unknown[]): BlindSpotRegistry;
|
|
81
|
+
/**
|
|
82
|
+
* Validate and add one record.
|
|
83
|
+
*
|
|
84
|
+
* @throws {AldusError} `ALDUS_BLIND_SPOT_MALFORMED` or `ALDUS_BLIND_SPOT_DUPLICATE`.
|
|
85
|
+
*/
|
|
86
|
+
record(input: unknown): BlindSpot;
|
|
87
|
+
/** Every record, in insertion order. */
|
|
88
|
+
list(): BlindSpot[];
|
|
89
|
+
/** Every record for one evaluator. */
|
|
90
|
+
forEvaluator(evaluatorId: string): BlindSpot[];
|
|
91
|
+
/**
|
|
92
|
+
* Open blind spots for an evaluator that apply within a scope slice.
|
|
93
|
+
*
|
|
94
|
+
* A blind spot applies to a slice when everything it scopes itself to is either held at the
|
|
95
|
+
* same value by the slice, or not held by the slice at all. The second half matters: a blind
|
|
96
|
+
* spot scoped to one voice applies to the whole-corpus slice, because the whole corpus
|
|
97
|
+
* includes that voice.
|
|
98
|
+
*/
|
|
99
|
+
openFor(evaluatorId: string, selector: ScopeSelector): BlindSpot[];
|
|
100
|
+
/** Blind spots demonstrated by at least one case in a corpus subset. */
|
|
101
|
+
demonstratedBy(evaluatorId: string, caseIds: ReadonlySet<string>): BlindSpot[];
|
|
102
|
+
/** Serialisable form. */
|
|
103
|
+
toJSON(): BlindSpot[];
|
|
104
|
+
}
|
|
105
|
+
/** True when a blind spot's own scope is satisfied by a case's scope. */
|
|
106
|
+
export declare function blindSpotCoversCase(record: BlindSpot, scope: Readonly<Record<string, string>>): boolean;
|
|
107
|
+
//# sourceMappingURL=blindspots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blindspots.d.ts","sourceRoot":"","sources":["../src/blindspots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9D,4CAA4C;AAC5C,eAAO,MAAM,mBAAmB;AAC9B,qEAAqE;AACrE,MAAM;AACN,+CAA+C;AAC/C,WAAW;AACX;;;;;GAKG;AACH,UAAU,CACF,CAAC;AAEX,+BAA+B;AAC/B,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,yDAAyD;AACzD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4CxB,CAAC;AAEL,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,qBAAa,iBAAiB;;IAG5B,sDAAsD;IACtD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,iBAAiB,CAI1D;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CA2BhC;IAED,wCAAwC;IACxC,IAAI,IAAI,SAAS,EAAE,CAElB;IAED,sCAAsC;IACtC,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,CAE7C;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,SAAS,EAAE,CAQjE;IAED,wEAAwE;IACxE,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,CAI7E;IAED,yBAAyB;IACzB,MAAM,IAAI,SAAS,EAAE,CAEpB;CACF;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACtC,OAAO,CAKT"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The known-blind-spot registry (architecture contract §12.1, §9.3).
|
|
3
|
+
*
|
|
4
|
+
* §12.1 lists "known blind spots" among what evaluator promotion must consider, and §9.3 makes
|
|
5
|
+
* negative knowledge first-class: "Known failed approaches, unsafe transformations, evaluator
|
|
6
|
+
* blind spots, and provider limitations SHOULD be first-class pack content. Learning does not
|
|
7
|
+
* mean storing only successful examples."
|
|
8
|
+
*
|
|
9
|
+
* A blind spot is a failure mode an evaluator is *known* not to catch. It matters to promotion
|
|
10
|
+
* precisely because the corpus does not contain it — so metrics computed over the corpus are not
|
|
11
|
+
* evidence against a blind spot, they are evidence that the corpus did not look. An evaluator
|
|
12
|
+
* with an open blind spot in a slice should never read as promotable in that slice, however good
|
|
13
|
+
* its numbers are.
|
|
14
|
+
*
|
|
15
|
+
* ### Relationship to Knowledge Packs
|
|
16
|
+
*
|
|
17
|
+
* `KnowledgePackManifest.negativeKnowledge` (WP-09) holds *resource paths* — Core indexes them
|
|
18
|
+
* and never parses what is behind them (§1.2, §9.1). This registry holds the structured,
|
|
19
|
+
* machine-checkable records that gate promotion. They are complementary: a pack points at the
|
|
20
|
+
* prose describing a blind spot, and this registry carries the part a policy can evaluate.
|
|
21
|
+
*/
|
|
22
|
+
import { actorRefSchema } from "@aldus-runtime/core";
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
import { findingCategory, scopeDimensions, severityLevel } from "./corpus.js";
|
|
25
|
+
import { RegressionErrorCodes, regressionError } from "./errors.js";
|
|
26
|
+
import { scopeMatches } from "./scope.js";
|
|
27
|
+
/** How a blind spot has been dealt with. */
|
|
28
|
+
export const BLIND_SPOT_STATUSES = [
|
|
29
|
+
/** Demonstrated and unaddressed. Disqualifies promotion in scope. */
|
|
30
|
+
"open",
|
|
31
|
+
/** Addressed, with the mitigation recorded. */
|
|
32
|
+
"mitigated",
|
|
33
|
+
/**
|
|
34
|
+
* Known, unmitigated, and deliberately tolerated.
|
|
35
|
+
*
|
|
36
|
+
* Distinct from `mitigated` because it is a decision, not a fix — and it must stay visible in
|
|
37
|
+
* the promotion report so tolerating it is a standing choice rather than a forgotten one.
|
|
38
|
+
*/
|
|
39
|
+
"accepted",
|
|
40
|
+
];
|
|
41
|
+
/** A failure mode an evaluator is known not to catch. */
|
|
42
|
+
export const blindSpotSchema = z
|
|
43
|
+
.object({
|
|
44
|
+
/** Identity of this record. */
|
|
45
|
+
blindSpotId: z.string().min(1).max(200),
|
|
46
|
+
/** Evaluator the blind spot belongs to. */
|
|
47
|
+
evaluatorId: z.string().min(1).max(200),
|
|
48
|
+
/** What the evaluator fails to catch. Prose, for a human reading the promotion report. */
|
|
49
|
+
description: z.string().min(1).max(4000),
|
|
50
|
+
/**
|
|
51
|
+
* Scope the blind spot applies to.
|
|
52
|
+
*
|
|
53
|
+
* An empty scope means it applies everywhere. A scoped blind spot disqualifies only the
|
|
54
|
+
* slices it covers — an evaluator blind to one voice's artefacts is not thereby disqualified
|
|
55
|
+
* for every other voice.
|
|
56
|
+
*/
|
|
57
|
+
scope: scopeDimensions,
|
|
58
|
+
/** Category from the adopter's taxonomy, where the blind spot maps to one (§12.3). */
|
|
59
|
+
category: findingCategory.optional(),
|
|
60
|
+
/** Severity of what goes undetected. */
|
|
61
|
+
severity: severityLevel.optional(),
|
|
62
|
+
/** Current status. */
|
|
63
|
+
status: z.enum(BLIND_SPOT_STATUSES),
|
|
64
|
+
/**
|
|
65
|
+
* Cases that demonstrate it, where the corpus contains any.
|
|
66
|
+
*
|
|
67
|
+
* Often empty, and that is the point: a blind spot the corpus can demonstrate is a
|
|
68
|
+
* measurable false negative, while one it cannot is invisible to every metric here.
|
|
69
|
+
*/
|
|
70
|
+
evidenceCaseIds: z.array(z.string().min(1).max(200)).max(1024),
|
|
71
|
+
/** What was done about it. Required in spirit when `mitigated`; prose either way. */
|
|
72
|
+
mitigation: z.string().max(4000).optional(),
|
|
73
|
+
/** Who recorded it (contract §19.2). */
|
|
74
|
+
recordedBy: actorRefSchema,
|
|
75
|
+
/** When it was recorded. */
|
|
76
|
+
recordedAt: z.iso.datetime({ offset: true }),
|
|
77
|
+
})
|
|
78
|
+
.meta({
|
|
79
|
+
id: "BlindSpot",
|
|
80
|
+
title: "BlindSpot",
|
|
81
|
+
description: "A failure mode an evaluator is known not to catch (architecture contract §12.1, §9.3). " +
|
|
82
|
+
"Corpus metrics are not evidence against a blind spot — a blind spot is by definition " +
|
|
83
|
+
"something the corpus did not sample. An `open` blind spot in scope disqualifies promotion " +
|
|
84
|
+
"there regardless of metrics.",
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* An in-memory, serialisable set of blind-spot records.
|
|
88
|
+
*
|
|
89
|
+
* Deliberately not file-backed. Persistence is the caller's choice — these records belong
|
|
90
|
+
* alongside an adopter's Knowledge Packs (§9.3), and binding the registry to one storage
|
|
91
|
+
* implementation would put a storage dependency in a package that only needs to read a list.
|
|
92
|
+
*/
|
|
93
|
+
export class BlindSpotRegistry {
|
|
94
|
+
#records = new Map();
|
|
95
|
+
/** Build a registry from records, validating each. */
|
|
96
|
+
static from(records) {
|
|
97
|
+
const registry = new BlindSpotRegistry();
|
|
98
|
+
for (const record of records)
|
|
99
|
+
registry.record(record);
|
|
100
|
+
return registry;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate and add one record.
|
|
104
|
+
*
|
|
105
|
+
* @throws {AldusError} `ALDUS_BLIND_SPOT_MALFORMED` or `ALDUS_BLIND_SPOT_DUPLICATE`.
|
|
106
|
+
*/
|
|
107
|
+
record(input) {
|
|
108
|
+
const result = blindSpotSchema.safeParse(input);
|
|
109
|
+
if (!result.success) {
|
|
110
|
+
// Paths and issue codes only — never the received value (contract §19.2).
|
|
111
|
+
throw regressionError(RegressionErrorCodes.BLIND_SPOT_MALFORMED, "The blind-spot record does not validate.", {
|
|
112
|
+
category: "validation",
|
|
113
|
+
details: {
|
|
114
|
+
issues: result.error.issues.map((issue) => ({
|
|
115
|
+
path: issue.path.join("."),
|
|
116
|
+
code: issue.code,
|
|
117
|
+
})),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (this.#records.has(result.data.blindSpotId)) {
|
|
122
|
+
throw regressionError(RegressionErrorCodes.BLIND_SPOT_DUPLICATE, `A blind spot with id "${result.data.blindSpotId}" is already registered.`, { category: "conflict", details: { blindSpotId: result.data.blindSpotId } });
|
|
123
|
+
}
|
|
124
|
+
this.#records.set(result.data.blindSpotId, result.data);
|
|
125
|
+
return result.data;
|
|
126
|
+
}
|
|
127
|
+
/** Every record, in insertion order. */
|
|
128
|
+
list() {
|
|
129
|
+
return [...this.#records.values()];
|
|
130
|
+
}
|
|
131
|
+
/** Every record for one evaluator. */
|
|
132
|
+
forEvaluator(evaluatorId) {
|
|
133
|
+
return this.list().filter((record) => record.evaluatorId === evaluatorId);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Open blind spots for an evaluator that apply within a scope slice.
|
|
137
|
+
*
|
|
138
|
+
* A blind spot applies to a slice when everything it scopes itself to is either held at the
|
|
139
|
+
* same value by the slice, or not held by the slice at all. The second half matters: a blind
|
|
140
|
+
* spot scoped to one voice applies to the whole-corpus slice, because the whole corpus
|
|
141
|
+
* includes that voice.
|
|
142
|
+
*/
|
|
143
|
+
openFor(evaluatorId, selector) {
|
|
144
|
+
return this.forEvaluator(evaluatorId).filter((record) => {
|
|
145
|
+
if (record.status !== "open")
|
|
146
|
+
return false;
|
|
147
|
+
return Object.entries(record.scope).every(([dimension, value]) => {
|
|
148
|
+
const held = selector.values[dimension];
|
|
149
|
+
return held === undefined || held === value;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** Blind spots demonstrated by at least one case in a corpus subset. */
|
|
154
|
+
demonstratedBy(evaluatorId, caseIds) {
|
|
155
|
+
return this.forEvaluator(evaluatorId).filter((record) => record.evidenceCaseIds.some((caseId) => caseIds.has(caseId)));
|
|
156
|
+
}
|
|
157
|
+
/** Serialisable form. */
|
|
158
|
+
toJSON() {
|
|
159
|
+
return this.list();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** True when a blind spot's own scope is satisfied by a case's scope. */
|
|
163
|
+
export function blindSpotCoversCase(record, scope) {
|
|
164
|
+
return scopeMatches(scope, {
|
|
165
|
+
dimensions: Object.keys(record.scope),
|
|
166
|
+
values: record.scope,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=blindspots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blindspots.js","sourceRoot":"","sources":["../src/blindspots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAAsB,MAAM,YAAY,CAAC;AAE9D,4CAA4C;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,qEAAqE;IACrE,MAAM;IACN,+CAA+C;IAC/C,WAAW;IACX;;;;;OAKG;IACH,UAAU;CACF,CAAC;AAKX,yDAAyD;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,CAAC;IACN,+BAA+B;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,2CAA2C;IAC3C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,0FAA0F;IAC1F,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACxC;;;;;;OAMG;IACH,KAAK,EAAE,eAAe;IACtB,sFAAsF;IACtF,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE;IACpC,wCAAwC;IACxC,QAAQ,EAAE,aAA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