project-tiny-context-harness 0.8.11 → 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/LICENSE +21 -21
- package/README.md +514 -472
- package/assets/README.md +803 -749
- package/assets/README.zh-CN.md +468 -431
- package/assets/agents/.gitkeep +1 -1
- package/assets/agents/AGENTS_CORE.md +22 -24
- package/assets/agents/long-task-implementation.toml +15 -0
- package/assets/context_templates/architecture.md +18 -18
- package/assets/context_templates/area.md +30 -30
- package/assets/context_templates/context.toml +24 -24
- package/assets/context_templates/deployment.md +35 -35
- package/assets/context_templates/global.md +56 -56
- package/assets/context_templates/product-surface-contract.md +70 -70
- package/assets/context_templates/screen-contract.md +189 -189
- package/assets/context_templates/verification.md +25 -25
- package/assets/github/.gitkeep +1 -1
- package/assets/github/harness.yml +39 -39
- package/assets/make/.gitkeep +1 -1
- package/assets/make/ty-context.mk +48 -48
- package/assets/skills/context_development_engineer/SKILL.md +72 -185
- package/assets/skills/context_full_project_export/SKILL.md +28 -28
- package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
- package/assets/skills/context_product_plan/SKILL.md +35 -101
- package/assets/skills/context_surface_contract/SKILL.md +194 -191
- package/assets/skills/context_uiux_design/SKILL.md +49 -172
- package/assets/skills/design-resource-authoring/SKILL.md +54 -88
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +51 -163
- package/assets/skills/design-resource-authoring/references/formal-selected-web-app-handoff.md +96 -0
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +140 -120
- package/assets/skills/design-resource-authoring/references/recovery-and-writeback.md +199 -0
- package/assets/skills/design-resource-authoring/references/resource-selection.md +158 -181
- package/assets/skills/design-system-authoring/SKILL.md +57 -57
- package/assets/skills/design-system-authoring/agents/openai.yaml +6 -6
- package/assets/skills/design-system-authoring/references/authority-adoption.md +48 -48
- package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +110 -110
- package/assets/skills/long-task-workflow/SKILL.md +71 -106
- package/assets/skills/long-task-workflow/agents/openai.yaml +1 -1
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +71 -69
- package/assets/skills/long-task-workflow/references/contract-authoring.md +110 -101
- package/assets/skills/long-task-workflow/references/evidence-design.md +99 -78
- package/assets/skills/long-task-workflow/references/source-authoring.md +90 -90
- package/assets/tools/validate_context.py +442 -442
- 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 +29 -3
- package/dist/commands/enable.js +2 -0
- package/dist/commands/index.js +2 -2
- package/dist/commands/long-task-revision.js +8 -7
- package/dist/commands/sync.js +2 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -0
- package/dist/lib/compact-authoring-support.d.ts +22 -0
- package/dist/lib/compact-authoring-support.js +143 -0
- package/dist/lib/compact-shared-structure-authoring.d.ts +5 -0
- package/dist/lib/compact-shared-structure-authoring.js +9 -0
- package/dist/lib/compact-shared-structure-types.d.ts +61 -0
- package/dist/lib/compact-shared-structure-types.js +1 -0
- package/dist/lib/compact-shared-structure-validation.d.ts +2 -0
- package/dist/lib/compact-shared-structure-validation.js +159 -0
- package/dist/lib/compact-shared-structures.d.ts +3 -0
- package/dist/lib/compact-shared-structures.js +204 -0
- package/dist/lib/design-resource-fact-enums.d.ts +4 -0
- package/dist/lib/design-resource-fact-enums.js +12 -0
- package/dist/lib/design-resource-fact-manifest-shape-evidence.js +2 -2
- package/dist/lib/design-resource-fact-policy.d.ts +2 -2
- package/dist/lib/design-resource-fact-types.d.ts +2 -2
- package/dist/lib/design-resource-handoff-bundle-draft.js +4 -2
- package/dist/lib/design-resource-handoff-input-types.d.ts +3 -0
- package/dist/lib/design-resource-handoff-parser.d.ts +2 -2
- package/dist/lib/design-resource-handoff-parser.js +2 -2
- package/dist/lib/design-resource-handoff-shape.d.ts +2 -0
- package/dist/lib/design-resource-handoff-shape.js +10 -0
- package/dist/lib/design-resource-handoff-snapshot.js +4 -0
- package/dist/lib/design-resource-handoff-validation.d.ts +4 -1
- package/dist/lib/design-resource-handoff-validation.js +11 -0
- package/dist/lib/design-resource-handoff-web-dependency-validation.d.ts +4 -2
- 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/design-resource-symbolic-applicability-authority.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-applicability-authority.js +19 -0
- package/dist/lib/design-resource-symbolic-applicability-policy.d.ts +12 -0
- package/dist/lib/design-resource-symbolic-applicability-policy.js +79 -0
- package/dist/lib/design-resource-symbolic-applicability-profiles.d.ts +8 -0
- package/dist/lib/design-resource-symbolic-applicability-profiles.js +55 -0
- package/dist/lib/design-resource-symbolic-applicability-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-applicability-shape.js +76 -0
- package/dist/lib/design-resource-symbolic-applicability-validation.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-applicability-validation.js +128 -0
- package/dist/lib/design-resource-symbolic-compilation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-compilation.js +13 -0
- package/dist/lib/design-resource-symbolic-denotation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-denotation.js +167 -0
- package/dist/lib/design-resource-symbolic-disposition-validation.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-disposition-validation.js +28 -0
- package/dist/lib/design-resource-symbolic-fact-policy.d.ts +12 -0
- package/dist/lib/design-resource-symbolic-fact-policy.js +12 -0
- package/dist/lib/design-resource-symbolic-fact-shape.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-shape.js +138 -0
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +213 -0
- package/dist/lib/design-resource-symbolic-fact-types.js +1 -0
- package/dist/lib/design-resource-symbolic-fact-validation.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +86 -0
- package/dist/lib/design-resource-symbolic-indexes.d.ts +23 -0
- package/dist/lib/design-resource-symbolic-indexes.js +54 -0
- package/dist/lib/design-resource-symbolic-manifest-shape.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-manifest-shape.js +155 -0
- package/dist/lib/design-resource-symbolic-manifest-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-manifest-validation.js +132 -0
- package/dist/lib/design-resource-symbolic-noninterference-artifact.d.ts +33 -0
- package/dist/lib/design-resource-symbolic-noninterference-artifact.js +110 -0
- package/dist/lib/design-resource-symbolic-noninterference-equivalence.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-noninterference-equivalence.js +77 -0
- package/dist/lib/design-resource-symbolic-noninterference-recompute.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-noninterference-recompute.js +146 -0
- package/dist/lib/design-resource-symbolic-noninterference-scope.d.ts +7 -0
- package/dist/lib/design-resource-symbolic-noninterference-scope.js +49 -0
- package/dist/lib/design-resource-symbolic-noninterference-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-noninterference-shape.js +152 -0
- package/dist/lib/design-resource-symbolic-noninterference-types.d.ts +103 -0
- package/dist/lib/design-resource-symbolic-noninterference-types.js +1 -0
- package/dist/lib/design-resource-symbolic-noninterference-validation.d.ts +5 -0
- package/dist/lib/design-resource-symbolic-noninterference-validation.js +62 -0
- package/dist/lib/design-resource-symbolic-oracle-fingerprint.d.ts +1 -0
- package/dist/lib/design-resource-symbolic-oracle-fingerprint.js +47 -0
- package/dist/lib/design-resource-symbolic-predicate-shape.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-predicate-shape.js +123 -0
- package/dist/lib/design-resource-symbolic-production-closure.d.ts +4 -0
- package/dist/lib/design-resource-symbolic-production-closure.js +144 -0
- package/dist/lib/design-resource-symbolic-proof-authority-validation.d.ts +10 -0
- package/dist/lib/design-resource-symbolic-proof-authority-validation.js +68 -0
- package/dist/lib/design-resource-symbolic-proof-validation.d.ts +10 -0
- package/dist/lib/design-resource-symbolic-proof-validation.js +89 -0
- package/dist/lib/design-resource-symbolic-region-validation.d.ts +19 -0
- package/dist/lib/design-resource-symbolic-region-validation.js +146 -0
- package/dist/lib/design-resource-symbolic-resource-validation.d.ts +5 -0
- package/dist/lib/design-resource-symbolic-resource-validation.js +90 -0
- package/dist/lib/design-resource-symbolic-rule-shape.d.ts +27 -0
- package/dist/lib/design-resource-symbolic-rule-shape.js +158 -0
- package/dist/lib/design-resource-symbolic-safety-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-safety-validation.js +29 -0
- package/dist/lib/design-resource-symbolic-source-ir-evaluation.d.ts +19 -0
- package/dist/lib/design-resource-symbolic-source-ir-evaluation.js +74 -0
- package/dist/lib/design-resource-symbolic-source-ir-evidence.d.ts +44 -0
- package/dist/lib/design-resource-symbolic-source-ir-evidence.js +88 -0
- package/dist/lib/design-resource-symbolic-source-ir-oracle.d.ts +13 -0
- package/dist/lib/design-resource-symbolic-source-ir-oracle.js +96 -0
- package/dist/lib/design-resource-symbolic-source-ir-proof.d.ts +14 -0
- package/dist/lib/design-resource-symbolic-source-ir-proof.js +98 -0
- package/dist/lib/design-resource-symbolic-source-ir-shape.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-source-ir-shape.js +38 -0
- package/dist/lib/design-resource-symbolic-source-ir-types.d.ts +17 -0
- package/dist/lib/design-resource-symbolic-source-ir-types.js +2 -0
- package/dist/lib/design-resource-symbolic-static-dependency-validation.d.ts +2 -0
- package/dist/lib/design-resource-symbolic-static-dependency-validation.js +83 -0
- package/dist/lib/design-resource-symbolic-structural-closure-validation.d.ts +6 -0
- package/dist/lib/design-resource-symbolic-structural-closure-validation.js +79 -0
- package/dist/lib/design-resource-symbolic-validation-support.d.ts +29 -0
- package/dist/lib/design-resource-symbolic-validation-support.js +111 -0
- package/dist/lib/design-resource-v1-capacity-header.d.ts +8 -0
- package/dist/lib/design-resource-v1-capacity-header.js +231 -0
- package/dist/lib/design-resource-v1-capacity.d.ts +5 -0
- package/dist/lib/design-resource-v1-capacity.js +45 -0
- package/dist/lib/init.js +1 -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 +5 -0
- package/dist/lib/long-task-authority-policy.js +5 -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-codex-agent-profile.d.ts +42 -0
- package/dist/lib/long-task-codex-agent-profile.js +276 -0
- package/dist/lib/long-task-compact-authoring-projections.d.ts +12 -0
- package/dist/lib/long-task-compact-authoring-projections.js +67 -0
- package/dist/lib/long-task-compact-authoring.d.ts +3 -0
- package/dist/lib/long-task-compact-authoring.js +173 -0
- package/dist/lib/long-task-compact-carrier.d.ts +7 -0
- package/dist/lib/long-task-compact-carrier.js +132 -0
- package/dist/lib/long-task-compact-parser.d.ts +14 -0
- package/dist/lib/long-task-compact-parser.js +123 -0
- package/dist/lib/long-task-compact-primitives.d.ts +22 -0
- package/dist/lib/long-task-compact-primitives.js +132 -0
- package/dist/lib/long-task-compact-projections.d.ts +4 -0
- package/dist/lib/long-task-compact-projections.js +153 -0
- package/dist/lib/long-task-compact-structure-targets.d.ts +2 -0
- package/dist/lib/long-task-compact-structure-targets.js +91 -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.d.ts +1 -1
- package/dist/lib/long-task-counterfactual-sandbox.js +8 -5
- 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-delivery-parser.d.ts +1 -0
- package/dist/lib/long-task-delivery-parser.js +38 -6
- package/dist/lib/long-task-design-resource-handoff.d.ts +2 -1
- package/dist/lib/long-task-design-resource-handoff.js +71 -11
- package/dist/lib/long-task-design-resource-method-binding.d.ts +8 -1
- package/dist/lib/long-task-design-resource-method-binding.js +150 -0
- package/dist/lib/long-task-evidence-capability-codec.js +256 -34
- package/dist/lib/long-task-evidence-capability-policy.d.ts +3 -2
- package/dist/lib/long-task-evidence-capability-policy.js +142 -8
- package/dist/lib/long-task-evidence-capability-runtime.d.ts +5 -2
- package/dist/lib/long-task-evidence-capability-runtime.js +420 -68
- package/dist/lib/long-task-evidence-capability-types.d.ts +70 -2
- 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 +322 -44
- 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-hook-install.d.ts +19 -2
- package/dist/lib/long-task-hook-install.js +288 -91
- 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-playwright-capability-records.d.ts +2 -0
- package/dist/lib/long-task-playwright-capability-records.js +74 -2
- 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 +130 -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 +2 -1
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +8 -0
- package/dist/lib/long-task-semantic-fact-closure.js +4 -1
- package/dist/lib/long-task-semantic-fact-contract-closure.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-closure.js +18 -6
- package/dist/lib/long-task-semantic-fact-contract-facts.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-facts.js +4 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.d.ts +1 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +12 -3
- package/dist/lib/long-task-semantic-fact-evidence.d.ts +8 -4
- package/dist/lib/long-task-semantic-fact-evidence.js +103 -43
- package/dist/lib/long-task-semantic-fact-shape.js +17 -6
- package/dist/lib/long-task-shape-primitives.d.ts +1 -1
- package/dist/lib/long-task-shape-primitives.js +1 -0
- package/dist/lib/long-task-source-claim-validation.js +4 -1
- package/dist/lib/long-task-source-item-parser.d.ts +2 -2
- package/dist/lib/long-task-source-item-parser.js +20 -11
- 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-ui-design-policy.js +64 -4
- package/dist/lib/long-task-ui-surface-shape.js +195 -0
- package/dist/lib/long-task-ui-surface-types.d.ts +53 -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-worker-selection.d.ts +2 -0
- package/dist/lib/long-task-worker-selection.js +7 -0
- package/dist/lib/long-task-workspace-scope.js +3 -1
- package/dist/lib/long-task-workspace.d.ts +1 -1
- package/dist/lib/long-task-workspace.js +12 -13
- package/dist/lib/migrations.js +58 -0
- package/dist/lib/profiles.js +0 -1
- package/dist/lib/repository-path-safety.d.ts +14 -0
- package/dist/lib/repository-path-safety.js +126 -0
- package/dist/lib/semantic-fact-compact-authoring.d.ts +2 -0
- package/dist/lib/semantic-fact-compact-authoring.js +160 -0
- package/dist/lib/semantic-fact-compact-capacity.d.ts +9 -0
- package/dist/lib/semantic-fact-compact-capacity.js +40 -0
- package/dist/lib/semantic-fact-compact-carrier.d.ts +16 -0
- package/dist/lib/semantic-fact-compact-carrier.js +146 -0
- package/dist/lib/semantic-fact-compact-parser.d.ts +17 -0
- package/dist/lib/semantic-fact-compact-parser.js +168 -0
- package/dist/lib/semantic-fact-compact-revision.d.ts +11 -0
- package/dist/lib/semantic-fact-compact-revision.js +64 -0
- package/dist/lib/semantic-fact-compact-support.d.ts +23 -0
- package/dist/lib/semantic-fact-compact-support.js +159 -0
- package/dist/lib/semantic-fact-policy-census.d.ts +1 -0
- package/dist/lib/semantic-fact-policy-census.js +43 -0
- package/dist/lib/semantic-fact-proof-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-property-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-source-parser.d.ts +5 -0
- package/dist/lib/semantic-fact-source-parser.js +47 -6
- package/dist/lib/structural-closure-cost.d.ts +79 -0
- package/dist/lib/structural-closure-cost.js +91 -0
- package/dist/lib/symbolic-denotation-dag-builder.d.ts +25 -0
- package/dist/lib/symbolic-denotation-dag-builder.js +176 -0
- package/dist/lib/symbolic-denotation-domain-validation.d.ts +3 -0
- package/dist/lib/symbolic-denotation-domain-validation.js +56 -0
- package/dist/lib/symbolic-denotation-engine.d.ts +32 -0
- package/dist/lib/symbolic-denotation-engine.js +140 -0
- package/dist/lib/symbolic-denotation-public.d.ts +11 -0
- package/dist/lib/symbolic-denotation-public.js +12 -0
- package/dist/lib/symbolic-denotation-runtime.d.ts +20 -0
- package/dist/lib/symbolic-denotation-runtime.js +90 -0
- package/dist/lib/symbolic-denotation-support.d.ts +11 -0
- package/dist/lib/symbolic-denotation-support.js +49 -0
- package/dist/lib/symbolic-denotation-types.d.ts +133 -0
- package/dist/lib/symbolic-denotation-types.js +18 -0
- package/dist/lib/symbolic-denotation-validation.d.ts +6 -0
- package/dist/lib/symbolic-denotation-validation.js +126 -0
- package/dist/lib/sync-engine.d.ts +1 -0
- package/dist/lib/sync-engine.js +4 -1
- package/dist/lib/upgrade.js +1 -0
- package/dist/long-task-hook.js +40 -1
- package/dist/public-types.d.ts +8 -0
- package/dist/public-types.js +1 -0
- package/dist/schemas/design-resource-symbolic-noninterference-artifact-v2.schema.json +289 -0
- package/dist/schemas/design-resource-symbolic-source-ir-v1.schema.json +130 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +435 -5
- package/migrations/README.md +92 -15
- package/package.json +2 -2
- package/source-mappings.yaml +28 -25
- package/assets/skills/source-plan-authoring/SKILL.md +0 -14
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parse as parseToml } from "smol-toml";
|
|
5
|
+
import { packageAssetPath } from "./paths.js";
|
|
6
|
+
export const LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH = ".codex/agents/long-task-implementation.toml";
|
|
7
|
+
export const LONG_TASK_CODEX_AGENT_PROFILE_MANAGED_MARKER = "# ty-context:managed:long-task-implementation-worker";
|
|
8
|
+
const ASSET_SEGMENTS = ["agents", "long-task-implementation.toml"];
|
|
9
|
+
const PROFILE_ROOT_FIELDS = new Set([
|
|
10
|
+
"name",
|
|
11
|
+
"description",
|
|
12
|
+
"developer_instructions",
|
|
13
|
+
"model",
|
|
14
|
+
"model_reasoning_effort",
|
|
15
|
+
"agents",
|
|
16
|
+
]);
|
|
17
|
+
const PROFILE_AGENT_FIELDS = new Set(["enabled"]);
|
|
18
|
+
const DEFAULT_FILE_OPERATIONS = {
|
|
19
|
+
lstat: (target) => fs.lstat(target),
|
|
20
|
+
realpath: (target) => fs.realpath(target),
|
|
21
|
+
readFile: (target, encoding) => fs.readFile(target, encoding),
|
|
22
|
+
mkdir: (target, options) => fs.mkdir(target, options),
|
|
23
|
+
writeFile: (target, content, options) => fs.writeFile(target, content, options),
|
|
24
|
+
rename: (source, destination) => fs.rename(source, destination),
|
|
25
|
+
rm: (target, options) => fs.rm(target, options),
|
|
26
|
+
randomId: () => randomUUID(),
|
|
27
|
+
};
|
|
28
|
+
export function parseAndValidateLongTaskCodexAgentProfile(content) {
|
|
29
|
+
const errors = [];
|
|
30
|
+
const normalized = content.replace(/\r\n/gu, "\n");
|
|
31
|
+
if (!hasManagedMarker(normalized))
|
|
32
|
+
errors.push("managed_marker_missing_or_invalid");
|
|
33
|
+
let decoded;
|
|
34
|
+
try {
|
|
35
|
+
decoded = parseToml(normalized);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return { valid: false, errors: [...errors, "toml_invalid"] };
|
|
39
|
+
}
|
|
40
|
+
const root = record(decoded);
|
|
41
|
+
if (!root)
|
|
42
|
+
return { valid: false, errors: [...errors, "profile_not_table"] };
|
|
43
|
+
for (const key of Object.keys(root).sort())
|
|
44
|
+
if (!PROFILE_ROOT_FIELDS.has(key))
|
|
45
|
+
errors.push(`unsupported_field:${key}`);
|
|
46
|
+
if (root.name !== "long_task_implementation")
|
|
47
|
+
errors.push("name_must_be_long_task_implementation");
|
|
48
|
+
if (!nonEmptyString(root.description))
|
|
49
|
+
errors.push("description_required");
|
|
50
|
+
if (!nonEmptyString(root.developer_instructions))
|
|
51
|
+
errors.push("developer_instructions_required");
|
|
52
|
+
if (!staticString(root.model))
|
|
53
|
+
errors.push("model_must_be_static_nonempty");
|
|
54
|
+
if (!staticString(root.model_reasoning_effort))
|
|
55
|
+
errors.push("model_reasoning_effort_must_be_static_nonempty");
|
|
56
|
+
const agents = record(root.agents);
|
|
57
|
+
if (!agents)
|
|
58
|
+
errors.push("agents_table_required");
|
|
59
|
+
else {
|
|
60
|
+
for (const key of Object.keys(agents).sort())
|
|
61
|
+
if (!PROFILE_AGENT_FIELDS.has(key))
|
|
62
|
+
errors.push(`unsupported_agents_field:${key}`);
|
|
63
|
+
if (agents.enabled !== false)
|
|
64
|
+
errors.push("agents_enabled_must_be_false");
|
|
65
|
+
}
|
|
66
|
+
if (errors.length)
|
|
67
|
+
return { valid: false, errors };
|
|
68
|
+
return {
|
|
69
|
+
valid: true,
|
|
70
|
+
profile: {
|
|
71
|
+
name: "long_task_implementation",
|
|
72
|
+
description: root.description,
|
|
73
|
+
developer_instructions: root.developer_instructions,
|
|
74
|
+
model: root.model,
|
|
75
|
+
model_reasoning_effort: root.model_reasoning_effort,
|
|
76
|
+
agents: { enabled: false },
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export async function syncLongTaskCodexAgentProfile(projectRoot, resolvedHarnessRoot, enabled, report, fileOperations = {}) {
|
|
81
|
+
if (resolvedHarnessRoot !== ".codex")
|
|
82
|
+
return;
|
|
83
|
+
const operations = operationsWith(fileOperations);
|
|
84
|
+
const asset = await readValidPackageProfile(operations);
|
|
85
|
+
if (!asset.valid) {
|
|
86
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: optional package asset ${asset.reason}`);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const destination = path.join(projectRoot, LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH);
|
|
90
|
+
if (!enabled) {
|
|
91
|
+
await removeManagedProfile(projectRoot, destination, report, operations);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const inspected = await inspectProfileDestination(projectRoot, destination, operations);
|
|
95
|
+
if (inspected.kind === "conflict") {
|
|
96
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: optional adapter conflict (${inspected.reason})`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
let previous = null;
|
|
100
|
+
if (inspected.kind === "regular") {
|
|
101
|
+
previous = await operations.readFile(destination, "utf8");
|
|
102
|
+
if (!hasManagedMarker(previous)) {
|
|
103
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: user-owned (managed marker absent)`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (previous === asset.content) {
|
|
107
|
+
report.skipped.push(LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await atomicWriteLongTaskCodexAgentProfile(destination, asset.content, operations, async () => {
|
|
113
|
+
const current = await inspectProfileDestination(projectRoot, destination, operations);
|
|
114
|
+
if (previous === null && current.kind !== "absent")
|
|
115
|
+
throw new Error("destination_changed_before_rename");
|
|
116
|
+
if (previous !== null) {
|
|
117
|
+
if (current.kind !== "regular")
|
|
118
|
+
throw new Error("destination_changed_before_rename");
|
|
119
|
+
if ((await operations.readFile(destination, "utf8")) !== previous)
|
|
120
|
+
throw new Error("destination_content_changed_before_rename");
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
report.changed.push(LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: optional adapter write failed (${message(error)})`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export async function longTaskCodexAgentProfileBootstrapPaths(projectRoot, resolvedHarnessRoot, enabled, fileOperations = {}) {
|
|
130
|
+
if (!enabled || resolvedHarnessRoot !== ".codex")
|
|
131
|
+
return [];
|
|
132
|
+
const operations = operationsWith(fileOperations);
|
|
133
|
+
const asset = await readValidPackageProfile(operations);
|
|
134
|
+
if (!asset.valid)
|
|
135
|
+
return [];
|
|
136
|
+
const destination = path.join(projectRoot, LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH);
|
|
137
|
+
const inspected = await inspectProfileDestination(projectRoot, destination, operations);
|
|
138
|
+
if (inspected.kind !== "regular")
|
|
139
|
+
return [];
|
|
140
|
+
const existing = await operations.readFile(destination, "utf8");
|
|
141
|
+
return existing === asset.content &&
|
|
142
|
+
parseAndValidateLongTaskCodexAgentProfile(existing).valid
|
|
143
|
+
? [LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH]
|
|
144
|
+
: [];
|
|
145
|
+
}
|
|
146
|
+
export function isManagedLongTaskCodexAgentProfile(content) {
|
|
147
|
+
return parseAndValidateLongTaskCodexAgentProfile(content).valid;
|
|
148
|
+
}
|
|
149
|
+
export async function atomicWriteLongTaskCodexAgentProfile(destination, content, operations = DEFAULT_FILE_OPERATIONS, beforeRename = async () => undefined) {
|
|
150
|
+
await operations.mkdir(path.dirname(destination), { recursive: true });
|
|
151
|
+
const temp = `${destination}.tmp-${process.pid}-${operations.randomId()}`;
|
|
152
|
+
let renamed = false;
|
|
153
|
+
try {
|
|
154
|
+
await operations.writeFile(temp, content, { flag: "wx" });
|
|
155
|
+
await beforeRename();
|
|
156
|
+
await operations.rename(temp, destination);
|
|
157
|
+
renamed = true;
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
if (!renamed)
|
|
161
|
+
await operations.rm(temp, { force: true }).catch(() => { });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function removeManagedProfile(projectRoot, destination, report, operations) {
|
|
165
|
+
const inspected = await inspectProfileDestination(projectRoot, destination, operations);
|
|
166
|
+
if (inspected.kind === "absent")
|
|
167
|
+
return;
|
|
168
|
+
if (inspected.kind === "conflict") {
|
|
169
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: optional adapter conflict (${inspected.reason})`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const existing = await operations.readFile(destination, "utf8");
|
|
173
|
+
if (!hasManagedMarker(existing)) {
|
|
174
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: user-owned (managed marker absent)`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const current = await inspectProfileDestination(projectRoot, destination, operations);
|
|
178
|
+
if (current.kind !== "regular" ||
|
|
179
|
+
(await operations.readFile(destination, "utf8")) !== existing) {
|
|
180
|
+
report.skipped.push(`${LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH}: optional adapter changed before disable`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
await operations.rm(destination, { force: true });
|
|
184
|
+
report.changed.push(LONG_TASK_CODEX_AGENT_PROFILE_RELATIVE_PATH);
|
|
185
|
+
}
|
|
186
|
+
async function readValidPackageProfile(operations) {
|
|
187
|
+
const source = packageAssetPath(...ASSET_SEGMENTS);
|
|
188
|
+
const sourceStat = await lstatOrNull(source, operations);
|
|
189
|
+
if (!sourceStat)
|
|
190
|
+
return { valid: false, reason: "unavailable" };
|
|
191
|
+
if (sourceStat.isSymbolicLink() || !sourceStat.isFile())
|
|
192
|
+
return { valid: false, reason: "is not a regular file" };
|
|
193
|
+
const content = await operations.readFile(source, "utf8");
|
|
194
|
+
const validation = parseAndValidateLongTaskCodexAgentProfile(content);
|
|
195
|
+
if (!validation.valid)
|
|
196
|
+
return {
|
|
197
|
+
valid: false,
|
|
198
|
+
reason: `is invalid (${validation.errors.join(",")})`,
|
|
199
|
+
};
|
|
200
|
+
return { valid: true, content };
|
|
201
|
+
}
|
|
202
|
+
async function inspectProfileDestination(projectRoot, destination, operations) {
|
|
203
|
+
const lexicalRoot = path.resolve(projectRoot);
|
|
204
|
+
const canonicalRoot = await operations.realpath(lexicalRoot);
|
|
205
|
+
let cursor = lexicalRoot;
|
|
206
|
+
for (const segment of [".codex", "agents"]) {
|
|
207
|
+
cursor = path.join(cursor, segment);
|
|
208
|
+
const status = await lstatOrNull(cursor, operations);
|
|
209
|
+
if (!status)
|
|
210
|
+
continue;
|
|
211
|
+
if (status.isSymbolicLink())
|
|
212
|
+
return { kind: "conflict", reason: `parent_symlink:${segment}` };
|
|
213
|
+
if (!status.isDirectory())
|
|
214
|
+
return { kind: "conflict", reason: `parent_not_directory:${segment}` };
|
|
215
|
+
if (!inside(canonicalRoot, await operations.realpath(cursor)))
|
|
216
|
+
return {
|
|
217
|
+
kind: "conflict",
|
|
218
|
+
reason: `parent_outside_repository:${segment}`,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const status = await lstatOrNull(destination, operations);
|
|
222
|
+
if (!status)
|
|
223
|
+
return { kind: "absent" };
|
|
224
|
+
if (status.isSymbolicLink())
|
|
225
|
+
return { kind: "conflict", reason: "destination_symlink" };
|
|
226
|
+
if (!status.isFile())
|
|
227
|
+
return { kind: "conflict", reason: "destination_not_regular_file" };
|
|
228
|
+
if (!inside(canonicalRoot, await operations.realpath(destination)))
|
|
229
|
+
return { kind: "conflict", reason: "destination_outside_repository" };
|
|
230
|
+
return { kind: "regular" };
|
|
231
|
+
}
|
|
232
|
+
function operationsWith(overrides) {
|
|
233
|
+
return { ...DEFAULT_FILE_OPERATIONS, ...overrides };
|
|
234
|
+
}
|
|
235
|
+
async function lstatOrNull(target, operations) {
|
|
236
|
+
try {
|
|
237
|
+
return await operations.lstat(target);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (code(error) === "ENOENT")
|
|
241
|
+
return null;
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function inside(root, candidate) {
|
|
246
|
+
const relative = path.relative(root, candidate);
|
|
247
|
+
return (relative === "" ||
|
|
248
|
+
(!relative.startsWith(`..${path.sep}`) &&
|
|
249
|
+
relative !== ".." &&
|
|
250
|
+
!path.isAbsolute(relative)));
|
|
251
|
+
}
|
|
252
|
+
function record(value) {
|
|
253
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
254
|
+
? value
|
|
255
|
+
: null;
|
|
256
|
+
}
|
|
257
|
+
function nonEmptyString(value) {
|
|
258
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
259
|
+
}
|
|
260
|
+
function staticString(value) {
|
|
261
|
+
return (nonEmptyString(value) &&
|
|
262
|
+
value === value.trim() &&
|
|
263
|
+
!/[\r\n$%{}]/u.test(value));
|
|
264
|
+
}
|
|
265
|
+
function hasManagedMarker(content) {
|
|
266
|
+
return (content.replace(/\r\n/gu, "\n").split("\n", 1)[0] ===
|
|
267
|
+
LONG_TASK_CODEX_AGENT_PROFILE_MANAGED_MARKER);
|
|
268
|
+
}
|
|
269
|
+
function code(error) {
|
|
270
|
+
return typeof error === "object" && error !== null && "code" in error
|
|
271
|
+
? String(error.code)
|
|
272
|
+
: "";
|
|
273
|
+
}
|
|
274
|
+
function message(error) {
|
|
275
|
+
return error instanceof Error ? error.message : String(error);
|
|
276
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactRevisionIdentityV1 } from "./semantic-fact-compact-carrier.js";
|
|
3
|
+
export declare function compactClaimProjection(outcomeRef: string, kind: "requirement" | "obligation" | "forbidden_shortcut" | "non_completing_outcome", row: {
|
|
4
|
+
key: string;
|
|
5
|
+
statement: string;
|
|
6
|
+
applicability_refs: string[];
|
|
7
|
+
required_proof_surfaces?: string[];
|
|
8
|
+
}, claimsByStatement: Map<string, string>): Record<string, unknown>;
|
|
9
|
+
export declare function compactAssertionProjection(outcomeRef: string, checkRef: string, position: number, assertion: Record<string, unknown>, claimsByStatement: Map<string, string>, facts: Map<string, string>): Record<string, unknown> | null;
|
|
10
|
+
export declare function compactRevisionMap(rows: SemanticFactRevisionIdentityV1[], label: string): Map<string, string>;
|
|
11
|
+
export declare function compactUniqueClaimStatements(claims: DeliveryContractV2["source_claims"]): Map<string, string>;
|
|
12
|
+
export declare function assertSameCompactKeys(left: string[], right: string[], label: string): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
2
|
+
import { compactWithoutFields } from "./compact-authoring-support.js";
|
|
3
|
+
export function compactClaimProjection(outcomeRef, kind, row, claimsByStatement) {
|
|
4
|
+
const claimKey = claimsByStatement.get(row.statement) ?? null;
|
|
5
|
+
return {
|
|
6
|
+
outcome_ref: outcomeRef,
|
|
7
|
+
projection_kind: kind,
|
|
8
|
+
projection_key: row.key,
|
|
9
|
+
claim_key: claimKey,
|
|
10
|
+
statement: claimKey ? null : row.statement,
|
|
11
|
+
required_proof_surfaces: row.required_proof_surfaces ?? null,
|
|
12
|
+
applicability_refs: row.applicability_refs,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function compactAssertionProjection(outcomeRef, checkRef, position, assertion, claimsByStatement, facts) {
|
|
16
|
+
const criterion = String(assertion.criterion ?? "");
|
|
17
|
+
const claimRef = claimsByStatement.get(criterion);
|
|
18
|
+
let criterionKind;
|
|
19
|
+
let criterionRef;
|
|
20
|
+
if (claimRef) {
|
|
21
|
+
criterionKind = "claim_statement";
|
|
22
|
+
criterionRef = claimRef;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const match = /^The current candidate satisfies the exact Source Fact (fact\.[a-z0-9._:-]+)\.$/u.exec(criterion);
|
|
26
|
+
if (!match || !facts.has(match[1]))
|
|
27
|
+
return null;
|
|
28
|
+
criterionKind = "semantic_fact";
|
|
29
|
+
criterionRef = match[1];
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
outcome_ref: outcomeRef,
|
|
33
|
+
check_ref: checkRef,
|
|
34
|
+
position,
|
|
35
|
+
criterion_kind: criterionKind,
|
|
36
|
+
criterion_ref: criterionRef,
|
|
37
|
+
...compactWithoutFields(assertion, ["criterion"]),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function compactRevisionMap(rows, label) {
|
|
41
|
+
const result = new Map();
|
|
42
|
+
for (const row of rows) {
|
|
43
|
+
if (result.has(row.key))
|
|
44
|
+
throw new Error(`long_task_compact_authoring_invalid:${label}_revision_duplicate:${row.key}`);
|
|
45
|
+
result.set(row.key, row.revision_digest);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
export function compactUniqueClaimStatements(claims) {
|
|
50
|
+
const result = new Map();
|
|
51
|
+
const duplicates = new Set();
|
|
52
|
+
for (const claim of claims) {
|
|
53
|
+
if (result.has(claim.statement)) {
|
|
54
|
+
result.delete(claim.statement);
|
|
55
|
+
duplicates.add(claim.statement);
|
|
56
|
+
}
|
|
57
|
+
else if (!duplicates.has(claim.statement))
|
|
58
|
+
result.set(claim.statement, claim.key);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
export function assertSameCompactKeys(left, right, label) {
|
|
63
|
+
const a = [...new Set(left)].sort();
|
|
64
|
+
const b = [...new Set(right)].sort();
|
|
65
|
+
if (canonicalValueJson(a) !== canonicalValueJson(b))
|
|
66
|
+
throw new Error(`long_task_compact_authoring_invalid:${label}:${a.length}:${b.length}`);
|
|
67
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DeliveryContractV2 } from "./long-task-delivery-types.js";
|
|
2
|
+
import type { SemanticFactRevisionIdentityV1 } from "./semantic-fact-compact-carrier.js";
|
|
3
|
+
export declare function createLongTaskCompactContract(contractInput: DeliveryContractV2, factRevisions: SemanticFactRevisionIdentityV1[], obligationRevisions: SemanticFactRevisionIdentityV1[]): Record<string, unknown>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { applyCompactAuthoringSelectors, compactAuthoringTable, compactCapacityBudget, compactDeterministicTemplates, compactWithoutFields as withoutFields, } from "./compact-authoring-support.js";
|
|
3
|
+
import { applyCompactSharedStructures } from "./compact-shared-structure-authoring.js";
|
|
4
|
+
import { longTaskCompactSharedStructureTargets } from "./long-task-compact-primitives.js";
|
|
5
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
6
|
+
import { assertSameCompactKeys as assertSameKeys, compactAssertionProjection as assertionProjection, compactClaimProjection as claimProjection, compactRevisionMap as revisionMap, compactUniqueClaimStatements as uniqueClaimStatements, } from "./long-task-compact-authoring-projections.js";
|
|
7
|
+
export function createLongTaskCompactContract(contractInput, factRevisions, obligationRevisions) {
|
|
8
|
+
const contract = structuredClone(contractInput);
|
|
9
|
+
const factRevisionByKey = revisionMap(factRevisions, "fact");
|
|
10
|
+
const obligationRevisionByKey = revisionMap(obligationRevisions, "obligation");
|
|
11
|
+
const sourceClaims = structuredClone(contract.source_claims);
|
|
12
|
+
const revisionedContract = structuredClone(contractInput);
|
|
13
|
+
for (const outcome of revisionedContract.outcomes) {
|
|
14
|
+
for (const binding of outcome.semantic_fact_bindings.facts) {
|
|
15
|
+
const digest = factRevisionByKey.get(binding.fact_ref);
|
|
16
|
+
if (digest)
|
|
17
|
+
binding.fact_revision_digest = digest;
|
|
18
|
+
}
|
|
19
|
+
for (const binding of outcome.semantic_fact_bindings.proofs) {
|
|
20
|
+
const digest = obligationRevisionByKey.get(binding.proof_ref);
|
|
21
|
+
if (digest)
|
|
22
|
+
binding.obligation_revision_digest = digest;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const claimByStatement = uniqueClaimStatements(contract.source_claims);
|
|
26
|
+
const claimProjections = [];
|
|
27
|
+
const facts = [];
|
|
28
|
+
const proofBindings = [];
|
|
29
|
+
const assertionProjections = [];
|
|
30
|
+
const base = contract;
|
|
31
|
+
delete base.source_claims;
|
|
32
|
+
for (const outcome of contract.outcomes) {
|
|
33
|
+
for (const row of outcome.product.requirements)
|
|
34
|
+
claimProjections.push(claimProjection(outcome.key, "requirement", row, claimByStatement));
|
|
35
|
+
for (const row of outcome.technical.obligations)
|
|
36
|
+
claimProjections.push(claimProjection(outcome.key, "obligation", row, claimByStatement));
|
|
37
|
+
for (const row of outcome.technical.forbidden_shortcuts)
|
|
38
|
+
claimProjections.push(claimProjection(outcome.key, "forbidden_shortcut", row, claimByStatement));
|
|
39
|
+
for (const row of outcome.product.non_completing_outcomes)
|
|
40
|
+
claimProjections.push(claimProjection(outcome.key, "non_completing_outcome", row, claimByStatement));
|
|
41
|
+
delete outcome.product.requirements;
|
|
42
|
+
delete outcome.product
|
|
43
|
+
.non_completing_outcomes;
|
|
44
|
+
delete outcome.technical
|
|
45
|
+
.obligations;
|
|
46
|
+
delete outcome.technical
|
|
47
|
+
.forbidden_shortcuts;
|
|
48
|
+
for (const binding of outcome.semantic_fact_bindings.facts) {
|
|
49
|
+
const revision = factRevisionByKey.get(binding.fact_ref);
|
|
50
|
+
if (!revision)
|
|
51
|
+
throw new Error(`long_task_compact_authoring_invalid:fact_revision_missing:${binding.fact_ref}`);
|
|
52
|
+
facts.push({
|
|
53
|
+
outcome_ref: outcome.key,
|
|
54
|
+
manifest_ref: outcome.semantic_fact_bindings.manifest_ref,
|
|
55
|
+
fact_key: binding.fact_ref,
|
|
56
|
+
fact_revision_digest: revision,
|
|
57
|
+
claim_ref: binding.claim_ref,
|
|
58
|
+
applicability_ref: binding.applicability_ref,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
for (const binding of outcome.semantic_fact_bindings.proofs) {
|
|
62
|
+
const revision = obligationRevisionByKey.get(binding.proof_ref);
|
|
63
|
+
if (!revision)
|
|
64
|
+
throw new Error(`long_task_compact_authoring_invalid:obligation_revision_missing:${binding.proof_ref}`);
|
|
65
|
+
proofBindings.push({
|
|
66
|
+
outcome_ref: outcome.key,
|
|
67
|
+
obligation_key: binding.proof_ref,
|
|
68
|
+
obligation_revision_digest: revision,
|
|
69
|
+
fact_key: binding.fact_ref,
|
|
70
|
+
...withoutFields(binding, [
|
|
71
|
+
"proof_ref",
|
|
72
|
+
"fact_ref",
|
|
73
|
+
"obligation_revision_digest",
|
|
74
|
+
]),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
delete outcome
|
|
78
|
+
.semantic_fact_bindings;
|
|
79
|
+
for (const check of outcome.acceptance.checks) {
|
|
80
|
+
const retained = [];
|
|
81
|
+
for (const [position, assertion] of check.positive_assertions.entries()) {
|
|
82
|
+
const projection = assertionProjection(outcome.key, check.key, position, assertion, claimByStatement, factRevisionByKey);
|
|
83
|
+
if (projection)
|
|
84
|
+
assertionProjections.push(projection);
|
|
85
|
+
else
|
|
86
|
+
retained.push(assertion);
|
|
87
|
+
}
|
|
88
|
+
check.positive_assertions = retained;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
assertSameKeys([...factRevisionByKey.keys()], facts.map((fact) => String(fact.fact_key)), "fact_set");
|
|
92
|
+
assertSameKeys([...obligationRevisionByKey.keys()], proofBindings.map((proof) => String(proof.obligation_key)), "obligation_set");
|
|
93
|
+
const proofTemplateExcludedFields = [
|
|
94
|
+
"outcome_ref",
|
|
95
|
+
"obligation_key",
|
|
96
|
+
"obligation_revision_digest",
|
|
97
|
+
"fact_key",
|
|
98
|
+
"assertion_ref",
|
|
99
|
+
"confirmation_ref",
|
|
100
|
+
];
|
|
101
|
+
const proofFamilies = compactDeterministicTemplates(proofBindings, proofTemplateExcludedFields, "proof-template");
|
|
102
|
+
const proofFamilyByKey = new Map(proofFamilies.templates.map((template) => [template.key, template.value]));
|
|
103
|
+
const obligationRows = proofBindings.map((proof, index) => ({
|
|
104
|
+
outcome_ref: proof.outcome_ref,
|
|
105
|
+
obligation_key: proof.obligation_key,
|
|
106
|
+
obligation_revision_digest: proof.obligation_revision_digest,
|
|
107
|
+
fact_key: proof.fact_key,
|
|
108
|
+
template_ref: proofFamilies.template_refs[index],
|
|
109
|
+
overrides: withoutFields(proof, [
|
|
110
|
+
"outcome_ref",
|
|
111
|
+
"obligation_key",
|
|
112
|
+
"obligation_revision_digest",
|
|
113
|
+
"fact_key",
|
|
114
|
+
...Object.keys(proofFamilyByKey.get(proofFamilies.template_refs[index])),
|
|
115
|
+
]),
|
|
116
|
+
}));
|
|
117
|
+
const exceptions = claimProjections
|
|
118
|
+
.filter((row) => canonicalValueJson(row.required_proof_surfaces) !==
|
|
119
|
+
canonicalValueJson(["runtime_behavior"]) &&
|
|
120
|
+
row.required_proof_surfaces !== null)
|
|
121
|
+
.map((row) => ({
|
|
122
|
+
key: `exception.claim-projection.${row.projection_key}`,
|
|
123
|
+
target_ref: row.projection_key,
|
|
124
|
+
rationale: "This projection explicitly retains a non-default required proof-surface set.",
|
|
125
|
+
}));
|
|
126
|
+
base.compact_semantic_carrier = {
|
|
127
|
+
schema_version: "long-task-compact-carrier-v1",
|
|
128
|
+
capacity: {},
|
|
129
|
+
selectors: [],
|
|
130
|
+
shared_structures: [],
|
|
131
|
+
claim_catalog: compactAuthoringTable(sourceClaims),
|
|
132
|
+
claim_projections: compactAuthoringTable(claimProjections),
|
|
133
|
+
fact_sets: [
|
|
134
|
+
{
|
|
135
|
+
key: "fact-set.complete-contract",
|
|
136
|
+
...compactAuthoringTable(facts),
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
proof_templates: proofFamilies.templates.map((template) => ({
|
|
140
|
+
key: template.key,
|
|
141
|
+
binding: template.value,
|
|
142
|
+
})),
|
|
143
|
+
obligations: compactAuthoringTable(obligationRows),
|
|
144
|
+
assertion_projections: compactAuthoringTable(assertionProjections),
|
|
145
|
+
exceptions,
|
|
146
|
+
};
|
|
147
|
+
const { value, selectors } = applyCompactAuthoringSelectors(base);
|
|
148
|
+
const carrier = value.compact_semantic_carrier;
|
|
149
|
+
carrier.selectors = selectors;
|
|
150
|
+
const structures = applyCompactSharedStructures(longTaskCompactSharedStructureTargets(value, carrier));
|
|
151
|
+
carrier.shared_structures = structures.catalog;
|
|
152
|
+
const measured = {
|
|
153
|
+
claims: sourceClaims.length,
|
|
154
|
+
claim_projections: claimProjections.length,
|
|
155
|
+
selector_members: selectors.reduce((sum, selector) => sum + selector.members.length, 0),
|
|
156
|
+
structure_families: structures.statistics.emitted_family_count,
|
|
157
|
+
structure_references: structures.statistics.reference_count,
|
|
158
|
+
structure_arguments: structures.statistics.argument_count,
|
|
159
|
+
facts: facts.length,
|
|
160
|
+
obligations: obligationRows.length,
|
|
161
|
+
assertions: assertionProjections.length,
|
|
162
|
+
canonical_bytes: Buffer.byteLength(canonicalValueJson(revisionedContract), "utf8"),
|
|
163
|
+
};
|
|
164
|
+
carrier.capacity = {
|
|
165
|
+
theoretical_ground_universe: "not_materialized",
|
|
166
|
+
measured,
|
|
167
|
+
maximum: Object.fromEntries(Object.entries(measured).map(([name, count]) => [
|
|
168
|
+
name,
|
|
169
|
+
compactCapacityBudget(name, count),
|
|
170
|
+
])),
|
|
171
|
+
};
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LongTaskCompactCapacityCounts } from "./long-task-compact-primitives.js";
|
|
2
|
+
export interface MaterializedLongTaskCompactCarrierV1 {
|
|
3
|
+
root: Record<string, unknown>;
|
|
4
|
+
measured: LongTaskCompactCapacityCounts;
|
|
5
|
+
}
|
|
6
|
+
export declare function materializeLongTaskCompactCarrier(rootInput: Record<string, unknown>): MaterializedLongTaskCompactCarrierV1;
|
|
7
|
+
export declare function materializeLongTaskCompactCarrierForMigration(rootInput: Record<string, unknown>): MaterializedLongTaskCompactCarrierV1;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { canonicalValueJson } from "./strict-codec.js";
|
|
3
|
+
import { materializeCanonicalCompactSharedStructures } from "./compact-shared-structure-validation.js";
|
|
4
|
+
import { parseLongTaskCompactCapacity, parseLongTaskCompactExceptions, parseLongTaskCompactFactSets, parseLongTaskCompactProofTemplates, parseLongTaskCompactSelectors, parseLongTaskCompactTable, } from "./long-task-compact-parser.js";
|
|
5
|
+
import { materializeLongTaskCompactAssertions, materializeLongTaskCompactClaimProjections, materializeLongTaskCompactFactBindings, prepareLongTaskCompactOutcomeTargets, } from "./long-task-compact-projections.js";
|
|
6
|
+
import { compactArray, compactFail, compactPlainObject, compactResolveSelectors, compactStableRef, compactStrictObject, compactUniqueRows, longTaskCompactSharedStructureTargets, validateLongTaskCompactCapacity, validateLongTaskCompactDeclaredMaximum, } from "./long-task-compact-primitives.js";
|
|
7
|
+
const VERSION = "long-task-compact-carrier-v1";
|
|
8
|
+
export function materializeLongTaskCompactCarrier(rootInput) {
|
|
9
|
+
return materializeLongTaskCompactCarrierInternal(rootInput, false);
|
|
10
|
+
}
|
|
11
|
+
export function materializeLongTaskCompactCarrierForMigration(rootInput) {
|
|
12
|
+
return materializeLongTaskCompactCarrierInternal(rootInput, true);
|
|
13
|
+
}
|
|
14
|
+
function materializeLongTaskCompactCarrierInternal(rootInput, allowLegacyCarrier) {
|
|
15
|
+
const label = "compact_semantic_carrier";
|
|
16
|
+
if (!Object.hasOwn(rootInput, label))
|
|
17
|
+
compactFail(label, "missing carrier");
|
|
18
|
+
if (Object.hasOwn(rootInput, "source_claims"))
|
|
19
|
+
compactFail(label, "expanded source_claims cannot coexist with compact carrier");
|
|
20
|
+
if (!Object.hasOwn(rootInput, "outcomes"))
|
|
21
|
+
compactFail(label, "v1 compact carrier requires inline outcomes");
|
|
22
|
+
const working = structuredClone(rootInput);
|
|
23
|
+
const carrierInput = compactPlainObject(working[label], label);
|
|
24
|
+
const hadSharedStructures = Object.hasOwn(carrierInput, "shared_structures");
|
|
25
|
+
if (!hadSharedStructures) {
|
|
26
|
+
if (!allowLegacyCarrier)
|
|
27
|
+
compactFail(`${label}.shared_structures`, "missing canonical catalog");
|
|
28
|
+
carrierInput.shared_structures = [];
|
|
29
|
+
addLegacyStructureCapacityFields(carrierInput.capacity);
|
|
30
|
+
}
|
|
31
|
+
const carrier = compactStrictObject(carrierInput, label, [
|
|
32
|
+
"schema_version",
|
|
33
|
+
"capacity",
|
|
34
|
+
"selectors",
|
|
35
|
+
"shared_structures",
|
|
36
|
+
"claim_catalog",
|
|
37
|
+
"claim_projections",
|
|
38
|
+
"fact_sets",
|
|
39
|
+
"proof_templates",
|
|
40
|
+
"obligations",
|
|
41
|
+
"assertion_projections",
|
|
42
|
+
"exceptions",
|
|
43
|
+
]);
|
|
44
|
+
if (carrier.schema_version !== VERSION)
|
|
45
|
+
compactFail(`${label}.schema_version`, `must be ${VERSION}`);
|
|
46
|
+
const capacity = parseLongTaskCompactCapacity(carrier.capacity, `${label}.capacity`);
|
|
47
|
+
validateLongTaskCompactDeclaredMaximum(capacity.maximum, label);
|
|
48
|
+
const structureStatistics = hadSharedStructures
|
|
49
|
+
? materializeCanonicalCompactSharedStructures(longTaskCompactSharedStructureTargets(working, carrier), carrier.shared_structures, label)
|
|
50
|
+
: {
|
|
51
|
+
emitted_family_count: 0,
|
|
52
|
+
reference_count: 0,
|
|
53
|
+
argument_count: 0,
|
|
54
|
+
};
|
|
55
|
+
const selectors = parseLongTaskCompactSelectors(carrier.selectors, `${label}.selectors`);
|
|
56
|
+
const claims = parseLongTaskCompactTable(carrier.claim_catalog, selectors, `${label}.claim_catalog`);
|
|
57
|
+
compactUniqueRows(claims, "key", `${label}.claim_catalog`);
|
|
58
|
+
const claimByKey = new Map(claims.map((claim) => [
|
|
59
|
+
compactStableRef(claim.key, `${label}.claim.key`),
|
|
60
|
+
claim,
|
|
61
|
+
]));
|
|
62
|
+
const claimProjections = parseLongTaskCompactTable(carrier.claim_projections, selectors, `${label}.claim_projections`);
|
|
63
|
+
const facts = parseLongTaskCompactFactSets(carrier.fact_sets, selectors, `${label}.fact_sets`);
|
|
64
|
+
compactUniqueRows(facts, "fact_key", `${label}.facts`);
|
|
65
|
+
const factByKey = new Map(facts.map((fact) => [
|
|
66
|
+
compactStableRef(fact.fact_key, `${label}.fact.fact_key`),
|
|
67
|
+
fact,
|
|
68
|
+
]));
|
|
69
|
+
const proofTemplates = parseLongTaskCompactProofTemplates(carrier.proof_templates, selectors, `${label}.proof_templates`);
|
|
70
|
+
const obligations = parseLongTaskCompactTable(carrier.obligations, selectors, `${label}.obligations`);
|
|
71
|
+
compactUniqueRows(obligations, "obligation_key", `${label}.obligations`);
|
|
72
|
+
const assertions = parseLongTaskCompactTable(carrier.assertion_projections, selectors, `${label}.assertion_projections`);
|
|
73
|
+
const exceptions = parseLongTaskCompactExceptions(carrier.exceptions, `${label}.exceptions`);
|
|
74
|
+
validateCompactProjectionExceptions(claimProjections, exceptions, `${label}.exceptions`);
|
|
75
|
+
const { compact_semantic_carrier: _carrier, ...base } = working;
|
|
76
|
+
const expanded = compactPlainObject(compactResolveSelectors(structuredClone(base), selectors, "$"), "$");
|
|
77
|
+
expanded.source_claims = claims;
|
|
78
|
+
const outcomes = compactArray(expanded.outcomes, "outcomes").map((item, index) => compactPlainObject(item, `outcomes[${index}]`));
|
|
79
|
+
const outcomeByKey = new Map(outcomes.map((outcome, index) => [
|
|
80
|
+
compactStableRef(outcome.key, `outcomes[${index}].key`),
|
|
81
|
+
outcome,
|
|
82
|
+
]));
|
|
83
|
+
prepareLongTaskCompactOutcomeTargets(outcomes);
|
|
84
|
+
materializeLongTaskCompactClaimProjections(claimProjections, claimByKey, outcomeByKey);
|
|
85
|
+
materializeLongTaskCompactFactBindings(facts, obligations, factByKey, proofTemplates, outcomeByKey);
|
|
86
|
+
materializeLongTaskCompactAssertions(assertions, claimByKey, factByKey, outcomeByKey);
|
|
87
|
+
expanded.outcomes = outcomes;
|
|
88
|
+
const measured = {
|
|
89
|
+
claims: claims.length,
|
|
90
|
+
claim_projections: claimProjections.length,
|
|
91
|
+
selector_members: [...selectors.values()].reduce((sum, members) => sum + members.length, 0),
|
|
92
|
+
structure_families: structureStatistics.emitted_family_count,
|
|
93
|
+
structure_references: structureStatistics.reference_count,
|
|
94
|
+
structure_arguments: structureStatistics.argument_count,
|
|
95
|
+
facts: facts.length,
|
|
96
|
+
obligations: obligations.length,
|
|
97
|
+
assertions: assertions.length,
|
|
98
|
+
canonical_bytes: Buffer.byteLength(canonicalValueJson(expanded), "utf8"),
|
|
99
|
+
};
|
|
100
|
+
validateLongTaskCompactCapacity(capacity, measured, label);
|
|
101
|
+
return { root: expanded, measured };
|
|
102
|
+
}
|
|
103
|
+
function addLegacyStructureCapacityFields(value) {
|
|
104
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
105
|
+
return;
|
|
106
|
+
const capacity = value;
|
|
107
|
+
for (const field of ["measured", "maximum"]) {
|
|
108
|
+
const counts = capacity[field];
|
|
109
|
+
if (!counts || typeof counts !== "object" || Array.isArray(counts))
|
|
110
|
+
continue;
|
|
111
|
+
const row = counts;
|
|
112
|
+
row.structure_families = 0;
|
|
113
|
+
row.structure_references = 0;
|
|
114
|
+
row.structure_arguments = 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function validateCompactProjectionExceptions(projections, exceptions, label) {
|
|
118
|
+
const expected = projections
|
|
119
|
+
.filter((projection) => {
|
|
120
|
+
const surfaces = projection.required_proof_surfaces;
|
|
121
|
+
return (surfaces !== null &&
|
|
122
|
+
(!Array.isArray(surfaces) ||
|
|
123
|
+
surfaces.length !== 1 ||
|
|
124
|
+
surfaces[0] !== "runtime_behavior"));
|
|
125
|
+
})
|
|
126
|
+
.map((projection, index) => compactStableRef(projection.projection_key, `${label}.projection[${index}].projection_key`))
|
|
127
|
+
.sort();
|
|
128
|
+
const actual = exceptions.map((item) => item.target_ref).sort();
|
|
129
|
+
if (new Set(actual).size !== actual.length ||
|
|
130
|
+
canonicalValueJson(expected) !== canonicalValueJson(actual))
|
|
131
|
+
compactFail(label, `projection target set mismatch: ${actual.length}:${expected.length}`);
|
|
132
|
+
}
|