project-tiny-context-harness 0.8.16 → 0.8.17
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 +31 -16
- package/assets/README.md +31 -16
- package/assets/README.zh-CN.md +29 -14
- package/assets/context_templates/screen-contract.md +16 -0
- package/assets/skills/context_development_engineer/SKILL.md +16 -30
- package/assets/skills/context_development_engineer/references/engineering-design-reasoning.md +93 -0
- package/assets/skills/context_surface_contract/SKILL.md +13 -2
- package/assets/skills/context_uiux_design/SKILL.md +7 -3
- package/assets/skills/context_uiux_design/references/task-uiux-analysis.md +82 -0
- package/assets/skills/design-resource-authoring/SKILL.md +14 -8
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +18 -6
- package/assets/skills/design-resource-authoring/references/formal-selected-web-app-handoff.md +26 -8
- package/assets/skills/design-resource-authoring/references/implementation-feasibility.md +111 -0
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +45 -7
- package/assets/skills/design-resource-authoring/references/recovery-and-writeback.md +7 -1
- package/assets/skills/design-resource-authoring/references/resource-selection.md +115 -3
- package/dist/commands/design-resource.js +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/lib/design-resource-handoff-bundle.js +5 -0
- package/dist/lib/design-resource-handoff-input-types.d.ts +1 -1
- package/dist/lib/design-resource-handoff-manifest-projection.js +1 -0
- package/dist/lib/design-resource-handoff-set-integrity.js +1 -0
- package/dist/lib/design-resource-handoff-shape.js +6 -2
- package/dist/lib/design-resource-handoff-types.d.ts +5 -0
- package/dist/lib/design-resource-handoff-validation.js +12 -0
- package/dist/lib/design-resource-implementation-feasibility-model.d.ts +35 -0
- package/dist/lib/design-resource-implementation-feasibility-model.js +62 -0
- package/dist/lib/design-resource-implementation-feasibility-shape-sections.d.ts +43 -0
- package/dist/lib/design-resource-implementation-feasibility-shape-sections.js +142 -0
- package/dist/lib/design-resource-implementation-feasibility-shape.d.ts +4 -0
- package/dist/lib/design-resource-implementation-feasibility-shape.js +154 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision-projection.d.ts +24 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision-projection.js +106 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision.d.ts +21 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision.js +75 -0
- package/dist/lib/design-resource-implementation-feasibility-types.d.ts +135 -0
- package/dist/lib/design-resource-implementation-feasibility-types.js +37 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-cells.d.ts +5 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-cells.js +125 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-document.d.ts +4 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-document.js +167 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-facts.d.ts +3 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-facts.js +76 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-realizations.d.ts +8 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-realizations.js +76 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-support.d.ts +10 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-support.js +75 -0
- package/dist/lib/design-resource-implementation-feasibility-validation.d.ts +3 -0
- package/dist/lib/design-resource-implementation-feasibility-validation.js +138 -0
- package/dist/lib/design-resource-symbolic-fact-shape.js +3 -1
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +5 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +13 -0
- package/dist/lib/long-task-activation-validation.js +77 -7
- package/dist/lib/long-task-check-runner.js +3 -296
- package/dist/lib/long-task-command-process.d.ts +9 -0
- package/dist/lib/long-task-command-process.js +175 -0
- package/dist/lib/long-task-delivery-validation.d.ts +5 -2
- package/dist/lib/long-task-delivery-validation.js +4 -4
- package/dist/lib/long-task-design-feasibility-binding-owners.d.ts +6 -0
- package/dist/lib/long-task-design-feasibility-binding-owners.js +52 -0
- package/dist/lib/long-task-design-feasibility-binding.d.ts +13 -0
- package/dist/lib/long-task-design-feasibility-binding.js +114 -0
- package/dist/lib/long-task-design-feasibility-source-closure.d.ts +11 -0
- package/dist/lib/long-task-design-feasibility-source-closure.js +78 -0
- package/dist/lib/long-task-design-resource-handoff.d.ts +3 -3
- package/dist/lib/long-task-design-resource-handoff.js +39 -3
- package/dist/lib/long-task-design-resource-method-binding.js +8 -2
- package/dist/lib/long-task-freshness.js +1 -1
- package/dist/lib/long-task-process-table.d.ts +12 -0
- package/dist/lib/long-task-process-table.js +119 -0
- package/dist/lib/long-task-process-tree.d.ts +9 -0
- package/dist/lib/long-task-process-tree.js +138 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -1
- package/dist/lib/long-task-protected-files.js +1 -1
- package/dist/lib/long-task-ui-surface-policy.d.ts +2 -1
- package/dist/lib/long-task-ui-surface-policy.js +7 -4
- package/dist/lib/long-task-ui-surface-validation.d.ts +3 -1
- package/dist/lib/long-task-ui-surface-validation.js +2 -2
- package/dist/lib/repository-path-safety.d.ts +2 -0
- package/dist/lib/repository-path-safety.js +36 -0
- package/dist/public-types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { DESIGN_RESOURCE_CUSTOMIZATION_SURFACES, DESIGN_RESOURCE_IMPLEMENTATION_STRATEGY_STEPS, DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, } from "./design-resource-implementation-feasibility-types.js";
|
|
2
|
+
import { parseSymbolicPredicate } from "./design-resource-symbolic-predicate-shape.js";
|
|
3
|
+
import { contractKey, stableKey, stableKeys, } from "./design-resource-handoff-shape-primitives.js";
|
|
4
|
+
import { array, literal, nullable, object, repositoryFile, string, strings, } from "./long-task-shape-primitives.js";
|
|
5
|
+
export function parseConditionModel(value, label) {
|
|
6
|
+
const itemLabel = `${label}.condition_model`;
|
|
7
|
+
const kind = object(value, itemLabel, ["kind", "profiles"]).kind;
|
|
8
|
+
if (kind === "explicit_conditions_v1") {
|
|
9
|
+
const row = object(value, itemLabel, ["kind", "profiles"]);
|
|
10
|
+
return {
|
|
11
|
+
kind: literal(row.kind, ["explicit_conditions_v1"], `${itemLabel}.kind`),
|
|
12
|
+
profiles: array(row.profiles, `${itemLabel}.profiles`).map((profile, index) => {
|
|
13
|
+
const profileLabel = `${itemLabel}.profiles[${index}]`;
|
|
14
|
+
const profileRow = object(profile, profileLabel, [
|
|
15
|
+
"key",
|
|
16
|
+
"condition_refs",
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
key: stableKey(profileRow.key, `${profileLabel}.key`),
|
|
20
|
+
condition_refs: stableKeys(profileRow.condition_refs, `${profileLabel}.condition_refs`),
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const row = object(value, itemLabel, ["kind", "profiles"]);
|
|
26
|
+
return {
|
|
27
|
+
kind: literal(row.kind, ["symbolic_regions_v2"], `${itemLabel}.kind`),
|
|
28
|
+
profiles: array(row.profiles, `${itemLabel}.profiles`).map((profile, index) => {
|
|
29
|
+
const profileLabel = `${itemLabel}.profiles[${index}]`;
|
|
30
|
+
const profileRow = object(profile, profileLabel, ["key", "region"]);
|
|
31
|
+
return {
|
|
32
|
+
key: stableKey(profileRow.key, `${profileLabel}.key`),
|
|
33
|
+
region: parseSymbolicPredicate(profileRow.region, `${profileLabel}.region`),
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function parseComponentFamilyCells(value, label) {
|
|
39
|
+
return array(value, `${label}.component_family_cells`).map((item, index) => {
|
|
40
|
+
const itemLabel = `${label}.component_family_cells[${index}]`;
|
|
41
|
+
const row = object(item, itemLabel, [
|
|
42
|
+
"key",
|
|
43
|
+
"component_family_ref",
|
|
44
|
+
"target_ref",
|
|
45
|
+
"condition_profile_ref",
|
|
46
|
+
"design_fact_refs",
|
|
47
|
+
"feasible_realizations",
|
|
48
|
+
"required_realization",
|
|
49
|
+
"blocker_refs",
|
|
50
|
+
]);
|
|
51
|
+
const required = object(row.required_realization, `${itemLabel}.required_realization`, ["realization_ref", "technical_authority_source_refs"]);
|
|
52
|
+
return {
|
|
53
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
54
|
+
component_family_ref: stableKey(row.component_family_ref, `${itemLabel}.component_family_ref`),
|
|
55
|
+
target_ref: contractKey(row.target_ref, `${itemLabel}.target_ref`),
|
|
56
|
+
condition_profile_ref: stableKey(row.condition_profile_ref, `${itemLabel}.condition_profile_ref`),
|
|
57
|
+
design_fact_refs: stableKeys(row.design_fact_refs, `${itemLabel}.design_fact_refs`),
|
|
58
|
+
feasible_realizations: parseRealizations(row.feasible_realizations, itemLabel),
|
|
59
|
+
required_realization: {
|
|
60
|
+
realization_ref: nullable(required.realization_ref, (entry) => stableKey(entry, `${itemLabel}.required_realization.realization_ref`)),
|
|
61
|
+
technical_authority_source_refs: stableKeys(required.technical_authority_source_refs, `${itemLabel}.required_realization.technical_authority_source_refs`),
|
|
62
|
+
},
|
|
63
|
+
blocker_refs: stableKeys(row.blocker_refs, `${itemLabel}.blocker_refs`),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function parseRealizations(value, label) {
|
|
68
|
+
return array(value, `${label}.feasible_realizations`).map((item, index) => {
|
|
69
|
+
const itemLabel = `${label}.feasible_realizations[${index}]`;
|
|
70
|
+
const row = object(item, itemLabel, [
|
|
71
|
+
"key",
|
|
72
|
+
"strategy_steps",
|
|
73
|
+
"primitive_refs",
|
|
74
|
+
"owner_candidates",
|
|
75
|
+
"supported_customization_surfaces",
|
|
76
|
+
"feasibility_basis_refs",
|
|
77
|
+
"observed_costs",
|
|
78
|
+
"observed_risks",
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
82
|
+
strategy_steps: array(row.strategy_steps, `${itemLabel}.strategy_steps`).map((step, stepIndex) => literal(step, DESIGN_RESOURCE_IMPLEMENTATION_STRATEGY_STEPS, `${itemLabel}.strategy_steps[${stepIndex}]`)),
|
|
83
|
+
primitive_refs: stableKeys(row.primitive_refs, `${itemLabel}.primitive_refs`),
|
|
84
|
+
owner_candidates: parseOwnerCandidates(row.owner_candidates, itemLabel),
|
|
85
|
+
supported_customization_surfaces: array(row.supported_customization_surfaces, `${itemLabel}.supported_customization_surfaces`).map((surface, surfaceIndex) => literal(surface, DESIGN_RESOURCE_CUSTOMIZATION_SURFACES, `${itemLabel}.supported_customization_surfaces[${surfaceIndex}]`)),
|
|
86
|
+
feasibility_basis_refs: stableKeys(row.feasibility_basis_refs, `${itemLabel}.feasibility_basis_refs`),
|
|
87
|
+
observed_costs: strings(row.observed_costs, `${itemLabel}.observed_costs`),
|
|
88
|
+
observed_risks: strings(row.observed_risks, `${itemLabel}.observed_risks`),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function parseOwnerCandidates(value, label) {
|
|
93
|
+
return array(value, `${label}.owner_candidates`).map((item, index) => {
|
|
94
|
+
const itemLabel = `${label}.owner_candidates[${index}]`;
|
|
95
|
+
const kind = object(item, itemLabel, ["kind", "locator", "existence"], ["authorization_source_refs"]).kind;
|
|
96
|
+
if (kind === "existing_path") {
|
|
97
|
+
const row = object(item, itemLabel, ["kind", "locator", "existence"]);
|
|
98
|
+
return {
|
|
99
|
+
kind: literal(row.kind, ["existing_path"], `${itemLabel}.kind`),
|
|
100
|
+
locator: repositoryFile(row.locator, `${itemLabel}.locator`),
|
|
101
|
+
existence: literal(row.existence, ["existing"], `${itemLabel}.existence`),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const row = object(item, itemLabel, [
|
|
105
|
+
"kind",
|
|
106
|
+
"locator",
|
|
107
|
+
"existence",
|
|
108
|
+
"authorization_source_refs",
|
|
109
|
+
]);
|
|
110
|
+
return {
|
|
111
|
+
kind: literal(row.kind, ["planned_logical_owner"], `${itemLabel}.kind`),
|
|
112
|
+
locator: stableKey(row.locator, `${itemLabel}.locator`),
|
|
113
|
+
existence: literal(row.existence, ["planned"], `${itemLabel}.existence`),
|
|
114
|
+
authorization_source_refs: stableKeys(row.authorization_source_refs, `${itemLabel}.authorization_source_refs`),
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
export function parseBlockers(value, label) {
|
|
119
|
+
return array(value, `${label}.blockers`).map((item, index) => {
|
|
120
|
+
const itemLabel = `${label}.blockers[${index}]`;
|
|
121
|
+
const row = object(item, itemLabel, [
|
|
122
|
+
"key",
|
|
123
|
+
"component_family_ref",
|
|
124
|
+
"target_ref",
|
|
125
|
+
"condition_profile_ref",
|
|
126
|
+
"source_record_refs",
|
|
127
|
+
"substrate_observation_refs",
|
|
128
|
+
"description",
|
|
129
|
+
]);
|
|
130
|
+
return {
|
|
131
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
132
|
+
component_family_ref: stableKey(row.component_family_ref, `${itemLabel}.component_family_ref`),
|
|
133
|
+
target_ref: contractKey(row.target_ref, `${itemLabel}.target_ref`),
|
|
134
|
+
condition_profile_ref: stableKey(row.condition_profile_ref, `${itemLabel}.condition_profile_ref`),
|
|
135
|
+
source_record_refs: stableKeys(row.source_record_refs, `${itemLabel}.source_record_refs`),
|
|
136
|
+
substrate_observation_refs: array(row.substrate_observation_refs, `${itemLabel}.substrate_observation_refs`)
|
|
137
|
+
.map((observationRef, observationIndex) => literal(observationRef, DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, `${itemLabel}.substrate_observation_refs[${observationIndex}]`))
|
|
138
|
+
.sort(),
|
|
139
|
+
description: string(row.description, `${itemLabel}.description`),
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DesignResourceImplementationFeasibilityV1, type DesignResourceTechnicalFeasibilityInputV1 } from "./design-resource-implementation-feasibility-types.js";
|
|
2
|
+
export declare function parseDesignResourceTechnicalFeasibilityInputs(value: unknown, label?: string): DesignResourceTechnicalFeasibilityInputV1[];
|
|
3
|
+
export declare function parseDesignResourceImplementationFeasibilityJson(content: string): DesignResourceImplementationFeasibilityV1;
|
|
4
|
+
export declare function parseDesignResourceImplementationFeasibilityShape(value: unknown): DesignResourceImplementationFeasibilityV1;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, DESIGN_RESOURCE_TECHNICAL_SOURCE_ROLES, } from "./design-resource-implementation-feasibility-types.js";
|
|
2
|
+
import { parseBlockers, parseComponentFamilyCells, parseConditionModel, } from "./design-resource-implementation-feasibility-shape-sections.js";
|
|
3
|
+
import { invalidFeasibility } from "./design-resource-implementation-feasibility-validation-support.js";
|
|
4
|
+
import { contractKey, sha256, stableKey, stableKeys, } from "./design-resource-handoff-shape-primitives.js";
|
|
5
|
+
import { array, literal, nullable, object, repositoryFile, string, } from "./long-task-shape-primitives.js";
|
|
6
|
+
import { parseStrictYaml } from "./strict-codec.js";
|
|
7
|
+
export function parseDesignResourceTechnicalFeasibilityInputs(value, label = "design_resource_handoff.technical_feasibility_inputs") {
|
|
8
|
+
return array(value, label).map((item, index) => {
|
|
9
|
+
const itemLabel = `${label}[${index}]`;
|
|
10
|
+
const row = object(item, itemLabel, [
|
|
11
|
+
"key",
|
|
12
|
+
"target_ref",
|
|
13
|
+
"path",
|
|
14
|
+
"media_type",
|
|
15
|
+
"sha256",
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
19
|
+
target_ref: contractKey(row.target_ref, `${itemLabel}.target_ref`),
|
|
20
|
+
path: repositoryFile(row.path, `${itemLabel}.path`),
|
|
21
|
+
media_type: literal(row.media_type, ["application/json"], `${itemLabel}.media_type`),
|
|
22
|
+
sha256: sha256(row.sha256, `${itemLabel}.sha256`),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function parseDesignResourceImplementationFeasibilityJson(content) {
|
|
27
|
+
try {
|
|
28
|
+
JSON.parse(content);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
invalidFeasibility("json", error instanceof Error ? error.message : String(error));
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return parseDesignResourceImplementationFeasibilityShape(parseStrictYaml(content));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof Error &&
|
|
38
|
+
error.message.startsWith("design_resource_implementation_feasibility_invalid:"))
|
|
39
|
+
throw error;
|
|
40
|
+
invalidFeasibility("shape", error instanceof Error ? error.message : String(error));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function parseDesignResourceImplementationFeasibilityShape(value) {
|
|
44
|
+
const label = "implementation_feasibility";
|
|
45
|
+
const root = object(value, label, [
|
|
46
|
+
"schema_version",
|
|
47
|
+
"key",
|
|
48
|
+
"target_ref",
|
|
49
|
+
"realization_mode",
|
|
50
|
+
"source_records",
|
|
51
|
+
"substrate_observations",
|
|
52
|
+
"condition_model",
|
|
53
|
+
"component_family_cells",
|
|
54
|
+
"blockers",
|
|
55
|
+
]);
|
|
56
|
+
return {
|
|
57
|
+
schema_version: literal(root.schema_version, ["design-resource-implementation-feasibility-v1"], `${label}.schema_version`),
|
|
58
|
+
key: stableKey(root.key, `${label}.key`),
|
|
59
|
+
target_ref: contractKey(root.target_ref, `${label}.target_ref`),
|
|
60
|
+
realization_mode: literal(root.realization_mode, ["native_substrate", "mapped_substrate", "reference"], `${label}.realization_mode`),
|
|
61
|
+
source_records: parseSourceRecords(root.source_records, label),
|
|
62
|
+
substrate_observations: parseSubstrateObservations(root.substrate_observations, label),
|
|
63
|
+
condition_model: parseConditionModel(root.condition_model, label),
|
|
64
|
+
component_family_cells: parseComponentFamilyCells(root.component_family_cells, label),
|
|
65
|
+
blockers: parseBlockers(root.blockers, label),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function parseSourceRecords(value, label) {
|
|
69
|
+
return array(value, `${label}.source_records`).map((item, index) => {
|
|
70
|
+
const itemLabel = `${label}.source_records[${index}]`;
|
|
71
|
+
const row = object(item, itemLabel, [
|
|
72
|
+
"key",
|
|
73
|
+
"path",
|
|
74
|
+
"media_type",
|
|
75
|
+
"sha256",
|
|
76
|
+
"locator",
|
|
77
|
+
"roles",
|
|
78
|
+
]);
|
|
79
|
+
const locator = object(row.locator, `${itemLabel}.locator`, ["kind", "value"], ["text_sha256"]);
|
|
80
|
+
const kind = literal(locator.kind, [
|
|
81
|
+
"whole_resource",
|
|
82
|
+
"json_pointer",
|
|
83
|
+
"markdown_anchor",
|
|
84
|
+
"source_anchor",
|
|
85
|
+
"source_item",
|
|
86
|
+
], `${itemLabel}.locator.kind`);
|
|
87
|
+
const locatorValue = string(locator.value, `${itemLabel}.locator.value`);
|
|
88
|
+
if (kind === "whole_resource" && locatorValue !== ".")
|
|
89
|
+
invalidFeasibility(`${itemLabel}.locator.value`, "whole_resource_must_be_dot");
|
|
90
|
+
if (kind === "json_pointer" && !locatorValue.startsWith("/"))
|
|
91
|
+
invalidFeasibility(`${itemLabel}.locator.value`, "json_pointer_must_start_with_slash");
|
|
92
|
+
const parsedLocator = kind === "whole_resource"
|
|
93
|
+
? { kind, value: "." }
|
|
94
|
+
: kind === "json_pointer"
|
|
95
|
+
? { kind, value: locatorValue }
|
|
96
|
+
: kind === "source_item"
|
|
97
|
+
? {
|
|
98
|
+
kind,
|
|
99
|
+
value: stableKey(locatorValue, `${itemLabel}.locator.value`),
|
|
100
|
+
text_sha256: sha256(locator.text_sha256, `${itemLabel}.locator.text_sha256`),
|
|
101
|
+
}
|
|
102
|
+
: { kind, value: locatorValue };
|
|
103
|
+
if (kind !== "source_item" && locator.text_sha256 !== undefined)
|
|
104
|
+
invalidFeasibility(`${itemLabel}.locator.text_sha256`, "only_source_item_may_declare_text_sha256");
|
|
105
|
+
return {
|
|
106
|
+
key: stableKey(row.key, `${itemLabel}.key`),
|
|
107
|
+
path: repositoryFile(row.path, `${itemLabel}.path`),
|
|
108
|
+
media_type: string(row.media_type, `${itemLabel}.media_type`),
|
|
109
|
+
sha256: sha256(row.sha256, `${itemLabel}.sha256`),
|
|
110
|
+
locator: parsedLocator,
|
|
111
|
+
roles: array(row.roles, `${itemLabel}.roles`).map((role, roleIndex) => literal(role, DESIGN_RESOURCE_TECHNICAL_SOURCE_ROLES, `${itemLabel}.roles[${roleIndex}]`)),
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function parseSubstrateObservations(value, label) {
|
|
116
|
+
return array(value, `${label}.substrate_observations`).map((item, index) => {
|
|
117
|
+
const itemLabel = `${label}.substrate_observations[${index}]`;
|
|
118
|
+
const row = object(item, itemLabel, [
|
|
119
|
+
"kind",
|
|
120
|
+
"disposition",
|
|
121
|
+
"value",
|
|
122
|
+
"source_record_refs",
|
|
123
|
+
"reason",
|
|
124
|
+
]);
|
|
125
|
+
return {
|
|
126
|
+
kind: literal(row.kind, DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, `${itemLabel}.kind`),
|
|
127
|
+
disposition: literal(row.disposition, [
|
|
128
|
+
"observed",
|
|
129
|
+
"not_applicable",
|
|
130
|
+
"decision_required",
|
|
131
|
+
"unavailable",
|
|
132
|
+
], `${itemLabel}.disposition`),
|
|
133
|
+
value: nullable(row.value, (entry) => parseObservationValue(entry, `${itemLabel}.value`)),
|
|
134
|
+
source_record_refs: stableKeys(row.source_record_refs, `${itemLabel}.source_record_refs`),
|
|
135
|
+
reason: nullable(row.reason, (entry) => string(entry, `${itemLabel}.reason`)),
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function parseObservationValue(value, label) {
|
|
140
|
+
const kind = object(value, label, ["kind"], ["name", "version_source_ref", "paths"]).kind;
|
|
141
|
+
if (kind === "identifier") {
|
|
142
|
+
const row = object(value, label, ["kind", "name", "version_source_ref"]);
|
|
143
|
+
return {
|
|
144
|
+
kind: literal(row.kind, ["identifier"], `${label}.kind`),
|
|
145
|
+
name: stableKey(row.name, `${label}.name`),
|
|
146
|
+
version_source_ref: nullable(row.version_source_ref, (entry) => stableKey(entry, `${label}.version_source_ref`)),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const row = object(value, label, ["kind", "paths"]);
|
|
150
|
+
return {
|
|
151
|
+
kind: literal(row.kind, ["repository_paths"], `${label}.kind`),
|
|
152
|
+
paths: array(row.paths, `${label}.paths`).map((item, index) => repositoryFile(item, `${label}.paths[${index}]`)),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type DesignResourceSubstrateObservationKind } from "./design-resource-implementation-feasibility-types.js";
|
|
2
|
+
export declare const DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA: "design-resource-feasibility-decision-v1";
|
|
3
|
+
export type DesignResourceFeasibilityDecisionProjection = DesignResourceRequiredRealizationProjection | DesignResourcePlannedOwnerProjection | DesignResourceFeasibilityBlockerProjection;
|
|
4
|
+
interface DesignResourceFeasibilityDecisionProjectionBase {
|
|
5
|
+
schema_version: typeof DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA;
|
|
6
|
+
target_ref: string;
|
|
7
|
+
component_family_ref: string;
|
|
8
|
+
condition_scope_sha256: string;
|
|
9
|
+
}
|
|
10
|
+
export interface DesignResourceRequiredRealizationProjection extends DesignResourceFeasibilityDecisionProjectionBase {
|
|
11
|
+
mode: "required_realization";
|
|
12
|
+
realization_ref: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DesignResourcePlannedOwnerProjection extends DesignResourceFeasibilityDecisionProjectionBase {
|
|
15
|
+
mode: "planned_owner_authorization";
|
|
16
|
+
owner_locator: string;
|
|
17
|
+
}
|
|
18
|
+
export interface DesignResourceFeasibilityBlockerProjection extends DesignResourceFeasibilityDecisionProjectionBase {
|
|
19
|
+
mode: "feasibility_blocker";
|
|
20
|
+
blocker_ref: string;
|
|
21
|
+
substrate_observation_refs: DesignResourceSubstrateObservationKind[];
|
|
22
|
+
}
|
|
23
|
+
export declare function parseDesignResourceFeasibilityDecisionProjections(sourcePath: string, sourceItemKey: string, normalizedText: string): DesignResourceFeasibilityDecisionProjection[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { digest, literal, object, oneOf, parseStrictJsonObject, stringSet, } from "./design-resource-recovery-codec-primitives.js";
|
|
2
|
+
import { contractKey, stableKey, } from "./design-resource-handoff-shape-primitives.js";
|
|
3
|
+
import { invalidFeasibility } from "./design-resource-implementation-feasibility-validation-support.js";
|
|
4
|
+
import { DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, } from "./design-resource-implementation-feasibility-types.js";
|
|
5
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
6
|
+
export const DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA = "design-resource-feasibility-decision-v1";
|
|
7
|
+
const DECISION_MARKER = "ty-design-feasibility-decision-v1";
|
|
8
|
+
export function parseDesignResourceFeasibilityDecisionProjections(sourcePath, sourceItemKey, normalizedText) {
|
|
9
|
+
const projections = [];
|
|
10
|
+
for (const [index, line] of normalizedText.split("\n").entries()) {
|
|
11
|
+
if (!line.includes(DECISION_MARKER))
|
|
12
|
+
continue;
|
|
13
|
+
const match = /^<!-- ty-design-feasibility-decision-v1 (\{.*\}) -->$/u.exec(line);
|
|
14
|
+
if (!match)
|
|
15
|
+
invalidFeasibility("source_decision_marker_invalid", `${sourcePath}:${sourceItemKey}:${index + 1}`);
|
|
16
|
+
try {
|
|
17
|
+
projections.push(parseDecisionProjection(match[1], `${sourcePath}:${sourceItemKey}:${index + 1}`));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error &&
|
|
21
|
+
error.message.startsWith("design_resource_implementation_feasibility_invalid:"))
|
|
22
|
+
throw error;
|
|
23
|
+
invalidFeasibility("source_decision_projection_invalid", `${sourcePath}:${sourceItemKey}:${index + 1}:${message(error)}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const identities = projections.map((projection) => canonicalValueJson(projection));
|
|
27
|
+
if (new Set(identities).size !== identities.length)
|
|
28
|
+
invalidFeasibility("source_decision_projection_duplicate", `${sourcePath}:${sourceItemKey}`);
|
|
29
|
+
return projections;
|
|
30
|
+
}
|
|
31
|
+
function parseDecisionProjection(content, label) {
|
|
32
|
+
const parsed = parseStrictJsonObject(content, `feasibility_decision_projection:${label}`);
|
|
33
|
+
const header = object(parsed, `feasibility_decision_projection:${label}`, [
|
|
34
|
+
"schema_version",
|
|
35
|
+
"mode",
|
|
36
|
+
"target_ref",
|
|
37
|
+
"component_family_ref",
|
|
38
|
+
"condition_scope_sha256",
|
|
39
|
+
], [
|
|
40
|
+
"realization_ref",
|
|
41
|
+
"owner_locator",
|
|
42
|
+
"blocker_ref",
|
|
43
|
+
"substrate_observation_refs",
|
|
44
|
+
]);
|
|
45
|
+
literal(header.schema_version, DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA, `${label}.schema_version`);
|
|
46
|
+
const mode = oneOf(header.mode, [
|
|
47
|
+
"required_realization",
|
|
48
|
+
"planned_owner_authorization",
|
|
49
|
+
"feasibility_blocker",
|
|
50
|
+
], `${label}.mode`);
|
|
51
|
+
const base = {
|
|
52
|
+
schema_version: DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA,
|
|
53
|
+
target_ref: contractKey(header.target_ref, `${label}.target_ref`),
|
|
54
|
+
component_family_ref: stableKey(header.component_family_ref, `${label}.component_family_ref`),
|
|
55
|
+
condition_scope_sha256: digest(header.condition_scope_sha256, `${label}.condition_scope_sha256`),
|
|
56
|
+
};
|
|
57
|
+
if (mode === "required_realization") {
|
|
58
|
+
const row = object(parsed, label, [
|
|
59
|
+
"schema_version",
|
|
60
|
+
"mode",
|
|
61
|
+
"target_ref",
|
|
62
|
+
"component_family_ref",
|
|
63
|
+
"condition_scope_sha256",
|
|
64
|
+
"realization_ref",
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
...base,
|
|
68
|
+
mode,
|
|
69
|
+
realization_ref: stableKey(row.realization_ref, `${label}.realization_ref`),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (mode === "planned_owner_authorization") {
|
|
73
|
+
const row = object(parsed, label, [
|
|
74
|
+
"schema_version",
|
|
75
|
+
"mode",
|
|
76
|
+
"target_ref",
|
|
77
|
+
"component_family_ref",
|
|
78
|
+
"condition_scope_sha256",
|
|
79
|
+
"owner_locator",
|
|
80
|
+
]);
|
|
81
|
+
return {
|
|
82
|
+
...base,
|
|
83
|
+
mode,
|
|
84
|
+
owner_locator: stableKey(row.owner_locator, `${label}.owner_locator`),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const row = object(parsed, label, [
|
|
88
|
+
"schema_version",
|
|
89
|
+
"mode",
|
|
90
|
+
"target_ref",
|
|
91
|
+
"component_family_ref",
|
|
92
|
+
"condition_scope_sha256",
|
|
93
|
+
"blocker_ref",
|
|
94
|
+
"substrate_observation_refs",
|
|
95
|
+
]);
|
|
96
|
+
const substrateObservationRefs = stringSet(row.substrate_observation_refs, `${label}.substrate_observation_refs`, { allowEmpty: true }).map((observationRef, observationIndex) => oneOf(observationRef, DESIGN_RESOURCE_SUBSTRATE_OBSERVATION_KINDS, `${label}.substrate_observation_refs[${observationIndex}]`));
|
|
97
|
+
return {
|
|
98
|
+
...base,
|
|
99
|
+
mode,
|
|
100
|
+
blocker_ref: stableKey(row.blocker_ref, `${label}.blocker_ref`),
|
|
101
|
+
substrate_observation_refs: substrateObservationRefs,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function message(error) {
|
|
105
|
+
return error instanceof Error ? error.message : String(error);
|
|
106
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SourceItemKind } from "./long-task-source-authority-types.js";
|
|
2
|
+
import type { DesignResourceImplementationFeasibilityV1, DesignResourceTechnicalSourceRecordV1 } from "./design-resource-implementation-feasibility-types.js";
|
|
3
|
+
import type { DesignResourceImplementationFeasibilityTargetModel } from "./design-resource-implementation-feasibility-model.js";
|
|
4
|
+
import { type DesignResourceFeasibilityDecisionProjection } from "./design-resource-implementation-feasibility-source-decision-projection.js";
|
|
5
|
+
export { DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA, parseDesignResourceFeasibilityDecisionProjections, } from "./design-resource-implementation-feasibility-source-decision-projection.js";
|
|
6
|
+
export type { DesignResourceFeasibilityBlockerProjection, DesignResourceFeasibilityDecisionProjection, DesignResourcePlannedOwnerProjection, DesignResourceRequiredRealizationProjection, } from "./design-resource-implementation-feasibility-source-decision-projection.js";
|
|
7
|
+
export interface LoadedDesignResourceFeasibilityDecisionSource {
|
|
8
|
+
source_record_ref: string;
|
|
9
|
+
source_path: string;
|
|
10
|
+
source_item_key: string;
|
|
11
|
+
source_item_kind: SourceItemKind;
|
|
12
|
+
text_sha256: string;
|
|
13
|
+
projections: DesignResourceFeasibilityDecisionProjection[];
|
|
14
|
+
}
|
|
15
|
+
export type DesignResourceFeasibilityDecisionSourceIndex = Map<string, LoadedDesignResourceFeasibilityDecisionSource>;
|
|
16
|
+
export declare function loadDesignResourceFeasibilityDecisionSource(record: DesignResourceTechnicalSourceRecordV1, content: string): LoadedDesignResourceFeasibilityDecisionSource | null;
|
|
17
|
+
export declare function deriveDesignResourceFeasibilityConditionScopeSha256(document: DesignResourceImplementationFeasibilityV1, model: DesignResourceImplementationFeasibilityTargetModel, profileRef: string): string;
|
|
18
|
+
export declare function requireExactFeasibilityDecisionProjection(sourceRefs: string[], sources: DesignResourceFeasibilityDecisionSourceIndex, expectation: DesignResourceFeasibilityDecisionProjection, label: string, options: {
|
|
19
|
+
allReferencesMustBeSourceItems: boolean;
|
|
20
|
+
allowedItemKinds: readonly SourceItemKind[];
|
|
21
|
+
}): LoadedDesignResourceFeasibilityDecisionSource;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { parseSourceDocument } from "./long-task-source-item-parser.js";
|
|
2
|
+
import { invalidFeasibility } from "./design-resource-implementation-feasibility-validation-support.js";
|
|
3
|
+
import { parseDesignResourceFeasibilityDecisionProjections, } from "./design-resource-implementation-feasibility-source-decision-projection.js";
|
|
4
|
+
import { createSymbolicDenotationCompilationSession } from "./symbolic-denotation-engine.js";
|
|
5
|
+
import { canonicalValueJson, sha256Hex } from "./strict-codec.js";
|
|
6
|
+
export { DESIGN_RESOURCE_FEASIBILITY_DECISION_SCHEMA, parseDesignResourceFeasibilityDecisionProjections, } from "./design-resource-implementation-feasibility-source-decision-projection.js";
|
|
7
|
+
export function loadDesignResourceFeasibilityDecisionSource(record, content) {
|
|
8
|
+
if (record.locator.kind !== "source_item")
|
|
9
|
+
return null;
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = parseSourceDocument(record.path, content);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
invalidFeasibility("source_item_document_invalid", `${record.key}:${message(error)}`);
|
|
16
|
+
}
|
|
17
|
+
const item = parsed.items.find((candidate) => candidate.key === record.locator.value);
|
|
18
|
+
if (!item)
|
|
19
|
+
invalidFeasibility("source_item_missing", `${record.key}:${record.locator.value}`);
|
|
20
|
+
if (item.text_sha256 !== record.locator.text_sha256)
|
|
21
|
+
invalidFeasibility("source_item_text_digest_mismatch", `${record.key}:${record.locator.text_sha256}:${item.text_sha256}`);
|
|
22
|
+
return {
|
|
23
|
+
source_record_ref: record.key,
|
|
24
|
+
source_path: record.path,
|
|
25
|
+
source_item_key: item.key,
|
|
26
|
+
source_item_kind: item.kind,
|
|
27
|
+
text_sha256: item.text_sha256,
|
|
28
|
+
projections: parseDesignResourceFeasibilityDecisionProjections(record.path, item.key, item.normalized_text),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function deriveDesignResourceFeasibilityConditionScopeSha256(document, model, profileRef) {
|
|
32
|
+
if (document.condition_model.kind === "explicit_conditions_v1" &&
|
|
33
|
+
model.representation === "fact_cells_v1") {
|
|
34
|
+
const profile = document.condition_model.profiles.find((candidate) => candidate.key === profileRef);
|
|
35
|
+
if (!profile)
|
|
36
|
+
invalidFeasibility("condition_profile_unknown", profileRef);
|
|
37
|
+
return sha256Hex(canonicalValueJson([...profile.condition_refs].sort(compareText)));
|
|
38
|
+
}
|
|
39
|
+
if (document.condition_model.kind === "symbolic_regions_v2" &&
|
|
40
|
+
model.representation === "symbolic_rules_v2") {
|
|
41
|
+
const profile = document.condition_model.profiles.find((candidate) => candidate.key === profileRef);
|
|
42
|
+
if (!profile)
|
|
43
|
+
invalidFeasibility("condition_profile_unknown", profileRef);
|
|
44
|
+
return createSymbolicDenotationCompilationSession(model.axis_domains, [
|
|
45
|
+
profile.region,
|
|
46
|
+
]).compile(profile.region).canonical_sha256;
|
|
47
|
+
}
|
|
48
|
+
invalidFeasibility("condition_model_representation_mismatch", profileRef);
|
|
49
|
+
}
|
|
50
|
+
export function requireExactFeasibilityDecisionProjection(sourceRefs, sources, expectation, label, options) {
|
|
51
|
+
if (options.allReferencesMustBeSourceItems)
|
|
52
|
+
for (const sourceRef of sourceRefs)
|
|
53
|
+
if (!sources.has(sourceRef))
|
|
54
|
+
invalidFeasibility("source_item_authority_required", `${label}:${sourceRef}`);
|
|
55
|
+
const matches = [];
|
|
56
|
+
for (const sourceRef of sourceRefs) {
|
|
57
|
+
const source = sources.get(sourceRef);
|
|
58
|
+
if (!source)
|
|
59
|
+
continue;
|
|
60
|
+
if (source.projections.some((projection) => canonicalValueJson(projection) === canonicalValueJson(expectation)))
|
|
61
|
+
matches.push(source);
|
|
62
|
+
}
|
|
63
|
+
if (matches.length !== 1)
|
|
64
|
+
invalidFeasibility("source_decision_projection_count", `${label}:${matches.length}`);
|
|
65
|
+
const match = matches[0];
|
|
66
|
+
if (!options.allowedItemKinds.includes(match.source_item_kind))
|
|
67
|
+
invalidFeasibility("source_decision_item_kind_invalid", `${label}:${match.source_item_kind}`);
|
|
68
|
+
return match;
|
|
69
|
+
}
|
|
70
|
+
function compareText(left, right) {
|
|
71
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
72
|
+
}
|
|
73
|
+
function message(error) {
|
|
74
|
+
return error instanceof Error ? error.message : String(error);
|
|
75
|
+
}
|