project-tiny-context-harness 0.8.12 → 0.8.13
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/README.md +43 -19
- package/assets/README.md +81 -40
- package/assets/README.zh-CN.md +44 -22
- package/assets/agents/AGENTS_CORE.md +8 -4
- package/assets/skills/context_development_engineer/SKILL.md +9 -1
- package/assets/skills/design-resource-authoring/SKILL.md +7 -5
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +2 -2
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +22 -2
- package/assets/skills/design-resource-authoring/references/recovery-and-writeback.md +199 -0
- package/assets/skills/design-resource-authoring/references/resource-selection.md +2 -2
- package/assets/skills/long-task-workflow/SKILL.md +6 -6
- package/assets/skills/long-task-workflow/references/contract-authoring.md +27 -22
- package/assets/skills/long-task-workflow/references/evidence-design.md +49 -32
- package/assets/skills/long-task-workflow/references/source-authoring.md +2 -2
- package/dist/commands/design-resource-recovery.d.ts +1 -0
- package/dist/commands/design-resource-recovery.js +152 -0
- package/dist/commands/design-resource.js +20 -1
- package/dist/commands/index.js +1 -1
- package/dist/lib/design-resource-reconciliation-codec.d.ts +2 -0
- package/dist/lib/design-resource-reconciliation-codec.js +174 -0
- package/dist/lib/design-resource-reconciliation-types.d.ts +62 -0
- package/dist/lib/design-resource-reconciliation-types.js +1 -0
- package/dist/lib/design-resource-reconciliation.d.ts +3 -0
- package/dist/lib/design-resource-reconciliation.js +224 -0
- package/dist/lib/design-resource-recovery-authority-policy.d.ts +8 -0
- package/dist/lib/design-resource-recovery-authority-policy.js +123 -0
- package/dist/lib/design-resource-recovery-catalog-resources.d.ts +6 -0
- package/dist/lib/design-resource-recovery-catalog-resources.js +121 -0
- package/dist/lib/design-resource-recovery-catalog-shape.d.ts +3 -0
- package/dist/lib/design-resource-recovery-catalog-shape.js +104 -0
- package/dist/lib/design-resource-recovery-catalog.d.ts +9 -0
- package/dist/lib/design-resource-recovery-catalog.js +103 -0
- package/dist/lib/design-resource-recovery-cleanup.d.ts +2 -0
- package/dist/lib/design-resource-recovery-cleanup.js +11 -0
- package/dist/lib/design-resource-recovery-codec-primitives.d.ts +19 -0
- package/dist/lib/design-resource-recovery-codec-primitives.js +92 -0
- package/dist/lib/design-resource-recovery-codec.d.ts +4 -0
- package/dist/lib/design-resource-recovery-codec.js +93 -0
- package/dist/lib/design-resource-recovery-current.d.ts +9 -0
- package/dist/lib/design-resource-recovery-current.js +41 -0
- package/dist/lib/design-resource-recovery-delta-policy.d.ts +5 -0
- package/dist/lib/design-resource-recovery-delta-policy.js +108 -0
- package/dist/lib/design-resource-recovery-files.d.ts +37 -0
- package/dist/lib/design-resource-recovery-files.js +204 -0
- package/dist/lib/design-resource-recovery-final-disposition-shape.d.ts +2 -0
- package/dist/lib/design-resource-recovery-final-disposition-shape.js +47 -0
- package/dist/lib/design-resource-recovery-patch-types.d.ts +54 -0
- package/dist/lib/design-resource-recovery-patch-types.js +1 -0
- package/dist/lib/design-resource-recovery-replay.d.ts +7 -0
- package/dist/lib/design-resource-recovery-replay.js +112 -0
- package/dist/lib/design-resource-recovery-repository-bindings.d.ts +9 -0
- package/dist/lib/design-resource-recovery-repository-bindings.js +49 -0
- package/dist/lib/design-resource-recovery-schema.d.ts +5 -0
- package/dist/lib/design-resource-recovery-schema.js +5 -0
- package/dist/lib/design-resource-recovery-shape.d.ts +10 -0
- package/dist/lib/design-resource-recovery-shape.js +184 -0
- package/dist/lib/design-resource-recovery-source-authority.d.ts +5 -0
- package/dist/lib/design-resource-recovery-source-authority.js +219 -0
- package/dist/lib/design-resource-recovery-text.d.ts +17 -0
- package/dist/lib/design-resource-recovery-text.js +186 -0
- package/dist/lib/design-resource-recovery-types.d.ts +197 -0
- package/dist/lib/design-resource-recovery-types.js +1 -0
- package/dist/lib/design-resource-recovery-writeback-policy.d.ts +5 -0
- package/dist/lib/design-resource-recovery-writeback-policy.js +326 -0
- package/dist/lib/design-resource-recovery-writeback-shape.d.ts +6 -0
- package/dist/lib/design-resource-recovery-writeback-shape.js +155 -0
- package/dist/lib/design-resource-recovery.d.ts +44 -0
- package/dist/lib/design-resource-recovery.js +216 -0
- package/dist/lib/long-task-acceptance-shape.js +8 -2
- package/dist/lib/long-task-activation-validation.js +13 -3
- package/dist/lib/long-task-admitted-observation-records.d.ts +25 -0
- package/dist/lib/long-task-admitted-observation-records.js +40 -0
- package/dist/lib/long-task-admitted-observation.d.ts +93 -0
- package/dist/lib/long-task-admitted-observation.js +201 -0
- package/dist/lib/long-task-artifacts.d.ts +1 -0
- package/dist/lib/long-task-artifacts.js +1 -0
- package/dist/lib/long-task-authority-material-diff.js +1 -0
- package/dist/lib/long-task-authority-policy.d.ts +2 -0
- package/dist/lib/long-task-authority-policy.js +2 -0
- package/dist/lib/long-task-authority-revision-details.js +3 -1
- package/dist/lib/long-task-authority.js +2 -1
- package/dist/lib/long-task-check-execution-policy.js +5 -0
- package/dist/lib/long-task-check-runner.d.ts +2 -2
- package/dist/lib/long-task-check-runner.js +440 -23
- package/dist/lib/long-task-claims.d.ts +18 -0
- package/dist/lib/long-task-claims.js +35 -0
- package/dist/lib/long-task-compact-structure-targets.js +1 -0
- package/dist/lib/long-task-conformance-policy.js +3 -1
- package/dist/lib/long-task-counterfactual-claim-policy.d.ts +3 -4
- package/dist/lib/long-task-counterfactual-claim-policy.js +11 -3
- package/dist/lib/long-task-counterfactual-sandbox.js +1 -0
- package/dist/lib/long-task-counterfactual-types.d.ts +2 -0
- package/dist/lib/long-task-delivery-compiler.js +2 -0
- package/dist/lib/long-task-evidence-capability-policy.d.ts +3 -2
- package/dist/lib/long-task-evidence-capability-policy.js +114 -8
- package/dist/lib/long-task-evidence-capability-runtime.d.ts +5 -2
- package/dist/lib/long-task-evidence-capability-runtime.js +149 -5
- package/dist/lib/long-task-evidence-sensitivity-policy.d.ts +9 -0
- package/dist/lib/long-task-evidence-sensitivity-policy.js +31 -1
- package/dist/lib/long-task-evidence-v2.d.ts +4 -4
- package/dist/lib/long-task-evidence-v2.js +321 -43
- package/dist/lib/long-task-exact-comparison.d.ts +16 -0
- package/dist/lib/long-task-exact-comparison.js +28 -0
- package/dist/lib/long-task-execution-observation.d.ts +24 -0
- package/dist/lib/long-task-execution-observation.js +332 -0
- package/dist/lib/long-task-explain-acceptance-link.d.ts +4 -0
- package/dist/lib/long-task-explain-acceptance-link.js +4 -0
- package/dist/lib/long-task-explain-claim-links.d.ts +2 -0
- package/dist/lib/long-task-explain-claim-links.js +2 -0
- package/dist/lib/long-task-explain-source-links.d.ts +6 -0
- package/dist/lib/long-task-final-v2.js +7 -4
- package/dist/lib/long-task-json-pointer-observation.d.ts +59 -0
- package/dist/lib/long-task-json-pointer-observation.js +184 -0
- package/dist/lib/long-task-observation-artifact.d.ts +8 -0
- package/dist/lib/long-task-observation-artifact.js +58 -0
- package/dist/lib/long-task-observation-authority.d.ts +17 -0
- package/dist/lib/long-task-observation-authority.js +348 -0
- package/dist/lib/long-task-paths.js +1 -1
- package/dist/lib/long-task-process-observation.d.ts +6 -0
- package/dist/lib/long-task-process-observation.js +117 -0
- package/dist/lib/long-task-process-runtime-closure.d.ts +13 -0
- package/dist/lib/long-task-process-runtime-closure.js +175 -0
- package/dist/lib/long-task-progress.js +2 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -1
- package/dist/lib/long-task-protected-files.js +1 -30
- package/dist/lib/long-task-risk.js +8 -3
- package/dist/lib/long-task-root-shape.js +10 -1
- package/dist/lib/long-task-runner-environment.d.ts +1 -1
- package/dist/lib/long-task-runner-environment.js +4 -4
- package/dist/lib/long-task-runner-freeze.d.ts +4 -2
- package/dist/lib/long-task-runner-freeze.js +128 -28
- package/dist/lib/long-task-runtime-types.d.ts +111 -0
- package/dist/lib/long-task-scoped-binding.d.ts +13 -0
- package/dist/lib/long-task-scoped-binding.js +11 -0
- package/dist/lib/long-task-semantic-contract-types.d.ts +1 -0
- package/dist/lib/long-task-semantic-fact-contract-closure.js +3 -3
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +3 -3
- package/dist/lib/long-task-semantic-fact-evidence.js +75 -58
- package/dist/lib/long-task-source-claim-validation.js +4 -1
- package/dist/lib/long-task-source-target-continuity.d.ts +2 -2
- package/dist/lib/long-task-source-target-continuity.js +35 -2
- package/dist/lib/long-task-source-target-index.d.ts +3 -0
- package/dist/lib/long-task-source-target-index.js +19 -0
- package/dist/lib/long-task-stage-policy.js +10 -4
- package/dist/lib/long-task-static-observation-freeze.d.ts +83 -0
- package/dist/lib/long-task-static-observation-freeze.js +428 -0
- package/dist/lib/long-task-status-projection.js +5 -1
- package/dist/lib/long-task-target-policy.d.ts +1 -1
- package/dist/lib/long-task-target-policy.js +3 -0
- package/dist/lib/long-task-verifier-dependency-closure.js +7 -3
- package/dist/lib/long-task-verifier-v2.js +70 -9
- package/dist/lib/long-task-workspace.d.ts +1 -1
- package/dist/lib/long-task-workspace.js +1 -12
- package/dist/lib/repository-path-safety.d.ts +14 -0
- package/dist/lib/repository-path-safety.js +126 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +53 -8
- package/migrations/README.md +77 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { DESIGN_RESOURCE_PATCH_SCHEMA } from "./design-resource-recovery-schema.js";
|
|
2
|
+
import { arrayOf, digest, integer, literal, multilineText, object, oneOf, optionalArrayOf, stringSet, text, } from "./design-resource-recovery-codec-primitives.js";
|
|
3
|
+
const ENCODINGS = ["utf8", "utf8-bom", "utf16le", "utf16be"];
|
|
4
|
+
export function parseProviderReferences(value, label) {
|
|
5
|
+
const row = object(value, label, ["project", "run", "resources"]);
|
|
6
|
+
return {
|
|
7
|
+
project: parseProviderIdentity(row.project, `${label}.project`),
|
|
8
|
+
run: parseProviderIdentity(row.run, `${label}.run`),
|
|
9
|
+
resources: optionalArrayOf(row.resources, `${label}.resources`, parseProviderResourceIdentity),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function parsePatch(value, label) {
|
|
13
|
+
const row = object(value, label, ["schema_version", "operations"]);
|
|
14
|
+
literal(row.schema_version, DESIGN_RESOURCE_PATCH_SCHEMA, `${label}.schema_version`);
|
|
15
|
+
return {
|
|
16
|
+
schema_version: DESIGN_RESOURCE_PATCH_SCHEMA,
|
|
17
|
+
operations: arrayOf(row.operations, `${label}.operations`, (item, itemLabel) => {
|
|
18
|
+
const operation = object(item, itemLabel, [
|
|
19
|
+
"operation_id",
|
|
20
|
+
"operation",
|
|
21
|
+
"target_key",
|
|
22
|
+
"delta_id",
|
|
23
|
+
"before_text",
|
|
24
|
+
"after_text",
|
|
25
|
+
"before_text_sha256",
|
|
26
|
+
"after_text_sha256",
|
|
27
|
+
"source_span",
|
|
28
|
+
"semantic_binding",
|
|
29
|
+
"expected_occurrences",
|
|
30
|
+
]);
|
|
31
|
+
literal(operation.expected_occurrences, 1, `${itemLabel}.expected_occurrences`);
|
|
32
|
+
return {
|
|
33
|
+
operation_id: text(operation.operation_id, `${itemLabel}.operation_id`),
|
|
34
|
+
operation: oneOf(operation.operation, ["add", "replace", "remove"], `${itemLabel}.operation`),
|
|
35
|
+
target_key: text(operation.target_key, `${itemLabel}.target_key`),
|
|
36
|
+
delta_id: text(operation.delta_id, `${itemLabel}.delta_id`),
|
|
37
|
+
before_text: multilineText(operation.before_text, `${itemLabel}.before_text`),
|
|
38
|
+
after_text: multilineText(operation.after_text, `${itemLabel}.after_text`, { allowEmpty: true }),
|
|
39
|
+
before_text_sha256: digest(operation.before_text_sha256, `${itemLabel}.before_text_sha256`),
|
|
40
|
+
after_text_sha256: digest(operation.after_text_sha256, `${itemLabel}.after_text_sha256`),
|
|
41
|
+
source_span: parsePatchSourceSpan(operation.source_span, `${itemLabel}.source_span`),
|
|
42
|
+
semantic_binding: parsePatchSemanticBinding(operation.semantic_binding, `${itemLabel}.semantic_binding`),
|
|
43
|
+
expected_occurrences: 1,
|
|
44
|
+
};
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function parsePatchSourceSpan(value, label) {
|
|
49
|
+
const row = object(value, label, [
|
|
50
|
+
"coordinate_system",
|
|
51
|
+
"start_offset",
|
|
52
|
+
"end_offset",
|
|
53
|
+
"before_text_sha256",
|
|
54
|
+
]);
|
|
55
|
+
literal(row.coordinate_system, "utf16-code-unit-v1", `${label}.coordinate_system`);
|
|
56
|
+
return {
|
|
57
|
+
coordinate_system: "utf16-code-unit-v1",
|
|
58
|
+
start_offset: integer(row.start_offset, `${label}.start_offset`),
|
|
59
|
+
end_offset: integer(row.end_offset, `${label}.end_offset`),
|
|
60
|
+
before_text_sha256: digest(row.before_text_sha256, `${label}.before_text_sha256`),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function parsePatchSemanticBinding(value, label) {
|
|
64
|
+
const row = object(value, label, [
|
|
65
|
+
"delta_id",
|
|
66
|
+
"target_key",
|
|
67
|
+
"before_semantics_sha256",
|
|
68
|
+
"after_semantics_sha256",
|
|
69
|
+
"before_text_projection",
|
|
70
|
+
"after_text_projection",
|
|
71
|
+
]);
|
|
72
|
+
return {
|
|
73
|
+
delta_id: text(row.delta_id, `${label}.delta_id`),
|
|
74
|
+
target_key: text(row.target_key, `${label}.target_key`),
|
|
75
|
+
before_semantics_sha256: digest(row.before_semantics_sha256, `${label}.before_semantics_sha256`),
|
|
76
|
+
after_semantics_sha256: digest(row.after_semantics_sha256, `${label}.after_semantics_sha256`),
|
|
77
|
+
before_text_projection: parseTextProjection(row.before_text_projection, `${label}.before_text_projection`),
|
|
78
|
+
after_text_projection: parseTextProjection(row.after_text_projection, `${label}.after_text_projection`),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseTextProjection(value, label) {
|
|
82
|
+
if (value === null)
|
|
83
|
+
return null;
|
|
84
|
+
const row = object(value, label, [
|
|
85
|
+
"semantic_path",
|
|
86
|
+
"start_offset",
|
|
87
|
+
"end_offset",
|
|
88
|
+
]);
|
|
89
|
+
return {
|
|
90
|
+
semantic_path: arrayOf(row.semantic_path, `${label}.semantic_path`, (item, itemLabel) => text(item, itemLabel), { allowEmpty: true }),
|
|
91
|
+
start_offset: integer(row.start_offset, `${label}.start_offset`),
|
|
92
|
+
end_offset: integer(row.end_offset, `${label}.end_offset`),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function parseWritebackInput(value, label, complete) {
|
|
96
|
+
const fields = [
|
|
97
|
+
"target_locator",
|
|
98
|
+
"pre_write_raw_byte_digest",
|
|
99
|
+
"patch",
|
|
100
|
+
"patch_identity",
|
|
101
|
+
"expected_post_write_raw_byte_digest",
|
|
102
|
+
"resource_identities",
|
|
103
|
+
"proposal_written_delta_ids",
|
|
104
|
+
];
|
|
105
|
+
if (complete)
|
|
106
|
+
fields.push("target_encoding", "target_eol_policy");
|
|
107
|
+
const row = object(value, label, fields);
|
|
108
|
+
const base = {
|
|
109
|
+
target_locator: text(row.target_locator, `${label}.target_locator`),
|
|
110
|
+
pre_write_raw_byte_digest: digest(row.pre_write_raw_byte_digest, `${label}.pre_write_raw_byte_digest`),
|
|
111
|
+
patch: parsePatch(row.patch, `${label}.patch`),
|
|
112
|
+
patch_identity: digest(row.patch_identity, `${label}.patch_identity`),
|
|
113
|
+
expected_post_write_raw_byte_digest: digest(row.expected_post_write_raw_byte_digest, `${label}.expected_post_write_raw_byte_digest`),
|
|
114
|
+
resource_identities: optionalArrayOf(row.resource_identities, `${label}.resource_identities`, parseResourceDigestIdentity),
|
|
115
|
+
proposal_written_delta_ids: stringSet(row.proposal_written_delta_ids, `${label}.proposal_written_delta_ids`, { allowEmpty: true }),
|
|
116
|
+
};
|
|
117
|
+
if (!complete)
|
|
118
|
+
return base;
|
|
119
|
+
return {
|
|
120
|
+
...base,
|
|
121
|
+
target_encoding: oneOf(row.target_encoding, ENCODINGS, `${label}.target_encoding`),
|
|
122
|
+
target_eol_policy: oneOf(row.target_eol_policy, ["none", "lf", "crlf", "cr"], `${label}.target_eol_policy`),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function parseProviderIdentity(value, label) {
|
|
126
|
+
const row = object(value, label, ["key", "locator", "immutable_identity"]);
|
|
127
|
+
return {
|
|
128
|
+
key: text(row.key, `${label}.key`),
|
|
129
|
+
locator: text(row.locator, `${label}.locator`),
|
|
130
|
+
immutable_identity: text(row.immutable_identity, `${label}.immutable_identity`),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function parseProviderResourceIdentity(value, label) {
|
|
134
|
+
const row = object(value, label, [
|
|
135
|
+
"key",
|
|
136
|
+
"locator",
|
|
137
|
+
"immutable_identity",
|
|
138
|
+
"raw_byte_digest",
|
|
139
|
+
]);
|
|
140
|
+
return {
|
|
141
|
+
...parseProviderIdentity({
|
|
142
|
+
key: row.key,
|
|
143
|
+
locator: row.locator,
|
|
144
|
+
immutable_identity: row.immutable_identity,
|
|
145
|
+
}, label),
|
|
146
|
+
raw_byte_digest: digest(row.raw_byte_digest, `${label}.raw_byte_digest`),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function parseResourceDigestIdentity(value, label) {
|
|
150
|
+
const row = object(value, label, ["key", "raw_byte_digest"]);
|
|
151
|
+
return {
|
|
152
|
+
key: text(row.key, `${label}.key`),
|
|
153
|
+
raw_byte_digest: digest(row.raw_byte_digest, `${label}.raw_byte_digest`),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type DesignResourceRecoveryCheckpoint, type DesignResourceRecoveryCreateInput, type DesignResourceReplayProjection } from "./design-resource-recovery-types.js";
|
|
2
|
+
import type { DesignResourceReconciliationResult } from "./design-resource-reconciliation-types.js";
|
|
3
|
+
export interface DesignResourceRecoveryInspection {
|
|
4
|
+
status: "recoverable";
|
|
5
|
+
checkpoint_path: string;
|
|
6
|
+
checkpoint_raw_byte_digest: string;
|
|
7
|
+
replay: DesignResourceReplayProjection;
|
|
8
|
+
writeback: {
|
|
9
|
+
configured: false;
|
|
10
|
+
} | {
|
|
11
|
+
configured: true;
|
|
12
|
+
state: "unapplied" | "applied" | "conflict";
|
|
13
|
+
current_raw_byte_digest: string;
|
|
14
|
+
pre_write_raw_byte_digest: string;
|
|
15
|
+
expected_post_write_raw_byte_digest: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function createDesignResourceRecoveryCheckpoint(repository: string, input: DesignResourceRecoveryCreateInput): Promise<{
|
|
19
|
+
status: "created" | "already-current";
|
|
20
|
+
checkpoint_path: string;
|
|
21
|
+
checkpoint_raw_byte_digest: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function updateDesignResourceRecoveryCheckpoint(repository: string, input: DesignResourceRecoveryCreateInput, expectedCurrentDigest: string): Promise<{
|
|
24
|
+
status: "updated" | "already-current";
|
|
25
|
+
checkpoint_path: string;
|
|
26
|
+
checkpoint_raw_byte_digest: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function inspectDesignResourceRecovery(repository: string, sessionId: string): Promise<DesignResourceRecoveryInspection>;
|
|
29
|
+
export declare function previewDesignResourceRecoveryWriteback(repository: string, sessionId: string): Promise<DesignResourceRecoveryInspection & {
|
|
30
|
+
patch: DesignResourceRecoveryCheckpoint["writeback"];
|
|
31
|
+
}>;
|
|
32
|
+
export declare function applyDesignResourceRecoveryWriteback(repository: string, sessionId: string, auditLocator: string): Promise<{
|
|
33
|
+
status: "writeback-applied" | "writeback-idempotent" | "external-resource-revalidation-pending" | "blocked";
|
|
34
|
+
write_transaction: boolean;
|
|
35
|
+
idempotent_replay: boolean;
|
|
36
|
+
reconciliation: DesignResourceReconciliationResult;
|
|
37
|
+
target_raw_byte_digest: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function reconcileDesignResourceRecovery(repository: string, sessionId: string, auditLocator: string): Promise<{
|
|
40
|
+
status: "reconciliation-balanced" | "external-resource-revalidation-pending" | "blocked";
|
|
41
|
+
write_transaction: false;
|
|
42
|
+
reconciliation: DesignResourceReconciliationResult;
|
|
43
|
+
}>;
|
|
44
|
+
export { removeDesignResourceRecoveryCheckpoint } from "./design-resource-recovery-cleanup.js";
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createRecoveryCheckpointFile, deriveDigestCasState, atomicCasWrite, readRecoveryCheckpointFile, readRecoveryRepositoryFile, updateRecoveryCheckpointFile, } from "./design-resource-recovery-files.js";
|
|
2
|
+
import { loadCurrentDesignResourceRecoveryCheckpoint, validateDesignResourceRepositoryAuthority, } from "./design-resource-recovery-current.js";
|
|
3
|
+
import { encodeDesignResourceRecoveryCheckpoint, parseDesignResourceRecoveryCheckpoint, } from "./design-resource-recovery-codec.js";
|
|
4
|
+
import { parseDesignResourceReconciliationAudit } from "./design-resource-reconciliation-codec.js";
|
|
5
|
+
import { reconcileDesignResourceWriteback } from "./design-resource-reconciliation.js";
|
|
6
|
+
import { activeAcceptedDesignResourceDeltas, createDesignResourceReplayProjection, validateDesignResourceRecoverySemantics, } from "./design-resource-recovery-replay.js";
|
|
7
|
+
import { applyDesignResourceExactPatch, decodeDesignResourceText, verifyDesignResourceExactPatchReadback, verifyDesignResourceSupersededTextReadback, } from "./design-resource-recovery-text.js";
|
|
8
|
+
import { validateDesignResourceAuthoritySourceItems } from "./design-resource-recovery-source-authority.js";
|
|
9
|
+
import { validateReconciliationDownstreamOwners, validateSelectedResourceRepositoryBindings, } from "./design-resource-recovery-repository-bindings.js";
|
|
10
|
+
import { DESIGN_RESOURCE_RECOVERY_SCHEMA } from "./design-resource-recovery-schema.js";
|
|
11
|
+
import { sha256Hex } from "./strict-codec.js";
|
|
12
|
+
export async function createDesignResourceRecoveryCheckpoint(repository, input) {
|
|
13
|
+
const { encoded } = await prepareDesignResourceRecoveryCheckpoint(repository, input);
|
|
14
|
+
const written = await createRecoveryCheckpointFile(repository, input.session_id, Buffer.from(encoded, "utf8"));
|
|
15
|
+
return {
|
|
16
|
+
status: written.changed ? "created" : "already-current",
|
|
17
|
+
checkpoint_path: written.path,
|
|
18
|
+
checkpoint_raw_byte_digest: written.raw_byte_digest,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function updateDesignResourceRecoveryCheckpoint(repository, input, expectedCurrentDigest) {
|
|
22
|
+
const current = await readRecoveryCheckpointFile(repository, input.session_id);
|
|
23
|
+
assertDigest("checkpoint_update", current.raw_byte_digest, expectedCurrentDigest);
|
|
24
|
+
const currentCheckpoint = parseDesignResourceRecoveryCheckpoint(current.bytes.toString("utf8"));
|
|
25
|
+
if (currentCheckpoint.session_id !== input.session_id)
|
|
26
|
+
throw new Error("design_resource_recovery_invalid:update_session_identity_mismatch");
|
|
27
|
+
validateDesignResourceRecoverySemantics(currentCheckpoint);
|
|
28
|
+
const { encoded } = await prepareDesignResourceRecoveryCheckpoint(repository, input);
|
|
29
|
+
const written = await updateRecoveryCheckpointFile(repository, input.session_id, Buffer.from(encoded, "utf8"), expectedCurrentDigest);
|
|
30
|
+
const readback = await readRecoveryCheckpointFile(repository, input.session_id);
|
|
31
|
+
assertDigest("checkpoint_update_readback", readback.raw_byte_digest, written.raw_byte_digest);
|
|
32
|
+
const parsed = parseDesignResourceRecoveryCheckpoint(readback.bytes.toString("utf8"));
|
|
33
|
+
validateDesignResourceRecoverySemantics(parsed);
|
|
34
|
+
return {
|
|
35
|
+
status: written.changed ? "updated" : "already-current",
|
|
36
|
+
checkpoint_path: written.path,
|
|
37
|
+
checkpoint_raw_byte_digest: written.raw_byte_digest,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function prepareDesignResourceRecoveryCheckpoint(repository, input) {
|
|
41
|
+
validateDesignResourceRecoverySemantics(input);
|
|
42
|
+
const baseSnapshot = await readRecoveryRepositoryFile(repository, input.base.locator, "design_resource_recovery_base");
|
|
43
|
+
assertDigest("base", baseSnapshot.raw_byte_digest, input.base.raw_byte_digest);
|
|
44
|
+
const baseText = decodeDesignResourceText(baseSnapshot.bytes);
|
|
45
|
+
await validateDesignResourceRepositoryAuthority(repository, input.design_authority);
|
|
46
|
+
await validateDesignResourceAuthoritySourceItems(repository, input);
|
|
47
|
+
await validateSelectedResourceRepositoryBindings(repository, input);
|
|
48
|
+
let writeback;
|
|
49
|
+
if (input.writeback) {
|
|
50
|
+
const target = await readRecoveryRepositoryFile(repository, input.writeback.target_locator, "design_resource_recovery_writeback_target");
|
|
51
|
+
assertDigest("writeback_pre", target.raw_byte_digest, input.writeback.pre_write_raw_byte_digest);
|
|
52
|
+
const patched = applyDesignResourceExactPatch(target.bytes, input.writeback.patch);
|
|
53
|
+
assertDigest("writeback_expected_post", sha256Hex(patched.bytes), input.writeback.expected_post_write_raw_byte_digest);
|
|
54
|
+
verifyDesignResourceSupersededTextReadback(patched.bytes, input.writeback.patch, supersedingDeltaIds(input));
|
|
55
|
+
writeback = {
|
|
56
|
+
...input.writeback,
|
|
57
|
+
target_encoding: patched.encoding,
|
|
58
|
+
target_eol_policy: patched.eol_policy,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const { schema_version: _inputSchema, base: _inputBase, writeback: _inputWriteback, ...common } = input;
|
|
62
|
+
const checkpoint = {
|
|
63
|
+
...common,
|
|
64
|
+
schema_version: DESIGN_RESOURCE_RECOVERY_SCHEMA,
|
|
65
|
+
owner: "ty-context-design-resource-recovery",
|
|
66
|
+
base: {
|
|
67
|
+
...input.base,
|
|
68
|
+
encoding: baseText.encoding,
|
|
69
|
+
eol_policy: baseText.eol_policy,
|
|
70
|
+
},
|
|
71
|
+
...(writeback ? { writeback } : {}),
|
|
72
|
+
};
|
|
73
|
+
validateDesignResourceRecoverySemantics(checkpoint);
|
|
74
|
+
const encoded = encodeDesignResourceRecoveryCheckpoint(checkpoint);
|
|
75
|
+
const roundTrip = parseDesignResourceRecoveryCheckpoint(encoded);
|
|
76
|
+
validateDesignResourceRecoverySemantics(roundTrip);
|
|
77
|
+
return {
|
|
78
|
+
checkpoint: roundTrip,
|
|
79
|
+
encoded,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export async function inspectDesignResourceRecovery(repository, sessionId) {
|
|
83
|
+
const loaded = await loadCurrentDesignResourceRecoveryCheckpoint(repository, sessionId);
|
|
84
|
+
const writeback = loaded.checkpoint.writeback;
|
|
85
|
+
if (!writeback)
|
|
86
|
+
return {
|
|
87
|
+
status: "recoverable",
|
|
88
|
+
checkpoint_path: loaded.path,
|
|
89
|
+
checkpoint_raw_byte_digest: loaded.digest,
|
|
90
|
+
replay: createDesignResourceReplayProjection(loaded.checkpoint),
|
|
91
|
+
writeback: { configured: false },
|
|
92
|
+
};
|
|
93
|
+
const target = await readRecoveryRepositoryFile(repository, writeback.target_locator, "design_resource_recovery_writeback_target");
|
|
94
|
+
return {
|
|
95
|
+
status: "recoverable",
|
|
96
|
+
checkpoint_path: loaded.path,
|
|
97
|
+
checkpoint_raw_byte_digest: loaded.digest,
|
|
98
|
+
replay: createDesignResourceReplayProjection(loaded.checkpoint),
|
|
99
|
+
writeback: {
|
|
100
|
+
configured: true,
|
|
101
|
+
state: deriveDigestCasState(target.raw_byte_digest, writeback.pre_write_raw_byte_digest, writeback.expected_post_write_raw_byte_digest),
|
|
102
|
+
current_raw_byte_digest: target.raw_byte_digest,
|
|
103
|
+
pre_write_raw_byte_digest: writeback.pre_write_raw_byte_digest,
|
|
104
|
+
expected_post_write_raw_byte_digest: writeback.expected_post_write_raw_byte_digest,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export async function previewDesignResourceRecoveryWriteback(repository, sessionId) {
|
|
109
|
+
const inspection = await inspectDesignResourceRecovery(repository, sessionId);
|
|
110
|
+
const checkpoint = (await loadCurrentDesignResourceRecoveryCheckpoint(repository, sessionId)).checkpoint;
|
|
111
|
+
if (!checkpoint.writeback)
|
|
112
|
+
throw new Error("design_resource_recovery_invalid:writeback_not_configured");
|
|
113
|
+
return { ...inspection, patch: checkpoint.writeback };
|
|
114
|
+
}
|
|
115
|
+
export async function applyDesignResourceRecoveryWriteback(repository, sessionId, auditLocator) {
|
|
116
|
+
const { checkpoint } = await loadCurrentDesignResourceRecoveryCheckpoint(repository, sessionId);
|
|
117
|
+
const writeback = checkpoint.writeback;
|
|
118
|
+
if (!writeback)
|
|
119
|
+
throw new Error("design_resource_recovery_invalid:writeback_not_configured");
|
|
120
|
+
const auditSnapshot = await readRecoveryRepositoryFile(repository, auditLocator, "design_resource_recovery_fresh_audit");
|
|
121
|
+
const audit = parseDesignResourceReconciliationAudit(auditSnapshot.bytes.toString("utf8"));
|
|
122
|
+
const preReconciliation = reconcileDesignResourceWriteback(checkpoint, audit);
|
|
123
|
+
let externalRevalidationRequired = false;
|
|
124
|
+
if (preReconciliation.status === "reconciliation-balanced") {
|
|
125
|
+
try {
|
|
126
|
+
externalRevalidationRequired = (await validateReconciliationDownstreamOwners(repository, checkpoint)).external_revalidation_required;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
preReconciliation.status = "blocked";
|
|
130
|
+
preReconciliation.findings.push(error instanceof Error ? error.message : String(error));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const target = await readRecoveryRepositoryFile(repository, writeback.target_locator, "design_resource_recovery_writeback_target");
|
|
134
|
+
const state = deriveDigestCasState(target.raw_byte_digest, writeback.pre_write_raw_byte_digest, writeback.expected_post_write_raw_byte_digest);
|
|
135
|
+
if (state === "conflict")
|
|
136
|
+
throw new Error("design_resource_recovery_invalid:writeback_cas_conflict");
|
|
137
|
+
if (preReconciliation.status === "blocked")
|
|
138
|
+
return {
|
|
139
|
+
status: "blocked",
|
|
140
|
+
write_transaction: false,
|
|
141
|
+
idempotent_replay: state === "applied",
|
|
142
|
+
reconciliation: preReconciliation,
|
|
143
|
+
target_raw_byte_digest: target.raw_byte_digest,
|
|
144
|
+
};
|
|
145
|
+
let wrote = false;
|
|
146
|
+
if (state === "unapplied") {
|
|
147
|
+
const patched = applyDesignResourceExactPatch(target.bytes, writeback.patch, writeback.target_encoding, writeback.target_eol_policy);
|
|
148
|
+
assertDigest("writeback_expected_post", sha256Hex(patched.bytes), writeback.expected_post_write_raw_byte_digest);
|
|
149
|
+
await atomicCasWrite(repository, writeback.target_locator, patched.bytes, writeback.pre_write_raw_byte_digest, target.mode);
|
|
150
|
+
wrote = true;
|
|
151
|
+
}
|
|
152
|
+
const post = await readRecoveryRepositoryFile(repository, writeback.target_locator, "design_resource_recovery_writeback_readback");
|
|
153
|
+
assertDigest("writeback_post_readback", post.raw_byte_digest, writeback.expected_post_write_raw_byte_digest);
|
|
154
|
+
verifyDesignResourceExactPatchReadback(post.bytes, writeback.patch);
|
|
155
|
+
verifyDesignResourceSupersededTextReadback(post.bytes, writeback.patch, supersedingDeltaIds(checkpoint));
|
|
156
|
+
const reconciliation = reconcileDesignResourceWriteback(checkpoint, audit);
|
|
157
|
+
if (reconciliation.status === "reconciliation-balanced") {
|
|
158
|
+
try {
|
|
159
|
+
externalRevalidationRequired = (await validateReconciliationDownstreamOwners(repository, checkpoint)).external_revalidation_required;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
reconciliation.status = "blocked";
|
|
163
|
+
reconciliation.findings.push(error instanceof Error ? error.message : String(error));
|
|
164
|
+
reconciliation.findings.sort();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
status: reconciliation.status === "blocked"
|
|
169
|
+
? "blocked"
|
|
170
|
+
: externalRevalidationRequired
|
|
171
|
+
? "external-resource-revalidation-pending"
|
|
172
|
+
: wrote
|
|
173
|
+
? "writeback-applied"
|
|
174
|
+
: "writeback-idempotent",
|
|
175
|
+
write_transaction: wrote,
|
|
176
|
+
idempotent_replay: !wrote,
|
|
177
|
+
reconciliation,
|
|
178
|
+
target_raw_byte_digest: post.raw_byte_digest,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export async function reconcileDesignResourceRecovery(repository, sessionId, auditLocator) {
|
|
182
|
+
const { checkpoint } = await loadCurrentDesignResourceRecoveryCheckpoint(repository, sessionId, { validateSelectedResources: false });
|
|
183
|
+
if (checkpoint.writeback)
|
|
184
|
+
throw new Error("design_resource_recovery_invalid:read_only_reconcile_requires_no_writeback");
|
|
185
|
+
const auditSnapshot = await readRecoveryRepositoryFile(repository, auditLocator, "design_resource_recovery_fresh_audit");
|
|
186
|
+
const audit = parseDesignResourceReconciliationAudit(auditSnapshot.bytes.toString("utf8"));
|
|
187
|
+
const reconciliation = reconcileDesignResourceWriteback(checkpoint, audit);
|
|
188
|
+
if (reconciliation.status === "blocked")
|
|
189
|
+
return { status: "blocked", write_transaction: false, reconciliation };
|
|
190
|
+
try {
|
|
191
|
+
const current = await validateReconciliationDownstreamOwners(repository, checkpoint);
|
|
192
|
+
return {
|
|
193
|
+
status: current.external_revalidation_required
|
|
194
|
+
? "external-resource-revalidation-pending"
|
|
195
|
+
: "reconciliation-balanced",
|
|
196
|
+
write_transaction: false,
|
|
197
|
+
reconciliation,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
reconciliation.status = "blocked";
|
|
202
|
+
reconciliation.findings.push(error instanceof Error ? error.message : String(error));
|
|
203
|
+
reconciliation.findings.sort();
|
|
204
|
+
return { status: "blocked", write_transaction: false, reconciliation };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export { removeDesignResourceRecoveryCheckpoint } from "./design-resource-recovery-cleanup.js";
|
|
208
|
+
function assertDigest(label, actual, expected) {
|
|
209
|
+
if (actual !== expected)
|
|
210
|
+
throw new Error(`design_resource_recovery_invalid:${label}_digest_mismatch:${expected}:${actual}`);
|
|
211
|
+
}
|
|
212
|
+
function supersedingDeltaIds(state) {
|
|
213
|
+
return new Set(activeAcceptedDesignResourceDeltas(state.deltas)
|
|
214
|
+
.filter((delta) => delta.supersedes.length > 0)
|
|
215
|
+
.map((delta) => delta.delta_id));
|
|
216
|
+
}
|
|
@@ -10,7 +10,7 @@ export function parseCounterfactuals(value, label) {
|
|
|
10
10
|
"check_key",
|
|
11
11
|
"mutation",
|
|
12
12
|
"expected_assertion_failures",
|
|
13
|
-
], ["preserved_assertions"]);
|
|
13
|
+
], ["preserved_assertions", "allowed_fanout_assertions"]);
|
|
14
14
|
const mutation = object(row.mutation, `${itemLabel}.mutation`, ["type"], [
|
|
15
15
|
"paths",
|
|
16
16
|
"path",
|
|
@@ -36,6 +36,9 @@ export function parseCounterfactuals(value, label) {
|
|
|
36
36
|
preserved_assertions: Object.hasOwn(row, "preserved_assertions")
|
|
37
37
|
? strings(row.preserved_assertions, `${itemLabel}.preserved_assertions`).map((item, assertionIndex) => key(item, `${itemLabel}.preserved_assertions[${assertionIndex}]`))
|
|
38
38
|
: [],
|
|
39
|
+
allowed_fanout_assertions: Object.hasOwn(row, "allowed_fanout_assertions")
|
|
40
|
+
? strings(row.allowed_fanout_assertions, `${itemLabel}.allowed_fanout_assertions`).map((item, assertionIndex) => key(item, `${itemLabel}.allowed_fanout_assertions[${assertionIndex}]`))
|
|
41
|
+
: [],
|
|
39
42
|
};
|
|
40
43
|
});
|
|
41
44
|
}
|
|
@@ -49,7 +52,7 @@ export function parseGlobalCounterfactuals(value, label) {
|
|
|
49
52
|
"check_key",
|
|
50
53
|
"mutation",
|
|
51
54
|
"expected_assertion_failures",
|
|
52
|
-
], ["preserved_assertions"]);
|
|
55
|
+
], ["preserved_assertions", "allowed_fanout_assertions"]);
|
|
53
56
|
const bindingRef = string(row.binding_ref, `${itemLabel}.binding_ref`);
|
|
54
57
|
if (!/^[a-z0-9][a-z0-9-]*\.[a-z0-9][a-z0-9-]*$/u.test(bindingRef))
|
|
55
58
|
fail(`${itemLabel}.binding_ref`, "must be <outcome-key>.<binding-key>");
|
|
@@ -69,6 +72,9 @@ export function parseGlobalCounterfactuals(value, label) {
|
|
|
69
72
|
preserved_assertions: Object.hasOwn(row, "preserved_assertions")
|
|
70
73
|
? strings(row.preserved_assertions, `${itemLabel}.preserved_assertions`).map((entry, assertionIndex) => key(entry, `${itemLabel}.preserved_assertions[${assertionIndex}]`))
|
|
71
74
|
: [],
|
|
75
|
+
allowed_fanout_assertions: Object.hasOwn(row, "allowed_fanout_assertions")
|
|
76
|
+
? strings(row.allowed_fanout_assertions, `${itemLabel}.allowed_fanout_assertions`).map((entry, assertionIndex) => key(entry, `${itemLabel}.allowed_fanout_assertions[${assertionIndex}]`))
|
|
77
|
+
: [],
|
|
72
78
|
};
|
|
73
79
|
});
|
|
74
80
|
}
|
|
@@ -9,6 +9,7 @@ import { validateRawExecutionObservationOwnership } from "./long-task-observatio
|
|
|
9
9
|
import { validateLongTaskDesignResourceHandoffs } from "./long-task-design-resource-handoff.js";
|
|
10
10
|
import { validateLongTaskSemanticFactClosure } from "./long-task-semantic-fact-closure.js";
|
|
11
11
|
import { freezeDeliveryCheck } from "./long-task-runner-freeze.js";
|
|
12
|
+
import { scopeDeliveryBindings } from "./long-task-scoped-binding.js";
|
|
12
13
|
import { classifyLongTaskRisk, validateRiskProof, } from "./long-task-risk.js";
|
|
13
14
|
import { validateSourceContinuity } from "./long-task-source-continuity.js";
|
|
14
15
|
import { compileSourceInventory } from "./long-task-source-inventory.js";
|
|
@@ -33,12 +34,13 @@ export async function validateContractForActivation(options) {
|
|
|
33
34
|
}
|
|
34
35
|
const sourceHashes = await attempt(mode, diagnostics, () => hashDeclaredFiles(repository, contract.task.source_paths, "source"));
|
|
35
36
|
await attempt(mode, diagnostics, () => validateSourceAnchors(repository, contract.source_claims));
|
|
37
|
+
let sourceBackedExecutionTargets = new Map();
|
|
36
38
|
const sourceItems = await attempt(mode, diagnostics, async () => {
|
|
37
39
|
const items = await compileSourceInventory(repository, contract.task.source_paths);
|
|
38
40
|
validateSourceContinuity(contract, items, mode === "collect"
|
|
39
41
|
? (error) => addDiagnosticError(diagnostics, new Error(error))
|
|
40
42
|
: undefined);
|
|
41
|
-
validateSourceTargetContinuity(contract, items, mode === "collect"
|
|
43
|
+
sourceBackedExecutionTargets = validateSourceTargetContinuity(contract, items, mode === "collect"
|
|
42
44
|
? (error) => addDiagnosticError(diagnostics, new Error(error))
|
|
43
45
|
: undefined);
|
|
44
46
|
return items;
|
|
@@ -61,12 +63,20 @@ export async function validateContractForActivation(options) {
|
|
|
61
63
|
});
|
|
62
64
|
if (!workspace)
|
|
63
65
|
return emptyCompiledResult(claims, risk, sourceHashes, sourceItems, context);
|
|
66
|
+
const observationAuthorityPaths = [
|
|
67
|
+
...workspace.files
|
|
68
|
+
.map((file) => file.path)
|
|
69
|
+
.filter((file) => file === workdirRelative || file.startsWith(`${workdirRelative}/`)),
|
|
70
|
+
`${workdirRelative}/delivery-contract.yaml`,
|
|
71
|
+
...Object.keys(sourceHashes ?? {}),
|
|
72
|
+
...(context?.files ?? []),
|
|
73
|
+
];
|
|
64
74
|
const globalChecks = [];
|
|
65
75
|
for (const check of contract.global.acceptance.checks) {
|
|
66
76
|
const executionTarget = contract.task.execution_targets.find((target) => target.key === check.execution_target.target_ref);
|
|
67
77
|
if (!executionTarget)
|
|
68
78
|
continue;
|
|
69
|
-
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, null, repository, workspace, executionTarget, contract.task.execution_targets, [], [],
|
|
79
|
+
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, null, repository, workspace, executionTarget, contract.task.execution_targets, [], [], contract.outcomes.flatMap((outcome) => scopeDeliveryBindings(outcome.key, outcome.technical.bindings)), contract.outcomes.flatMap((outcome) => outcome.product.owner.path_globs), sourceBackedExecutionTargets.get(executionTarget.key) ?? null, observationAuthorityPaths), null, check.key);
|
|
70
80
|
if (frozen)
|
|
71
81
|
globalChecks.push(frozen);
|
|
72
82
|
}
|
|
@@ -77,7 +87,7 @@ export async function validateContractForActivation(options) {
|
|
|
77
87
|
const executionTarget = contract.task.execution_targets.find((target) => target.key === check.execution_target.target_ref);
|
|
78
88
|
if (!executionTarget)
|
|
79
89
|
continue;
|
|
80
|
-
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, outcome.key, repository, workspace, executionTarget, contract.task.execution_targets, designTargetsForCheck(outcome, check.key), semanticFactClosure?.expectations_by_check.get(check.key) ?? [],
|
|
90
|
+
const frozen = await attempt(mode, diagnostics, () => freezeDeliveryCheck(check, outcome.key, repository, workspace, executionTarget, contract.task.execution_targets, designTargetsForCheck(outcome, check.key), semanticFactClosure?.expectations_by_check.get(check.key) ?? [], scopeDeliveryBindings(outcome.key, outcome.technical.bindings), outcome.product.owner.path_globs, sourceBackedExecutionTargets.get(executionTarget.key) ?? null, observationAuthorityPaths), outcome.key, check.key);
|
|
81
91
|
if (frozen)
|
|
82
92
|
checks.push(frozen);
|
|
83
93
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EvidenceCapabilityRecordV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { JsonPointerExactLocator } from "./long-task-json-pointer-observation.js";
|
|
3
|
+
export type AdmittedObservationCandidate = {
|
|
4
|
+
assertion_key: string;
|
|
5
|
+
identity_ref: string;
|
|
6
|
+
method: string;
|
|
7
|
+
actual_observation: {
|
|
8
|
+
artifact_path: string;
|
|
9
|
+
locator: JsonPointerExactLocator;
|
|
10
|
+
sensitivity: string;
|
|
11
|
+
};
|
|
12
|
+
comparison: {
|
|
13
|
+
comparator: string;
|
|
14
|
+
mode: string;
|
|
15
|
+
tolerance: unknown;
|
|
16
|
+
mask: unknown;
|
|
17
|
+
};
|
|
18
|
+
oracle: {
|
|
19
|
+
trust: string;
|
|
20
|
+
identity: string;
|
|
21
|
+
version: string;
|
|
22
|
+
sha256: string | null;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare function admittedObservationCandidates(records: EvidenceCapabilityRecordV2[]): AdmittedObservationCandidate[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function admittedObservationCandidates(records) {
|
|
2
|
+
const candidates = [];
|
|
3
|
+
for (const record of records) {
|
|
4
|
+
if (record.capability === "semantic_fact") {
|
|
5
|
+
candidates.push({
|
|
6
|
+
assertion_key: record.assertion_key,
|
|
7
|
+
identity_ref: record.fact_ref,
|
|
8
|
+
method: record.method,
|
|
9
|
+
actual_observation: record.actual_observation,
|
|
10
|
+
comparison: record.comparison,
|
|
11
|
+
oracle: record.oracle,
|
|
12
|
+
});
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (record.capability !== "design_method")
|
|
16
|
+
continue;
|
|
17
|
+
if ("fact_model" in record)
|
|
18
|
+
for (const result of record.rule_results)
|
|
19
|
+
candidates.push({
|
|
20
|
+
assertion_key: record.assertion_key,
|
|
21
|
+
identity_ref: result.obligation_ref,
|
|
22
|
+
method: record.method,
|
|
23
|
+
actual_observation: result.actual_observation,
|
|
24
|
+
comparison: result.comparison,
|
|
25
|
+
oracle: result.oracle,
|
|
26
|
+
});
|
|
27
|
+
else
|
|
28
|
+
for (const cell of record.cells)
|
|
29
|
+
for (const result of cell.fact_results)
|
|
30
|
+
candidates.push({
|
|
31
|
+
assertion_key: record.assertion_key,
|
|
32
|
+
identity_ref: result.fact_ref,
|
|
33
|
+
method: record.method,
|
|
34
|
+
actual_observation: result.actual_observation,
|
|
35
|
+
comparison: result.comparison,
|
|
36
|
+
oracle: result.oracle,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return candidates;
|
|
40
|
+
}
|