@skill-harness/adapters 0.16.0 → 0.18.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/dist/index.d.ts +0 -28
- package/dist/index.js +0 -28
- package/dist/pi.js +21 -133
- package/package.json +2 -3
- package/dist/archive-access.d.ts +0 -58
- package/dist/archive-access.js +0 -61
- package/dist/archive-checkpoint.d.ts +0 -47
- package/dist/archive-checkpoint.js +0 -116
- package/dist/archive-facts.d.ts +0 -19
- package/dist/archive-facts.js +0 -20
- package/dist/archive-observer.d.ts +0 -21
- package/dist/archive-observer.js +0 -79
- package/dist/archive-policy.d.ts +0 -107
- package/dist/archive-policy.js +0 -135
- package/dist/archive-read-capability.d.ts +0 -49
- package/dist/archive-read-capability.js +0 -45
- package/dist/archive-retention-policy.d.ts +0 -52
- package/dist/archive-retention-policy.js +0 -49
- package/dist/archived-work.d.ts +0 -45
- package/dist/archived-work.js +0 -78
- package/dist/blind-intervention.d.ts +0 -35
- package/dist/blind-intervention.js +0 -218
- package/dist/codex-diagnostic-model.d.ts +0 -14
- package/dist/codex-diagnostic-model.js +0 -39
- package/dist/codex-host-observer.d.ts +0 -111
- package/dist/codex-host-observer.js +0 -309
- package/dist/codex-https.d.ts +0 -7
- package/dist/codex-https.js +0 -221
- package/dist/codex-model-profile.d.ts +0 -38
- package/dist/codex-model-profile.js +0 -54
- package/dist/codex-producer-ipc.d.ts +0 -55
- package/dist/codex-producer-ipc.js +0 -67
- package/dist/codex-sdk-transport.d.ts +0 -50
- package/dist/codex-sdk-transport.js +0 -294
- package/dist/codex-subscription.d.ts +0 -114
- package/dist/codex-subscription.js +0 -268
- package/dist/evidence-archive.d.ts +0 -65
- package/dist/evidence-archive.js +0 -225
- package/dist/execution-projection-schema.d.ts +0 -10
- package/dist/execution-projection-schema.js +0 -30
- package/dist/execution-retention-archive.d.ts +0 -69
- package/dist/execution-retention-archive.js +0 -154
- package/dist/generated/retention-v2-contract.d.ts +0 -72
- package/dist/generated/retention-v2-contract.js +0 -105
- package/dist/generated/retention-v2-json.d.ts +0 -24
- package/dist/generated/retention-v2-json.js +0 -268
- package/dist/generated/retention-v2-native-json.d.ts +0 -2
- package/dist/generated/retention-v2-native-json.js +0 -33
- package/dist/generated/retention-v2-native.d.ts +0 -58
- package/dist/generated/retention-v2-native.js +0 -155
- package/dist/generated/retention-v2-pin.d.ts +0 -2
- package/dist/generated/retention-v2-pin.js +0 -4
- package/dist/generated/retention-v2-types.d.ts +0 -49
- package/dist/generated/retention-v2-types.js +0 -2
- package/dist/generated/retention-v2-work-types.d.ts +0 -260
- package/dist/generated/retention-v2-work-types.js +0 -13
- package/dist/generated/work-v4/execution-id.d.ts +0 -5
- package/dist/generated/work-v4/execution-id.js +0 -14
- package/dist/generated/work-v4/json.d.ts +0 -24
- package/dist/generated/work-v4/json.js +0 -268
- package/dist/generated/work-v4/occurrences.d.ts +0 -226
- package/dist/generated/work-v4/occurrences.js +0 -116
- package/dist/generated/work-v4/pin.d.ts +0 -1
- package/dist/generated/work-v4/pin.js +0 -3
- package/dist/generated/work-v4/projection.d.ts +0 -294
- package/dist/generated/work-v4/projection.js +0 -238
- package/dist/generated/work-v4/reader.d.ts +0 -24
- package/dist/generated/work-v4/reader.js +0 -109
- package/dist/generated/work-v4/snapshot.d.ts +0 -28
- package/dist/generated/work-v4/snapshot.js +0 -268
- package/dist/generated/work-v4/types.d.ts +0 -260
- package/dist/generated/work-v4/types.js +0 -13
- package/dist/generated/work-v4/validation.d.ts +0 -13
- package/dist/generated/work-v4/validation.js +0 -227
- package/dist/installed-review-session.d.ts +0 -28
- package/dist/installed-review-session.js +0 -166
- package/dist/intervention-run.d.ts +0 -403
- package/dist/intervention-run.js +0 -169
- package/dist/learning-case.d.ts +0 -12
- package/dist/learning-case.js +0 -15
- package/dist/learning-journal.d.ts +0 -18
- package/dist/learning-journal.js +0 -256
- package/dist/learning-lifecycle.d.ts +0 -28
- package/dist/learning-lifecycle.js +0 -66
- package/dist/learning-trust-setup.d.ts +0 -64
- package/dist/learning-trust-setup.js +0 -55
- package/dist/learning-workspace.d.ts +0 -930
- package/dist/learning-workspace.js +0 -663
- package/dist/principal-payload-port.d.ts +0 -25
- package/dist/principal-payload-port.js +0 -40
- package/dist/producer-product.d.ts +0 -70
- package/dist/producer-product.js +0 -186
- package/dist/producer-review.d.ts +0 -53
- package/dist/producer-review.js +0 -207
- package/dist/prompt-capture-extension.d.ts +0 -10
- package/dist/prompt-capture-extension.js +0 -26
- package/dist/prompt-provenance.d.ts +0 -22
- package/dist/prompt-provenance.js +0 -146
- package/dist/reviewed-archive-export.d.ts +0 -42
- package/dist/reviewed-archive-export.js +0 -78
- package/dist/trust-lifecycle.d.ts +0 -152
- package/dist/trust-lifecycle.js +0 -209
- package/dist/weekly-investigation.d.ts +0 -237
- package/dist/weekly-investigation.js +0 -330
- package/dist/work-candidates.d.ts +0 -29
- package/dist/work-candidates.js +0 -78
- package/dist/work-case-archive.d.ts +0 -25
- package/dist/work-case-archive.js +0 -63
- package/dist/work-case-review.d.ts +0 -45
- package/dist/work-case-review.js +0 -220
- package/dist/work-signal-cases.d.ts +0 -15
- package/dist/work-signal-cases.js +0 -54
- package/dist/work-signal-observation.d.ts +0 -23
- package/dist/work-signal-observation.js +0 -89
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { type Hypothesis, type InvestigationAuthority, type InvestigationScenarioPreview, type FrozenInvestigationInputs } from '@skill-harness/core';
|
|
2
|
-
import { type ArchiveReadCapabilityOptions } from './archive-read-capability.js';
|
|
3
|
-
export interface WeeklySupervisorInput {
|
|
4
|
-
archiveRoot: string;
|
|
5
|
-
week: string;
|
|
6
|
-
population: string;
|
|
7
|
-
policyDigest: string;
|
|
8
|
-
maxCases: number;
|
|
9
|
-
cases: {
|
|
10
|
-
version: 2 | 3;
|
|
11
|
-
batchId: string;
|
|
12
|
-
manifestId: string;
|
|
13
|
-
decisionId: string;
|
|
14
|
-
}[];
|
|
15
|
-
reader: Omit<ArchiveReadCapabilityOptions, 'root'>;
|
|
16
|
-
}
|
|
17
|
-
export interface ModelArchiveRequest {
|
|
18
|
-
kind: 'producer-archive-model-v1';
|
|
19
|
-
manifestIds: string[];
|
|
20
|
-
maxInputBytes: number;
|
|
21
|
-
proposalLimits: {
|
|
22
|
-
subjectCalls: number;
|
|
23
|
-
judgeCalls: number;
|
|
24
|
-
wallMs: number;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface InvestigationScreenRequest {
|
|
28
|
-
manifestIds: string[];
|
|
29
|
-
population: string;
|
|
30
|
-
}
|
|
31
|
-
export interface InvestigationFiles {
|
|
32
|
-
spec: string;
|
|
33
|
-
rubric: string;
|
|
34
|
-
judgePolicy: string;
|
|
35
|
-
heldout: string;
|
|
36
|
-
configuration: string;
|
|
37
|
-
skill: string;
|
|
38
|
-
}
|
|
39
|
-
export declare function createWeeklyInvestigation(directory: string, input: WeeklySupervisorInput): {
|
|
40
|
-
inspect: () => {
|
|
41
|
-
state: string;
|
|
42
|
-
hypothesis: Hypothesis | null;
|
|
43
|
-
approved: boolean;
|
|
44
|
-
preview: InvestigationScenarioPreview | null;
|
|
45
|
-
frozen: {
|
|
46
|
-
digest: string;
|
|
47
|
-
version: string;
|
|
48
|
-
hypothesisId: string;
|
|
49
|
-
authorityId: string;
|
|
50
|
-
inputs: FrozenInvestigationInputs;
|
|
51
|
-
executionReady: false;
|
|
52
|
-
} | null;
|
|
53
|
-
files: InvestigationFiles | null;
|
|
54
|
-
skillHash: string | null;
|
|
55
|
-
selection: import("@skill-harness/core").WeeklyInvestigationSelection;
|
|
56
|
-
tip: string;
|
|
57
|
-
};
|
|
58
|
-
evaluation: () => {
|
|
59
|
-
frozen: {
|
|
60
|
-
digest: string;
|
|
61
|
-
version: string;
|
|
62
|
-
hypothesisId: string;
|
|
63
|
-
authorityId: string;
|
|
64
|
-
inputs: FrozenInvestigationInputs;
|
|
65
|
-
executionReady: false;
|
|
66
|
-
};
|
|
67
|
-
caseIds: string[];
|
|
68
|
-
skillSha256: string;
|
|
69
|
-
executionReady: false;
|
|
70
|
-
};
|
|
71
|
-
previewScreen: (request: InvestigationScreenRequest) => {
|
|
72
|
-
digest: string;
|
|
73
|
-
input: InvestigationScreenRequest;
|
|
74
|
-
freeze: string;
|
|
75
|
-
skillSha256: string;
|
|
76
|
-
scenarioId: string;
|
|
77
|
-
};
|
|
78
|
-
prepareModel(raw: ModelArchiveRequest): {
|
|
79
|
-
digest: string;
|
|
80
|
-
input: string;
|
|
81
|
-
};
|
|
82
|
-
runModel(preparedDigest: string, planSha256: string, invoke: (input: string) => Promise<{
|
|
83
|
-
hostPath: string;
|
|
84
|
-
id: string;
|
|
85
|
-
}>): Promise<Hypothesis>;
|
|
86
|
-
screen(request: InvestigationScreenRequest, authorizedLinks: readonly string[]): {
|
|
87
|
-
report: {
|
|
88
|
-
scenarios: import("@skill-harness/core").ScreenScenario[];
|
|
89
|
-
criteria: import("@skill-harness/core").ScreenCriterion[];
|
|
90
|
-
};
|
|
91
|
-
exploratory: true;
|
|
92
|
-
populationMatches: boolean;
|
|
93
|
-
comparisonQualified: false;
|
|
94
|
-
digest: string;
|
|
95
|
-
input: InvestigationScreenRequest;
|
|
96
|
-
freeze: string;
|
|
97
|
-
skillSha256: string;
|
|
98
|
-
scenarioId: string;
|
|
99
|
-
};
|
|
100
|
-
run(program: unknown): Hypothesis;
|
|
101
|
-
approve(authority: InvestigationAuthority): {
|
|
102
|
-
version: string;
|
|
103
|
-
hypothesisId: string;
|
|
104
|
-
authorityId: string;
|
|
105
|
-
scope: "investigation-only";
|
|
106
|
-
};
|
|
107
|
-
preview(specPath: string, scenario: Record<string, unknown>): InvestigationScenarioPreview;
|
|
108
|
-
promote(preview: InvestigationScenarioPreview, authority: InvestigationAuthority): {
|
|
109
|
-
scenarioId: string;
|
|
110
|
-
replayed: boolean;
|
|
111
|
-
sha256: string;
|
|
112
|
-
scope: "scenario-only";
|
|
113
|
-
};
|
|
114
|
-
freeze(files: InvestigationFiles, authority: InvestigationAuthority): {
|
|
115
|
-
digest: string;
|
|
116
|
-
version: string;
|
|
117
|
-
hypothesisId: string;
|
|
118
|
-
authorityId: string;
|
|
119
|
-
inputs: FrozenInvestigationInputs;
|
|
120
|
-
executionReady: false;
|
|
121
|
-
};
|
|
122
|
-
previewEdit(text: string): string;
|
|
123
|
-
edit(text: string, authorizedDigests: readonly string[]): {
|
|
124
|
-
frozen: {
|
|
125
|
-
digest: string;
|
|
126
|
-
version: string;
|
|
127
|
-
hypothesisId: string;
|
|
128
|
-
authorityId: string;
|
|
129
|
-
inputs: FrozenInvestigationInputs;
|
|
130
|
-
executionReady: false;
|
|
131
|
-
};
|
|
132
|
-
caseIds: string[];
|
|
133
|
-
skillSha256: string;
|
|
134
|
-
executionReady: false;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
/** Existing run is a finite inert data-only interpreter. The separate prepareModel/runModel
|
|
138
|
-
* composition forwards only capability-selected frozen bytes to an original producer model seam;
|
|
139
|
-
* it does not expose shell/filesystem tools or turn proposal evidence into execution authority. */
|
|
140
|
-
export declare function openWeeklyInvestigation(directory: string): {
|
|
141
|
-
inspect: () => {
|
|
142
|
-
state: string;
|
|
143
|
-
hypothesis: Hypothesis | null;
|
|
144
|
-
approved: boolean;
|
|
145
|
-
preview: InvestigationScenarioPreview | null;
|
|
146
|
-
frozen: {
|
|
147
|
-
digest: string;
|
|
148
|
-
version: string;
|
|
149
|
-
hypothesisId: string;
|
|
150
|
-
authorityId: string;
|
|
151
|
-
inputs: FrozenInvestigationInputs;
|
|
152
|
-
executionReady: false;
|
|
153
|
-
} | null;
|
|
154
|
-
files: InvestigationFiles | null;
|
|
155
|
-
skillHash: string | null;
|
|
156
|
-
selection: import("@skill-harness/core").WeeklyInvestigationSelection;
|
|
157
|
-
tip: string;
|
|
158
|
-
};
|
|
159
|
-
evaluation: () => {
|
|
160
|
-
frozen: {
|
|
161
|
-
digest: string;
|
|
162
|
-
version: string;
|
|
163
|
-
hypothesisId: string;
|
|
164
|
-
authorityId: string;
|
|
165
|
-
inputs: FrozenInvestigationInputs;
|
|
166
|
-
executionReady: false;
|
|
167
|
-
};
|
|
168
|
-
caseIds: string[];
|
|
169
|
-
skillSha256: string;
|
|
170
|
-
executionReady: false;
|
|
171
|
-
};
|
|
172
|
-
previewScreen: (request: InvestigationScreenRequest) => {
|
|
173
|
-
digest: string;
|
|
174
|
-
input: InvestigationScreenRequest;
|
|
175
|
-
freeze: string;
|
|
176
|
-
skillSha256: string;
|
|
177
|
-
scenarioId: string;
|
|
178
|
-
};
|
|
179
|
-
prepareModel(raw: ModelArchiveRequest): {
|
|
180
|
-
digest: string;
|
|
181
|
-
input: string;
|
|
182
|
-
};
|
|
183
|
-
runModel(preparedDigest: string, planSha256: string, invoke: (input: string) => Promise<{
|
|
184
|
-
hostPath: string;
|
|
185
|
-
id: string;
|
|
186
|
-
}>): Promise<Hypothesis>;
|
|
187
|
-
screen(request: InvestigationScreenRequest, authorizedLinks: readonly string[]): {
|
|
188
|
-
report: {
|
|
189
|
-
scenarios: import("@skill-harness/core").ScreenScenario[];
|
|
190
|
-
criteria: import("@skill-harness/core").ScreenCriterion[];
|
|
191
|
-
};
|
|
192
|
-
exploratory: true;
|
|
193
|
-
populationMatches: boolean;
|
|
194
|
-
comparisonQualified: false;
|
|
195
|
-
digest: string;
|
|
196
|
-
input: InvestigationScreenRequest;
|
|
197
|
-
freeze: string;
|
|
198
|
-
skillSha256: string;
|
|
199
|
-
scenarioId: string;
|
|
200
|
-
};
|
|
201
|
-
run(program: unknown): Hypothesis;
|
|
202
|
-
approve(authority: InvestigationAuthority): {
|
|
203
|
-
version: string;
|
|
204
|
-
hypothesisId: string;
|
|
205
|
-
authorityId: string;
|
|
206
|
-
scope: "investigation-only";
|
|
207
|
-
};
|
|
208
|
-
preview(specPath: string, scenario: Record<string, unknown>): InvestigationScenarioPreview;
|
|
209
|
-
promote(preview: InvestigationScenarioPreview, authority: InvestigationAuthority): {
|
|
210
|
-
scenarioId: string;
|
|
211
|
-
replayed: boolean;
|
|
212
|
-
sha256: string;
|
|
213
|
-
scope: "scenario-only";
|
|
214
|
-
};
|
|
215
|
-
freeze(files: InvestigationFiles, authority: InvestigationAuthority): {
|
|
216
|
-
digest: string;
|
|
217
|
-
version: string;
|
|
218
|
-
hypothesisId: string;
|
|
219
|
-
authorityId: string;
|
|
220
|
-
inputs: FrozenInvestigationInputs;
|
|
221
|
-
executionReady: false;
|
|
222
|
-
};
|
|
223
|
-
previewEdit(text: string): string;
|
|
224
|
-
edit(text: string, authorizedDigests: readonly string[]): {
|
|
225
|
-
frozen: {
|
|
226
|
-
digest: string;
|
|
227
|
-
version: string;
|
|
228
|
-
hypothesisId: string;
|
|
229
|
-
authorityId: string;
|
|
230
|
-
inputs: FrozenInvestigationInputs;
|
|
231
|
-
executionReady: false;
|
|
232
|
-
};
|
|
233
|
-
caseIds: string[];
|
|
234
|
-
skillSha256: string;
|
|
235
|
-
executionReady: false;
|
|
236
|
-
};
|
|
237
|
-
};
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { isAbsolute } from 'node:path';
|
|
3
|
-
import { constants, openSync, fstatSync, writeSync, fsyncSync, closeSync, realpathSync } from 'node:fs';
|
|
4
|
-
import { screenResults, validateResults, parseLearningRequest, buildHypothesis, selectWeeklyInvestigation, authorizeInvestigation, previewInvestigationScenario, applyInvestigationScenario, freezeInvestigation, assertFrozenInvestigation } from '@skill-harness/core';
|
|
5
|
-
import { createArchiveReadCapability } from './archive-read-capability.js';
|
|
6
|
-
import { readArchiveSource } from './evidence-archive.js';
|
|
7
|
-
import { readLearningCase } from './learning-case.js';
|
|
8
|
-
import { learningJournal, learningCopy, learningHash, learningFile, registerLearningStore, verifyLearningStore } from './learning-journal.js';
|
|
9
|
-
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
10
|
-
function confirmed(input) {
|
|
11
|
-
if (Object.keys(input).sort().join() !== 'archiveRoot,cases,maxCases,policyDigest,population,reader,week' || !isAbsolute(input.archiveRoot))
|
|
12
|
-
throw Error('closed absolute weekly input required');
|
|
13
|
-
if (!Array.isArray(input.cases) || !input.cases.length || input.cases.length > 32)
|
|
14
|
-
throw Error('bounded confirmed cases required');
|
|
15
|
-
return input.cases.map(c => { const { candidate, current, matched } = readLearningCase(input.archiveRoot, c); if (!matched || current?.disposition !== 'confirmed_defect' || candidate.detector.population !== input.population)
|
|
16
|
-
throw Error('current confirmed case decision and population required'); return candidate.id; });
|
|
17
|
-
}
|
|
18
|
-
function selection(input) { const ids = confirmed(input), reader = createArchiveReadCapability({ ...input.reader, root: input.archiveRoot }); return selectWeeklyInvestigation([], { week: input.week, population: input.population, policyDigest: input.policyDigest, archiveSnapshot: reader.snapshot.id, eligibleCaseIds: ids, maxCases: input.maxCases }); }
|
|
19
|
-
export function createWeeklyInvestigation(directory, input) {
|
|
20
|
-
const safe = learningCopy(input), selected = selection(safe), initial = { type: 'initial', kind: 'weekly-investigation-v1', input: safe, selection: selected };
|
|
21
|
-
registerLearningStore(safe.archiveRoot, 'weekly', selected.key, directory, learningHash(initial));
|
|
22
|
-
try {
|
|
23
|
-
learningJournal(directory, initial);
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
if (e.code !== 'EEXIST')
|
|
27
|
-
throw e;
|
|
28
|
-
const old = learningJournal(directory).read()[0].value;
|
|
29
|
-
if (learningHash(old) !== learningHash(initial))
|
|
30
|
-
throw Error('weekly selection already frozen');
|
|
31
|
-
}
|
|
32
|
-
return openWeeklyInvestigation(directory);
|
|
33
|
-
}
|
|
34
|
-
/** Existing run is a finite inert data-only interpreter. The separate prepareModel/runModel
|
|
35
|
-
* composition forwards only capability-selected frozen bytes to an original producer model seam;
|
|
36
|
-
* it does not expose shell/filesystem tools or turn proposal evidence into execution authority. */
|
|
37
|
-
export function openWeeklyInvestigation(directory) {
|
|
38
|
-
const journal = learningJournal(directory), initial = journal.read()[0].value;
|
|
39
|
-
if (initial.kind !== 'weekly-investigation-v1' || initial.type !== 'initial')
|
|
40
|
-
throw Error('wrong supervisor journal');
|
|
41
|
-
const input = initial.input, selected = initial.selection;
|
|
42
|
-
const inspect = () => {
|
|
43
|
-
verifyLearningStore(input.archiveRoot, 'weekly', selected.key, directory, learningHash(initial));
|
|
44
|
-
const events = journal.read();
|
|
45
|
-
let state = 'prepared', hypothesis = null, approved = false, preview = null, frozen = null, files = null, skillHash = null;
|
|
46
|
-
for (const { value: v } of events.slice(1)) {
|
|
47
|
-
switch (v.type) {
|
|
48
|
-
case 'model-prepared':
|
|
49
|
-
if (state !== 'prepared')
|
|
50
|
-
throw Error('invalid model preparation');
|
|
51
|
-
state = 'model-prepared';
|
|
52
|
-
break;
|
|
53
|
-
case 'claim':
|
|
54
|
-
if (!['prepared', 'model-prepared'].includes(state))
|
|
55
|
-
throw Error('invalid supervisor claim');
|
|
56
|
-
state = 'claimed';
|
|
57
|
-
break;
|
|
58
|
-
case 'read':
|
|
59
|
-
if (state !== 'claimed')
|
|
60
|
-
throw Error('invalid read phase');
|
|
61
|
-
break;
|
|
62
|
-
case 'proposed':
|
|
63
|
-
if (state !== 'claimed')
|
|
64
|
-
throw Error('invalid proposal phase');
|
|
65
|
-
hypothesis = buildHypothesis(v.hypothesis.proposal);
|
|
66
|
-
if (hypothesis.id !== v.hypothesis.id)
|
|
67
|
-
throw Error('proposal identity changed');
|
|
68
|
-
state = 'proposed';
|
|
69
|
-
break;
|
|
70
|
-
case 'failed':
|
|
71
|
-
if (state !== 'claimed')
|
|
72
|
-
throw Error('invalid failure phase');
|
|
73
|
-
state = 'failed';
|
|
74
|
-
break;
|
|
75
|
-
case 'approved':
|
|
76
|
-
if (state !== 'proposed')
|
|
77
|
-
throw Error('invalid approval phase');
|
|
78
|
-
approved = true;
|
|
79
|
-
state = 'approved';
|
|
80
|
-
break;
|
|
81
|
-
case 'promotion-pending':
|
|
82
|
-
if (state !== 'approved')
|
|
83
|
-
throw Error('invalid promotion phase');
|
|
84
|
-
preview = v.preview;
|
|
85
|
-
state = 'promotion-pending';
|
|
86
|
-
break;
|
|
87
|
-
case 'promoted':
|
|
88
|
-
if (state !== 'promotion-pending')
|
|
89
|
-
throw Error('invalid promotion completion');
|
|
90
|
-
state = 'promoted';
|
|
91
|
-
break;
|
|
92
|
-
case 'frozen':
|
|
93
|
-
if (state !== 'promoted')
|
|
94
|
-
throw Error('invalid freeze phase');
|
|
95
|
-
frozen = v.frozen;
|
|
96
|
-
files = v.files;
|
|
97
|
-
skillHash = String(v.skillHash);
|
|
98
|
-
state = 'frozen';
|
|
99
|
-
break;
|
|
100
|
-
case 'edit-pending':
|
|
101
|
-
if (state !== 'frozen')
|
|
102
|
-
throw Error('invalid edit phase');
|
|
103
|
-
state = 'edit-pending';
|
|
104
|
-
break;
|
|
105
|
-
case 'edited':
|
|
106
|
-
if (state !== 'edit-pending')
|
|
107
|
-
throw Error('invalid edit completion');
|
|
108
|
-
skillHash = String(v.skillHash);
|
|
109
|
-
state = 'edited';
|
|
110
|
-
break;
|
|
111
|
-
case 'screened':
|
|
112
|
-
if (!['frozen', 'edited'].includes(state))
|
|
113
|
-
throw Error('invalid screen phase');
|
|
114
|
-
break;
|
|
115
|
-
default: throw Error('unknown supervisor event');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return learningCopy({ state, hypothesis, approved, preview, frozen, files, skillHash, selection: selected, tip: events.at(-1).id });
|
|
119
|
-
};
|
|
120
|
-
inspect();
|
|
121
|
-
const append = (prior, value) => journal.append(prior, value);
|
|
122
|
-
const inputs = (files) => ({ specSha256: sha(learningFile(files.spec)), rubricSha256: sha(learningFile(files.rubric)), judgePolicySha256: sha(learningFile(files.judgePolicy)), heldoutSha256: sha(learningFile(files.heldout)), configurationSha256: sha(learningFile(files.configuration)) });
|
|
123
|
-
const evaluation = () => { const s = inspect(); if (!s.frozen || !s.files || !['frozen', 'edited'].includes(s.state))
|
|
124
|
-
throw Error('frozen investigation required'); confirmed(input); assertFrozenInvestigation(s.frozen, inputs(s.files)); if (sha(learningFile(s.files.skill)) !== s.skillHash)
|
|
125
|
-
throw Error('candidate changed outside authorized edit'); return { frozen: s.frozen, caseIds: s.hypothesis.proposal.caseIds, skillSha256: s.skillHash, executionReady: false }; };
|
|
126
|
-
const previewScreen = (request) => {
|
|
127
|
-
const evaluated = evaluation(), s = inspect(), input = learningCopy(request);
|
|
128
|
-
if (Object.keys(input).sort().join() !== 'manifestIds,population' || typeof input.population !== 'string' || !input.population.length || input.population.length > 512 || !Array.isArray(input.manifestIds) || !input.manifestIds.length || input.manifestIds.length > 16 || new Set(input.manifestIds).size !== input.manifestIds.length || input.manifestIds.some(id => !/^[a-f0-9]{64}$/.test(id)))
|
|
129
|
-
throw Error('bounded distinct screen sources required');
|
|
130
|
-
const binding = { input, freeze: evaluated.frozen.digest, skillSha256: evaluated.skillSha256, scenarioId: String(s.preview.scenario.id) };
|
|
131
|
-
return { ...binding, digest: learningHash(binding) };
|
|
132
|
-
};
|
|
133
|
-
return { inspect, evaluation, previewScreen,
|
|
134
|
-
prepareModel(raw) {
|
|
135
|
-
const request = learningCopy(raw), s = inspect();
|
|
136
|
-
confirmed(input);
|
|
137
|
-
if (Object.keys(request).sort().join() !== 'kind,manifestIds,maxInputBytes,proposalLimits' || request.kind !== 'producer-archive-model-v1' || !Number.isSafeInteger(request.maxInputBytes) || request.maxInputBytes < 1 || request.maxInputBytes > 3000 || !Array.isArray(request.manifestIds) || !request.manifestIds.length || new Set(request.manifestIds).size !== request.manifestIds.length || request.manifestIds.length > input.reader.maxCalls || request.manifestIds.some(id => !input.reader.manifestIds.includes(id)) || Object.keys(request.proposalLimits).sort().join() !== 'judgeCalls,subjectCalls,wallMs' || Object.values(request.proposalLimits).some(n => !Number.isSafeInteger(n) || n < 0) || request.proposalLimits.wallMs < 1)
|
|
138
|
-
throw Error('bounded archive-only model request required');
|
|
139
|
-
const old = journal.read().find(e => e.value.type === 'model-prepared');
|
|
140
|
-
if (old) {
|
|
141
|
-
if (learningHash(old.value.request) !== learningHash(request) || s.state !== 'model-prepared')
|
|
142
|
-
throw Error('model preparation changed or already claimed');
|
|
143
|
-
return learningCopy(old.value.prepared);
|
|
144
|
-
}
|
|
145
|
-
if (s.state !== 'prepared')
|
|
146
|
-
throw Error('weekly owner already claimed');
|
|
147
|
-
const reader = createArchiveReadCapability({ ...input.reader, root: input.archiveRoot });
|
|
148
|
-
const sources = request.manifestIds.map(id => { const r = reader.read(id); return { manifestId: r.manifestId, sha256: r.reference.sha256, bytesBase64: r.bytes.toString('base64') }; });
|
|
149
|
-
const text = JSON.stringify({ selection: selected, sources, proposalLimits: request.proposalLimits });
|
|
150
|
-
if (Buffer.byteLength(text) > request.maxInputBytes)
|
|
151
|
-
throw Error('archive model input overbudget');
|
|
152
|
-
const prepared = { input: text, digest: learningHash({ request, input: text, selection: selected }) };
|
|
153
|
-
append(s.tip, { type: 'model-prepared', request, prepared, sourceKind: 'producer-archive-model-v1' });
|
|
154
|
-
return prepared;
|
|
155
|
-
},
|
|
156
|
-
async runModel(preparedDigest, planSha256, invoke) {
|
|
157
|
-
const s = inspect(), prepared = journal.read().find(e => e.value.type === 'model-prepared')?.value;
|
|
158
|
-
if (s.state !== 'model-prepared' || !prepared || prepared.prepared.digest !== preparedDigest || !/^([a-f0-9]{64})$/.test(planSha256))
|
|
159
|
-
throw Error('frozen model preparation required');
|
|
160
|
-
confirmed(input);
|
|
161
|
-
const tip = append(s.tip, { type: 'claim', sourceKind: 'producer-archive-model-v1', preparedDigest, planSha256 }).id;
|
|
162
|
-
try {
|
|
163
|
-
const ref = await invoke(String(prepared.prepared.input)), rows = learningJournal(ref.hostPath).read(), obs = rows.find(r => r.value.type === 'observation' && r.value.id === ref.id), bound = rows.find(r => r.value.type === 'producer-ipc-bound' && r.value.id === ref.id), settled = rows.find(r => r.value.type === 'producer-ipc-settled' && r.value.id === ref.id);
|
|
164
|
-
if (!obs || !bound || !settled || bound.value.bindingHash !== settled.value.bindingHash || bound.value.binding.charterSha256 !== planSha256)
|
|
165
|
-
throw Error('original model settlement required');
|
|
166
|
-
const h = buildHypothesis(JSON.parse(Buffer.from(String(obs.value.outputBase64), 'base64').toString('utf8')));
|
|
167
|
-
if (h.proposal.archiveSnapshot !== selected.archiveSnapshot || h.proposal.population !== selected.population || learningHash([...h.proposal.caseIds].sort()) !== learningHash([...selected.selectedCaseIds].sort()) || learningHash(h.proposal.limits) !== learningHash(prepared.request.proposalLimits))
|
|
168
|
-
throw Error('model proposal scope/limits mismatch');
|
|
169
|
-
confirmed(input);
|
|
170
|
-
append(tip, { type: 'proposed', hypothesis: h, sourceKind: 'producer-archive-model-v1', source: { ...ref, observation: obs.id, settlement: settled.id, planSha256 }, approved: false });
|
|
171
|
-
return h;
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
try {
|
|
175
|
-
append(tip, { type: 'failed', reason: 'model-retro-failed; no retry' });
|
|
176
|
-
}
|
|
177
|
-
catch (persist) {
|
|
178
|
-
throw new AggregateError([error, persist], 'retro failure persistence unknown');
|
|
179
|
-
}
|
|
180
|
-
throw error;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
screen(request, authorizedLinks) {
|
|
184
|
-
const s = inspect(), preview = previewScreen(request);
|
|
185
|
-
if (!authorizedLinks.includes(preview.digest))
|
|
186
|
-
throw Error('independent exact screen linkage authority required');
|
|
187
|
-
if (inspect().tip !== s.tip)
|
|
188
|
-
throw Error('stale screen snapshot');
|
|
189
|
-
const seen = new Set();
|
|
190
|
-
const results = preview.input.manifestIds.map(id => {
|
|
191
|
-
const source = readArchiveSource(input.archiveRoot, id);
|
|
192
|
-
if (source.status !== 'available' || source.reference.retention !== 'exact' || source.reference.parser.id !== 'skill-harness-results' || source.bytes.length > 65536)
|
|
193
|
-
throw Error('retained screen results unavailable');
|
|
194
|
-
if (seen.has(source.reference.sha256))
|
|
195
|
-
throw Error('duplicate screen evidence bytes');
|
|
196
|
-
seen.add(source.reference.sha256);
|
|
197
|
-
const result = validateResults(parseLearningRequest(source.bytes.toString('utf8')));
|
|
198
|
-
if (source.reference.parser.version !== String(result.schema) || typeof result.skill !== 'string' || typeof result.model !== 'string' || new Set(result.scenarios.map(r => r.id)).size !== result.scenarios.length || !result.scenarios.some(r => r.id === preview.scenarioId))
|
|
199
|
-
throw Error('screen result scenario/schema binding mismatch');
|
|
200
|
-
return result;
|
|
201
|
-
});
|
|
202
|
-
const report = screenResults(results), receipt = { ...preview, report: { scenarios: report.scenarios.filter(r => r.id === preview.scenarioId), criteria: report.criteria.filter(r => r.scenario_id === preview.scenarioId) }, exploratory: true, populationMatches: preview.input.population === selected.population, comparisonQualified: false };
|
|
203
|
-
const old = journal.read().find(e => e.value.type === 'screened' && e.value.receipt.digest === receipt.digest);
|
|
204
|
-
if (old) {
|
|
205
|
-
if (learningHash(old.value.receipt) !== learningHash(receipt))
|
|
206
|
-
throw Error('screen receipt changed');
|
|
207
|
-
return receipt;
|
|
208
|
-
}
|
|
209
|
-
append(s.tip, { type: 'screened', receipt });
|
|
210
|
-
return receipt;
|
|
211
|
-
},
|
|
212
|
-
run(program) {
|
|
213
|
-
const before = inspect();
|
|
214
|
-
if (before.state !== 'prepared')
|
|
215
|
-
throw Error('weekly job already claimed; no automatic retry');
|
|
216
|
-
confirmed(input);
|
|
217
|
-
let tip = journal.append(before.tip, { type: 'claim' }).id;
|
|
218
|
-
try {
|
|
219
|
-
const host = learningCopy(program);
|
|
220
|
-
if (host.kind !== 'inert-v1' || Object.keys(host).sort().join() !== 'kind,requests' || !Array.isArray(host.requests) || host.requests.length > 128)
|
|
221
|
-
throw Error('host denied');
|
|
222
|
-
const reader = createArchiveReadCapability({ ...input.reader, root: input.archiveRoot });
|
|
223
|
-
let reads = 0, h = null;
|
|
224
|
-
for (const request of host.requests) {
|
|
225
|
-
if (h)
|
|
226
|
-
throw Error('request after proposal denied');
|
|
227
|
-
if (request.tool === 'archive.read' && Object.keys(request).sort().join() === 'manifestId,tool') {
|
|
228
|
-
const result = reader.read(String(request.manifestId));
|
|
229
|
-
tip = append(tip, { type: 'read', manifestId: result.manifestId, sha256: result.reference.sha256 }).id;
|
|
230
|
-
reads++;
|
|
231
|
-
}
|
|
232
|
-
else if (request.tool === 'hypothesis' && Object.keys(request).sort().join() === 'proposal,tool') {
|
|
233
|
-
h = buildHypothesis(request.proposal);
|
|
234
|
-
if (!reads || h.proposal.archiveSnapshot !== selected.archiveSnapshot || h.proposal.population !== selected.population || learningHash([...h.proposal.caseIds].sort()) !== learningHash([...selected.selectedCaseIds].sort()) || h.proposal.limits.subjectCalls !== 0 || h.proposal.limits.judgeCalls !== 0)
|
|
235
|
-
throw Error('confirmed case/read linkage or inert budget mismatch');
|
|
236
|
-
}
|
|
237
|
-
else
|
|
238
|
-
throw Error('capability denied');
|
|
239
|
-
}
|
|
240
|
-
if (!h)
|
|
241
|
-
throw Error('hypothesis missing');
|
|
242
|
-
confirmed(input);
|
|
243
|
-
append(tip, { type: 'proposed', hypothesis: h });
|
|
244
|
-
return h;
|
|
245
|
-
}
|
|
246
|
-
catch (error) {
|
|
247
|
-
try {
|
|
248
|
-
append(tip, { type: 'failed', reason: 'inert-host-refused-or-failed' });
|
|
249
|
-
}
|
|
250
|
-
catch (persist) {
|
|
251
|
-
throw new AggregateError([error, persist], 'supervisor failed; failure persistence unknown');
|
|
252
|
-
}
|
|
253
|
-
throw error;
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
approve(authority) { const s = inspect(); if (!s.hypothesis)
|
|
257
|
-
throw Error('hypothesis required'); const approval = authorizeInvestigation(s.hypothesis, authority); if (s.approved)
|
|
258
|
-
return approval; if (s.state !== 'proposed')
|
|
259
|
-
throw Error('proposal required'); confirmed(input); append(s.tip, { type: 'approved', approval }); return approval; },
|
|
260
|
-
preview(specPath, scenario) { const s = inspect(); if (!s.approved || !s.hypothesis)
|
|
261
|
-
throw Error('investigation approval required'); confirmed(input); return previewInvestigationScenario(s.hypothesis, specPath, scenario); },
|
|
262
|
-
promote(preview, authority) {
|
|
263
|
-
const s = inspect();
|
|
264
|
-
if (!s.hypothesis || !s.approved)
|
|
265
|
-
throw Error('approved investigation required');
|
|
266
|
-
authorizeInvestigation(s.hypothesis, authority);
|
|
267
|
-
if (!authority.promotions.includes(preview.digest))
|
|
268
|
-
throw Error('exact promotion authority required');
|
|
269
|
-
confirmed(input);
|
|
270
|
-
if (['promoted', 'frozen', 'edited'].includes(s.state) && s.preview?.digest === preview.digest) {
|
|
271
|
-
if (learningHash(s.preview) !== learningHash(preview))
|
|
272
|
-
throw Error('promotion identity changed');
|
|
273
|
-
if (sha(learningFile(preview.specPath)) !== preview.afterSha256)
|
|
274
|
-
throw Error('promoted scenario changed');
|
|
275
|
-
return { scenarioId: String(preview.scenario.id), replayed: true, sha256: preview.afterSha256, scope: 'scenario-only' };
|
|
276
|
-
}
|
|
277
|
-
if (s.state !== 'approved')
|
|
278
|
-
throw Error('pending effects are not retried');
|
|
279
|
-
if (learningHash(previewInvestigationScenario(s.hypothesis, preview.specPath, preview.scenario)) !== learningHash(preview))
|
|
280
|
-
throw Error('promotion identity changed');
|
|
281
|
-
const pending = append(s.tip, { type: 'promotion-pending', preview });
|
|
282
|
-
const result = applyInvestigationScenario(s.hypothesis, preview, authority);
|
|
283
|
-
append(pending.id, { type: 'promoted', result });
|
|
284
|
-
return result;
|
|
285
|
-
},
|
|
286
|
-
freeze(files, authority) { const s = inspect(); if (s.state !== 'promoted' || !s.hypothesis || !s.preview || files.spec !== s.preview.specPath || sha(learningFile(files.spec)) !== s.preview.afterSha256)
|
|
287
|
-
throw Error('promoted scenario binding required'); confirmed(input); const safe = learningCopy(files); for (const key of Object.keys(safe)) {
|
|
288
|
-
learningFile(safe[key]);
|
|
289
|
-
safe[key] = realpathSync(safe[key]);
|
|
290
|
-
} if (Object.keys(safe).sort().join() !== 'configuration,heldout,judgePolicy,rubric,skill,spec' || new Set(Object.values(safe)).size !== 6)
|
|
291
|
-
throw Error('distinct frozen evaluation and candidate paths required'); const frozen = freezeInvestigation(s.hypothesis, inputs(safe), authority); append(s.tip, { type: 'frozen', frozen, files: safe, skillHash: sha(learningFile(safe.skill)) }); return frozen; },
|
|
292
|
-
previewEdit(text) { evaluation(); const s = inspect(); if (s.state !== 'frozen' || typeof text !== 'string' || Buffer.byteLength(text) > 1024 * 1024)
|
|
293
|
-
throw Error('frozen bounded edit required'); return learningHash({ freeze: s.frozen.digest, path: s.files.skill, before: s.skillHash, after: sha(Buffer.from(text)) }); },
|
|
294
|
-
edit(text, authorizedDigests) {
|
|
295
|
-
const id = this.previewEdit(text), s = inspect();
|
|
296
|
-
if (!authorizedDigests.includes(id))
|
|
297
|
-
throw Error('independent exact edit authority required');
|
|
298
|
-
confirmed(input);
|
|
299
|
-
const pending = append(s.tip, { type: 'edit-pending', editId: id });
|
|
300
|
-
const fd = openSync(s.files.skill, constants.O_WRONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
301
|
-
try {
|
|
302
|
-
const stat = fstatSync(fd);
|
|
303
|
-
if (!stat.isFile() || stat.nlink !== 1)
|
|
304
|
-
throw Error('edit destination changed');
|
|
305
|
-
// Whole-file replacement is bounded and explicitly approved. Partial writes remain pending/error.
|
|
306
|
-
const bytes = Buffer.from(text);
|
|
307
|
-
let n = 0;
|
|
308
|
-
while (n < bytes.length) {
|
|
309
|
-
const k = writeSync(fd, bytes, n, bytes.length - n, n);
|
|
310
|
-
if (!k)
|
|
311
|
-
throw Error('edit write stalled');
|
|
312
|
-
n += k;
|
|
313
|
-
}
|
|
314
|
-
// Truncate only this explicitly approved candidate, never an evaluation input or historical evidence.
|
|
315
|
-
truncateCandidate(fd, bytes.length);
|
|
316
|
-
fsyncSync(fd);
|
|
317
|
-
}
|
|
318
|
-
finally {
|
|
319
|
-
closeSync(fd);
|
|
320
|
-
}
|
|
321
|
-
const current = sha(learningFile(s.files.skill));
|
|
322
|
-
if (current !== sha(Buffer.from(text)))
|
|
323
|
-
throw Error('edited candidate bytes changed');
|
|
324
|
-
append(pending.id, { type: 'edited', skillHash: current });
|
|
325
|
-
return evaluation();
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
import { ftruncateSync as truncateCandidate } from 'node:fs';
|
|
330
|
-
//# sourceMappingURL=weekly-investigation.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type WorkCaptureCaseV2 } from "@skill-harness/core";
|
|
2
|
-
import type { WorkProjection } from "./generated/retention-v2-work-types.js";
|
|
3
|
-
export interface WorkDetectionOptions {
|
|
4
|
-
version: string;
|
|
5
|
-
population: string;
|
|
6
|
-
scopeDigest: string;
|
|
7
|
-
minEquivalentAttempts: number;
|
|
8
|
-
/** Explicit frozen domain facts, never inferred from worker prose. Values are obligation digests. */
|
|
9
|
-
expectedWaits: string[];
|
|
10
|
-
expectedFailures: string[];
|
|
11
|
-
exemplar?: {
|
|
12
|
-
unit: "wall_ms" | "tool_calls" | "usd";
|
|
13
|
-
maximum: number;
|
|
14
|
-
};
|
|
15
|
-
usage?: Record<string, {
|
|
16
|
-
observed: boolean;
|
|
17
|
-
cost: number;
|
|
18
|
-
unit: "wall_ms" | "tool_calls" | "usd";
|
|
19
|
-
evidence: string;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
export declare const WORK_CANDIDATE_IMPLEMENTATION = "structural-work-v2";
|
|
23
|
-
/** Consumes the actual P01 host projection, not arbitrary native wire or a new acceptance authority. */
|
|
24
|
-
export declare function detectWorkCandidates(work: WorkProjection, options: WorkDetectionOptions): {
|
|
25
|
-
version: "work-candidates-v1";
|
|
26
|
-
cases: WorkCaptureCaseV2[];
|
|
27
|
-
issues: string[];
|
|
28
|
-
expected: string[];
|
|
29
|
-
};
|