@kontourai/flow-agents 3.12.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +76 -0
- package/CHANGELOG.md +48 -0
- package/build/generated/capability-declarations.json +177 -0
- package/build/src/builder-flow-runtime.d.ts +37 -0
- package/build/src/builder-flow-runtime.js +71 -1
- package/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/build/src/builder-gate-action-envelope.js +163 -30
- package/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/build/src/builder-lifecycle-authority.js +38 -0
- package/build/src/cli/builder-run.js +71 -2
- package/build/src/cli/narrative-render.d.ts +95 -0
- package/build/src/cli/narrative-render.js +466 -0
- package/build/src/cli/narrative-sources.d.ts +2 -0
- package/build/src/cli/narrative-sources.js +282 -0
- package/build/src/cli/public-contracts.d.ts +257 -0
- package/build/src/cli/public-contracts.js +87 -0
- package/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/build/src/cli/workflow-sidecar.js +599 -180
- package/build/src/cli/workflow.js +11 -1
- package/build/src/cli.js +8 -0
- package/build/src/continuation-driver.d.ts +12 -0
- package/build/src/continuation-driver.js +16 -2
- package/build/src/continuation-validation.js +349 -3
- package/build/src/flow-kit/action-metadata.js +21 -1
- package/build/src/index.d.ts +33 -2
- package/build/src/index.js +24 -0
- package/build/src/lib/capability-declarations.d.ts +83 -0
- package/build/src/lib/capability-declarations.js +209 -0
- package/build/src/narrative/envelope.d.ts +111 -0
- package/build/src/narrative/envelope.js +590 -0
- package/build/src/narrative/eval-result.d.ts +60 -0
- package/build/src/narrative/eval-result.js +158 -0
- package/build/src/narrative/grounding-validator.d.ts +104 -0
- package/build/src/narrative/grounding-validator.js +472 -0
- package/build/src/narrative/integrity.d.ts +17 -0
- package/build/src/narrative/integrity.js +39 -0
- package/build/src/narrative/intent-economics.d.ts +42 -0
- package/build/src/narrative/intent-economics.js +82 -0
- package/build/src/narrative/intent.d.ts +94 -0
- package/build/src/narrative/intent.js +132 -0
- package/build/src/narrative/policy-filter.d.ts +15 -0
- package/build/src/narrative/policy-filter.js +58 -0
- package/build/src/narrative/projection.d.ts +58 -0
- package/build/src/narrative/projection.js +502 -0
- package/build/src/narrative/readers.d.ts +84 -0
- package/build/src/narrative/readers.js +406 -0
- package/build/src/narrative/render.d.ts +3 -0
- package/build/src/narrative/render.js +83 -0
- package/build/src/narrative/resolver.d.ts +52 -0
- package/build/src/narrative/resolver.js +190 -0
- package/build/src/narrative/snapshot.d.ts +90 -0
- package/build/src/narrative/snapshot.js +325 -0
- package/build/src/narrative/source-ids.d.ts +121 -0
- package/build/src/narrative/source-ids.js +201 -0
- package/build/src/narrative/statements.d.ts +84 -0
- package/build/src/narrative/statements.js +347 -0
- package/build/src/narrative/turn-spine.d.ts +19 -0
- package/build/src/narrative/turn-spine.js +73 -0
- package/build/src/tools/build-universal-bundles.js +8 -0
- package/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/build/src/tools/generate-capability-matrix.js +207 -0
- package/build/src/tools/validate-source-tree.js +5 -1
- package/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/context/scripts/hooks/workflow-steering.js +160 -19
- package/context/scripts/telemetry/lib/session.sh +3 -0
- package/context/scripts/telemetry/lib/transport.sh +12 -3
- package/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/base/build/generated/capability-declarations.json +177 -0
- package/dist/base/build/package.json +1 -1
- package/dist/base/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/base/build/src/builder-flow-runtime.js +71 -1
- package/dist/base/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/base/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/base/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/base/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/base/build/src/cli/builder-run.js +71 -2
- package/dist/base/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/base/build/src/cli/narrative-render.js +466 -0
- package/dist/base/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/base/build/src/cli/narrative-sources.js +282 -0
- package/dist/base/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/base/build/src/cli/public-contracts.js +87 -0
- package/dist/base/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/base/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/base/build/src/cli/workflow.js +11 -1
- package/dist/base/build/src/cli.js +8 -0
- package/dist/base/build/src/continuation-driver.d.ts +12 -0
- package/dist/base/build/src/continuation-driver.js +16 -2
- package/dist/base/build/src/continuation-validation.js +349 -3
- package/dist/base/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/base/build/src/index.d.ts +33 -2
- package/dist/base/build/src/index.js +24 -0
- package/dist/base/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/base/build/src/lib/capability-declarations.js +209 -0
- package/dist/base/build/src/narrative/envelope.d.ts +111 -0
- package/dist/base/build/src/narrative/envelope.js +590 -0
- package/dist/base/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/base/build/src/narrative/eval-result.js +158 -0
- package/dist/base/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/base/build/src/narrative/grounding-validator.js +472 -0
- package/dist/base/build/src/narrative/integrity.d.ts +17 -0
- package/dist/base/build/src/narrative/integrity.js +39 -0
- package/dist/base/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/base/build/src/narrative/intent-economics.js +82 -0
- package/dist/base/build/src/narrative/intent.d.ts +94 -0
- package/dist/base/build/src/narrative/intent.js +132 -0
- package/dist/base/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/base/build/src/narrative/policy-filter.js +58 -0
- package/dist/base/build/src/narrative/projection.d.ts +58 -0
- package/dist/base/build/src/narrative/projection.js +502 -0
- package/dist/base/build/src/narrative/readers.d.ts +84 -0
- package/dist/base/build/src/narrative/readers.js +406 -0
- package/dist/base/build/src/narrative/render.d.ts +3 -0
- package/dist/base/build/src/narrative/render.js +83 -0
- package/dist/base/build/src/narrative/resolver.d.ts +52 -0
- package/dist/base/build/src/narrative/resolver.js +190 -0
- package/dist/base/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/base/build/src/narrative/snapshot.js +325 -0
- package/dist/base/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/base/build/src/narrative/source-ids.js +201 -0
- package/dist/base/build/src/narrative/statements.d.ts +84 -0
- package/dist/base/build/src/narrative/statements.js +347 -0
- package/dist/base/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/base/build/src/narrative/turn-spine.js +73 -0
- package/dist/base/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/base/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/base/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/base/build/src/tools/validate-source-tree.js +5 -1
- package/dist/base/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/base/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/base/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/base/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/base/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/base/docs/context-map.md +4 -0
- package/dist/base/docs/decisions/index.md +1 -0
- package/dist/base/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/base/docs/fixture-ownership.md +5 -1
- package/dist/base/docs/migrations.md +20 -0
- package/dist/base/docs/public-workflow-cli.md +9 -0
- package/dist/base/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/base/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/base/docs/specs/economics-record-contract.md +1 -1
- package/dist/base/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/base/docs/workflow-usage-guide.md +4 -1
- package/dist/base/evals/ci/run-baseline.sh +38 -0
- package/dist/base/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/base/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/base/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/base/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/base/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/base/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/base/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/base/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/base/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/base/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/base/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/base/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/base/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/base/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/base/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/base/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/base/evals/integration/test_economics_record.sh +42 -0
- package/dist/base/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/base/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/base/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/base/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/base/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/base/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/base/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/base/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/base/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/base/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/base/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/base/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/base/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/base/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/base/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/base/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/base/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/base/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/base/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/base/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/base/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/base/evals/run.sh +12 -0
- package/dist/base/evals/static/test_library_exports.sh +5 -0
- package/dist/base/install.sh +1 -1
- package/dist/base/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/base/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/base/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/base/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/base/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/base/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/base/scripts/hooks/workflow-steering.js +160 -19
- package/dist/base/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/base/scripts/telemetry/economics-record.sh +47 -3
- package/dist/base/scripts/telemetry/lib/session.sh +3 -0
- package/dist/base/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/base/scripts/telemetry/telemetry.sh +480 -59
- package/dist/claude-code/build/generated/capability-declarations.json +177 -0
- package/dist/claude-code/build/package.json +1 -1
- package/dist/claude-code/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/claude-code/build/src/builder-flow-runtime.js +71 -1
- package/dist/claude-code/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/claude-code/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/claude-code/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/claude-code/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/claude-code/build/src/cli/builder-run.js +71 -2
- package/dist/claude-code/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/claude-code/build/src/cli/narrative-render.js +466 -0
- package/dist/claude-code/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/claude-code/build/src/cli/narrative-sources.js +282 -0
- package/dist/claude-code/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/claude-code/build/src/cli/public-contracts.js +87 -0
- package/dist/claude-code/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/claude-code/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/claude-code/build/src/cli/workflow.js +11 -1
- package/dist/claude-code/build/src/cli.js +8 -0
- package/dist/claude-code/build/src/continuation-driver.d.ts +12 -0
- package/dist/claude-code/build/src/continuation-driver.js +16 -2
- package/dist/claude-code/build/src/continuation-validation.js +349 -3
- package/dist/claude-code/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/claude-code/build/src/index.d.ts +33 -2
- package/dist/claude-code/build/src/index.js +24 -0
- package/dist/claude-code/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/claude-code/build/src/lib/capability-declarations.js +209 -0
- package/dist/claude-code/build/src/narrative/envelope.d.ts +111 -0
- package/dist/claude-code/build/src/narrative/envelope.js +590 -0
- package/dist/claude-code/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/claude-code/build/src/narrative/eval-result.js +158 -0
- package/dist/claude-code/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/claude-code/build/src/narrative/grounding-validator.js +472 -0
- package/dist/claude-code/build/src/narrative/integrity.d.ts +17 -0
- package/dist/claude-code/build/src/narrative/integrity.js +39 -0
- package/dist/claude-code/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/claude-code/build/src/narrative/intent-economics.js +82 -0
- package/dist/claude-code/build/src/narrative/intent.d.ts +94 -0
- package/dist/claude-code/build/src/narrative/intent.js +132 -0
- package/dist/claude-code/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/claude-code/build/src/narrative/policy-filter.js +58 -0
- package/dist/claude-code/build/src/narrative/projection.d.ts +58 -0
- package/dist/claude-code/build/src/narrative/projection.js +502 -0
- package/dist/claude-code/build/src/narrative/readers.d.ts +84 -0
- package/dist/claude-code/build/src/narrative/readers.js +406 -0
- package/dist/claude-code/build/src/narrative/render.d.ts +3 -0
- package/dist/claude-code/build/src/narrative/render.js +83 -0
- package/dist/claude-code/build/src/narrative/resolver.d.ts +52 -0
- package/dist/claude-code/build/src/narrative/resolver.js +190 -0
- package/dist/claude-code/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/claude-code/build/src/narrative/snapshot.js +325 -0
- package/dist/claude-code/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/claude-code/build/src/narrative/source-ids.js +201 -0
- package/dist/claude-code/build/src/narrative/statements.d.ts +84 -0
- package/dist/claude-code/build/src/narrative/statements.js +347 -0
- package/dist/claude-code/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/claude-code/build/src/narrative/turn-spine.js +73 -0
- package/dist/claude-code/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/claude-code/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/claude-code/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/claude-code/build/src/tools/validate-source-tree.js +5 -1
- package/dist/claude-code/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/claude-code/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/claude-code/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/claude-code/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/claude-code/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/claude-code/docs/context-map.md +4 -0
- package/dist/claude-code/docs/decisions/index.md +1 -0
- package/dist/claude-code/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/claude-code/docs/fixture-ownership.md +5 -1
- package/dist/claude-code/docs/migrations.md +20 -0
- package/dist/claude-code/docs/public-workflow-cli.md +9 -0
- package/dist/claude-code/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/claude-code/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/claude-code/docs/specs/economics-record-contract.md +1 -1
- package/dist/claude-code/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/claude-code/docs/workflow-usage-guide.md +4 -1
- package/dist/claude-code/evals/ci/run-baseline.sh +38 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/claude-code/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/claude-code/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/claude-code/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/claude-code/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/claude-code/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/claude-code/evals/integration/test_economics_record.sh +42 -0
- package/dist/claude-code/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/claude-code/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/claude-code/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/claude-code/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/claude-code/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/claude-code/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/claude-code/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/claude-code/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/claude-code/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/claude-code/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/claude-code/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/claude-code/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/claude-code/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/claude-code/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/claude-code/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/claude-code/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/claude-code/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/claude-code/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/claude-code/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/claude-code/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/claude-code/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/claude-code/evals/run.sh +12 -0
- package/dist/claude-code/evals/static/test_library_exports.sh +5 -0
- package/dist/claude-code/install.sh +1 -1
- package/dist/claude-code/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/claude-code/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/claude-code/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/claude-code/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/claude-code/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/claude-code/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/claude-code/scripts/hooks/workflow-steering.js +160 -19
- package/dist/claude-code/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/claude-code/scripts/telemetry/economics-record.sh +47 -3
- package/dist/claude-code/scripts/telemetry/lib/session.sh +3 -0
- package/dist/claude-code/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/claude-code/scripts/telemetry/telemetry.sh +480 -59
- package/dist/codex/build/generated/capability-declarations.json +177 -0
- package/dist/codex/build/package.json +1 -1
- package/dist/codex/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/codex/build/src/builder-flow-runtime.js +71 -1
- package/dist/codex/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/codex/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/codex/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/codex/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/codex/build/src/cli/builder-run.js +71 -2
- package/dist/codex/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/codex/build/src/cli/narrative-render.js +466 -0
- package/dist/codex/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/codex/build/src/cli/narrative-sources.js +282 -0
- package/dist/codex/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/codex/build/src/cli/public-contracts.js +87 -0
- package/dist/codex/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/codex/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/codex/build/src/cli/workflow.js +11 -1
- package/dist/codex/build/src/cli.js +8 -0
- package/dist/codex/build/src/continuation-driver.d.ts +12 -0
- package/dist/codex/build/src/continuation-driver.js +16 -2
- package/dist/codex/build/src/continuation-validation.js +349 -3
- package/dist/codex/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/codex/build/src/index.d.ts +33 -2
- package/dist/codex/build/src/index.js +24 -0
- package/dist/codex/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/codex/build/src/lib/capability-declarations.js +209 -0
- package/dist/codex/build/src/narrative/envelope.d.ts +111 -0
- package/dist/codex/build/src/narrative/envelope.js +590 -0
- package/dist/codex/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/codex/build/src/narrative/eval-result.js +158 -0
- package/dist/codex/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/codex/build/src/narrative/grounding-validator.js +472 -0
- package/dist/codex/build/src/narrative/integrity.d.ts +17 -0
- package/dist/codex/build/src/narrative/integrity.js +39 -0
- package/dist/codex/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/codex/build/src/narrative/intent-economics.js +82 -0
- package/dist/codex/build/src/narrative/intent.d.ts +94 -0
- package/dist/codex/build/src/narrative/intent.js +132 -0
- package/dist/codex/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/codex/build/src/narrative/policy-filter.js +58 -0
- package/dist/codex/build/src/narrative/projection.d.ts +58 -0
- package/dist/codex/build/src/narrative/projection.js +502 -0
- package/dist/codex/build/src/narrative/readers.d.ts +84 -0
- package/dist/codex/build/src/narrative/readers.js +406 -0
- package/dist/codex/build/src/narrative/render.d.ts +3 -0
- package/dist/codex/build/src/narrative/render.js +83 -0
- package/dist/codex/build/src/narrative/resolver.d.ts +52 -0
- package/dist/codex/build/src/narrative/resolver.js +190 -0
- package/dist/codex/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/codex/build/src/narrative/snapshot.js +325 -0
- package/dist/codex/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/codex/build/src/narrative/source-ids.js +201 -0
- package/dist/codex/build/src/narrative/statements.d.ts +84 -0
- package/dist/codex/build/src/narrative/statements.js +347 -0
- package/dist/codex/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/codex/build/src/narrative/turn-spine.js +73 -0
- package/dist/codex/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/codex/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/codex/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/codex/build/src/tools/validate-source-tree.js +5 -1
- package/dist/codex/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/codex/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/codex/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/codex/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/codex/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/codex/docs/context-map.md +4 -0
- package/dist/codex/docs/decisions/index.md +1 -0
- package/dist/codex/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/codex/docs/fixture-ownership.md +5 -1
- package/dist/codex/docs/migrations.md +20 -0
- package/dist/codex/docs/public-workflow-cli.md +9 -0
- package/dist/codex/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/codex/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/codex/docs/specs/economics-record-contract.md +1 -1
- package/dist/codex/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/codex/docs/workflow-usage-guide.md +4 -1
- package/dist/codex/evals/ci/run-baseline.sh +38 -0
- package/dist/codex/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/codex/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/codex/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/codex/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/codex/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/codex/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/codex/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/codex/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/codex/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/codex/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/codex/evals/integration/test_economics_record.sh +42 -0
- package/dist/codex/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/codex/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/codex/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/codex/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/codex/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/codex/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/codex/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/codex/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/codex/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/codex/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/codex/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/codex/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/codex/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/codex/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/codex/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/codex/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/codex/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/codex/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/codex/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/codex/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/codex/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/codex/evals/run.sh +12 -0
- package/dist/codex/evals/static/test_library_exports.sh +5 -0
- package/dist/codex/install.sh +1 -1
- package/dist/codex/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/codex/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/codex/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/codex/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/codex/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/codex/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/codex/scripts/hooks/workflow-steering.js +160 -19
- package/dist/codex/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/codex/scripts/telemetry/economics-record.sh +47 -3
- package/dist/codex/scripts/telemetry/lib/session.sh +3 -0
- package/dist/codex/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/codex/scripts/telemetry/telemetry.sh +480 -59
- package/dist/kiro/build/generated/capability-declarations.json +177 -0
- package/dist/kiro/build/package.json +1 -1
- package/dist/kiro/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/kiro/build/src/builder-flow-runtime.js +71 -1
- package/dist/kiro/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/kiro/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/kiro/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/kiro/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/kiro/build/src/cli/builder-run.js +71 -2
- package/dist/kiro/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/kiro/build/src/cli/narrative-render.js +466 -0
- package/dist/kiro/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/kiro/build/src/cli/narrative-sources.js +282 -0
- package/dist/kiro/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/kiro/build/src/cli/public-contracts.js +87 -0
- package/dist/kiro/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/kiro/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/kiro/build/src/cli/workflow.js +11 -1
- package/dist/kiro/build/src/cli.js +8 -0
- package/dist/kiro/build/src/continuation-driver.d.ts +12 -0
- package/dist/kiro/build/src/continuation-driver.js +16 -2
- package/dist/kiro/build/src/continuation-validation.js +349 -3
- package/dist/kiro/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/kiro/build/src/index.d.ts +33 -2
- package/dist/kiro/build/src/index.js +24 -0
- package/dist/kiro/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/kiro/build/src/lib/capability-declarations.js +209 -0
- package/dist/kiro/build/src/narrative/envelope.d.ts +111 -0
- package/dist/kiro/build/src/narrative/envelope.js +590 -0
- package/dist/kiro/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/kiro/build/src/narrative/eval-result.js +158 -0
- package/dist/kiro/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/kiro/build/src/narrative/grounding-validator.js +472 -0
- package/dist/kiro/build/src/narrative/integrity.d.ts +17 -0
- package/dist/kiro/build/src/narrative/integrity.js +39 -0
- package/dist/kiro/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/kiro/build/src/narrative/intent-economics.js +82 -0
- package/dist/kiro/build/src/narrative/intent.d.ts +94 -0
- package/dist/kiro/build/src/narrative/intent.js +132 -0
- package/dist/kiro/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/kiro/build/src/narrative/policy-filter.js +58 -0
- package/dist/kiro/build/src/narrative/projection.d.ts +58 -0
- package/dist/kiro/build/src/narrative/projection.js +502 -0
- package/dist/kiro/build/src/narrative/readers.d.ts +84 -0
- package/dist/kiro/build/src/narrative/readers.js +406 -0
- package/dist/kiro/build/src/narrative/render.d.ts +3 -0
- package/dist/kiro/build/src/narrative/render.js +83 -0
- package/dist/kiro/build/src/narrative/resolver.d.ts +52 -0
- package/dist/kiro/build/src/narrative/resolver.js +190 -0
- package/dist/kiro/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/kiro/build/src/narrative/snapshot.js +325 -0
- package/dist/kiro/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/kiro/build/src/narrative/source-ids.js +201 -0
- package/dist/kiro/build/src/narrative/statements.d.ts +84 -0
- package/dist/kiro/build/src/narrative/statements.js +347 -0
- package/dist/kiro/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/kiro/build/src/narrative/turn-spine.js +73 -0
- package/dist/kiro/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/kiro/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/kiro/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/kiro/build/src/tools/validate-source-tree.js +5 -1
- package/dist/kiro/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/kiro/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/kiro/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/kiro/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/kiro/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/kiro/docs/context-map.md +4 -0
- package/dist/kiro/docs/decisions/index.md +1 -0
- package/dist/kiro/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/kiro/docs/fixture-ownership.md +5 -1
- package/dist/kiro/docs/migrations.md +20 -0
- package/dist/kiro/docs/public-workflow-cli.md +9 -0
- package/dist/kiro/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/kiro/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/kiro/docs/specs/economics-record-contract.md +1 -1
- package/dist/kiro/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/kiro/docs/workflow-usage-guide.md +4 -1
- package/dist/kiro/evals/ci/run-baseline.sh +38 -0
- package/dist/kiro/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/kiro/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/kiro/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/kiro/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/kiro/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/kiro/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/kiro/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/kiro/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/kiro/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/kiro/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/kiro/evals/integration/test_economics_record.sh +42 -0
- package/dist/kiro/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/kiro/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/kiro/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/kiro/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/kiro/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/kiro/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/kiro/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/kiro/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/kiro/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/kiro/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/kiro/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/kiro/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/kiro/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/kiro/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/kiro/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/kiro/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/kiro/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/kiro/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/kiro/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/kiro/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/kiro/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/kiro/evals/run.sh +12 -0
- package/dist/kiro/evals/static/test_library_exports.sh +5 -0
- package/dist/kiro/install.sh +1 -1
- package/dist/kiro/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/kiro/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/kiro/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/kiro/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/kiro/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/kiro/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/kiro/scripts/hooks/workflow-steering.js +160 -19
- package/dist/kiro/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/kiro/scripts/telemetry/economics-record.sh +47 -3
- package/dist/kiro/scripts/telemetry/lib/session.sh +3 -0
- package/dist/kiro/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/kiro/scripts/telemetry/telemetry.sh +480 -59
- package/dist/opencode/build/generated/capability-declarations.json +177 -0
- package/dist/opencode/build/package.json +1 -1
- package/dist/opencode/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/opencode/build/src/builder-flow-runtime.js +71 -1
- package/dist/opencode/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/opencode/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/opencode/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/opencode/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/opencode/build/src/cli/builder-run.js +71 -2
- package/dist/opencode/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/opencode/build/src/cli/narrative-render.js +466 -0
- package/dist/opencode/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/opencode/build/src/cli/narrative-sources.js +282 -0
- package/dist/opencode/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/opencode/build/src/cli/public-contracts.js +87 -0
- package/dist/opencode/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/opencode/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/opencode/build/src/cli/workflow.js +11 -1
- package/dist/opencode/build/src/cli.js +8 -0
- package/dist/opencode/build/src/continuation-driver.d.ts +12 -0
- package/dist/opencode/build/src/continuation-driver.js +16 -2
- package/dist/opencode/build/src/continuation-validation.js +349 -3
- package/dist/opencode/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/opencode/build/src/index.d.ts +33 -2
- package/dist/opencode/build/src/index.js +24 -0
- package/dist/opencode/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/opencode/build/src/lib/capability-declarations.js +209 -0
- package/dist/opencode/build/src/narrative/envelope.d.ts +111 -0
- package/dist/opencode/build/src/narrative/envelope.js +590 -0
- package/dist/opencode/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/opencode/build/src/narrative/eval-result.js +158 -0
- package/dist/opencode/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/opencode/build/src/narrative/grounding-validator.js +472 -0
- package/dist/opencode/build/src/narrative/integrity.d.ts +17 -0
- package/dist/opencode/build/src/narrative/integrity.js +39 -0
- package/dist/opencode/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/opencode/build/src/narrative/intent-economics.js +82 -0
- package/dist/opencode/build/src/narrative/intent.d.ts +94 -0
- package/dist/opencode/build/src/narrative/intent.js +132 -0
- package/dist/opencode/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/opencode/build/src/narrative/policy-filter.js +58 -0
- package/dist/opencode/build/src/narrative/projection.d.ts +58 -0
- package/dist/opencode/build/src/narrative/projection.js +502 -0
- package/dist/opencode/build/src/narrative/readers.d.ts +84 -0
- package/dist/opencode/build/src/narrative/readers.js +406 -0
- package/dist/opencode/build/src/narrative/render.d.ts +3 -0
- package/dist/opencode/build/src/narrative/render.js +83 -0
- package/dist/opencode/build/src/narrative/resolver.d.ts +52 -0
- package/dist/opencode/build/src/narrative/resolver.js +190 -0
- package/dist/opencode/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/opencode/build/src/narrative/snapshot.js +325 -0
- package/dist/opencode/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/opencode/build/src/narrative/source-ids.js +201 -0
- package/dist/opencode/build/src/narrative/statements.d.ts +84 -0
- package/dist/opencode/build/src/narrative/statements.js +347 -0
- package/dist/opencode/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/opencode/build/src/narrative/turn-spine.js +73 -0
- package/dist/opencode/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/opencode/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/opencode/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/opencode/build/src/tools/validate-source-tree.js +5 -1
- package/dist/opencode/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/opencode/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/opencode/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/opencode/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/opencode/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/opencode/docs/context-map.md +4 -0
- package/dist/opencode/docs/decisions/index.md +1 -0
- package/dist/opencode/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/opencode/docs/fixture-ownership.md +5 -1
- package/dist/opencode/docs/migrations.md +20 -0
- package/dist/opencode/docs/public-workflow-cli.md +9 -0
- package/dist/opencode/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/opencode/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/opencode/docs/specs/economics-record-contract.md +1 -1
- package/dist/opencode/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/opencode/docs/workflow-usage-guide.md +4 -1
- package/dist/opencode/evals/ci/run-baseline.sh +38 -0
- package/dist/opencode/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/opencode/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/opencode/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/opencode/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/opencode/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/opencode/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/opencode/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/opencode/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/opencode/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/opencode/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/opencode/evals/integration/test_economics_record.sh +42 -0
- package/dist/opencode/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/opencode/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/opencode/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/opencode/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/opencode/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/opencode/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/opencode/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/opencode/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/opencode/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/opencode/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/opencode/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/opencode/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/opencode/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/opencode/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/opencode/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/opencode/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/opencode/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/opencode/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/opencode/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/opencode/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/opencode/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/opencode/evals/run.sh +12 -0
- package/dist/opencode/evals/static/test_library_exports.sh +5 -0
- package/dist/opencode/install.sh +1 -1
- package/dist/opencode/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/opencode/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/opencode/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/opencode/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/opencode/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/opencode/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/opencode/scripts/hooks/workflow-steering.js +160 -19
- package/dist/opencode/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/opencode/scripts/telemetry/economics-record.sh +47 -3
- package/dist/opencode/scripts/telemetry/lib/session.sh +3 -0
- package/dist/opencode/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/opencode/scripts/telemetry/telemetry.sh +480 -59
- package/dist/pi/build/generated/capability-declarations.json +177 -0
- package/dist/pi/build/package.json +1 -1
- package/dist/pi/build/src/builder-flow-runtime.d.ts +37 -0
- package/dist/pi/build/src/builder-flow-runtime.js +71 -1
- package/dist/pi/build/src/builder-gate-action-envelope.d.ts +59 -7
- package/dist/pi/build/src/builder-gate-action-envelope.js +163 -30
- package/dist/pi/build/src/builder-lifecycle-authority.d.ts +26 -0
- package/dist/pi/build/src/builder-lifecycle-authority.js +38 -0
- package/dist/pi/build/src/cli/builder-run.js +71 -2
- package/dist/pi/build/src/cli/narrative-render.d.ts +95 -0
- package/dist/pi/build/src/cli/narrative-render.js +466 -0
- package/dist/pi/build/src/cli/narrative-sources.d.ts +2 -0
- package/dist/pi/build/src/cli/narrative-sources.js +282 -0
- package/dist/pi/build/src/cli/public-contracts.d.ts +257 -0
- package/dist/pi/build/src/cli/public-contracts.js +87 -0
- package/dist/pi/build/src/cli/workflow-sidecar.d.ts +28 -12
- package/dist/pi/build/src/cli/workflow-sidecar.js +599 -180
- package/dist/pi/build/src/cli/workflow.js +11 -1
- package/dist/pi/build/src/cli.js +8 -0
- package/dist/pi/build/src/continuation-driver.d.ts +12 -0
- package/dist/pi/build/src/continuation-driver.js +16 -2
- package/dist/pi/build/src/continuation-validation.js +349 -3
- package/dist/pi/build/src/flow-kit/action-metadata.js +21 -1
- package/dist/pi/build/src/index.d.ts +33 -2
- package/dist/pi/build/src/index.js +24 -0
- package/dist/pi/build/src/lib/capability-declarations.d.ts +83 -0
- package/dist/pi/build/src/lib/capability-declarations.js +209 -0
- package/dist/pi/build/src/narrative/envelope.d.ts +111 -0
- package/dist/pi/build/src/narrative/envelope.js +590 -0
- package/dist/pi/build/src/narrative/eval-result.d.ts +60 -0
- package/dist/pi/build/src/narrative/eval-result.js +158 -0
- package/dist/pi/build/src/narrative/grounding-validator.d.ts +104 -0
- package/dist/pi/build/src/narrative/grounding-validator.js +472 -0
- package/dist/pi/build/src/narrative/integrity.d.ts +17 -0
- package/dist/pi/build/src/narrative/integrity.js +39 -0
- package/dist/pi/build/src/narrative/intent-economics.d.ts +42 -0
- package/dist/pi/build/src/narrative/intent-economics.js +82 -0
- package/dist/pi/build/src/narrative/intent.d.ts +94 -0
- package/dist/pi/build/src/narrative/intent.js +132 -0
- package/dist/pi/build/src/narrative/policy-filter.d.ts +15 -0
- package/dist/pi/build/src/narrative/policy-filter.js +58 -0
- package/dist/pi/build/src/narrative/projection.d.ts +58 -0
- package/dist/pi/build/src/narrative/projection.js +502 -0
- package/dist/pi/build/src/narrative/readers.d.ts +84 -0
- package/dist/pi/build/src/narrative/readers.js +406 -0
- package/dist/pi/build/src/narrative/render.d.ts +3 -0
- package/dist/pi/build/src/narrative/render.js +83 -0
- package/dist/pi/build/src/narrative/resolver.d.ts +52 -0
- package/dist/pi/build/src/narrative/resolver.js +190 -0
- package/dist/pi/build/src/narrative/snapshot.d.ts +90 -0
- package/dist/pi/build/src/narrative/snapshot.js +325 -0
- package/dist/pi/build/src/narrative/source-ids.d.ts +121 -0
- package/dist/pi/build/src/narrative/source-ids.js +201 -0
- package/dist/pi/build/src/narrative/statements.d.ts +84 -0
- package/dist/pi/build/src/narrative/statements.js +347 -0
- package/dist/pi/build/src/narrative/turn-spine.d.ts +19 -0
- package/dist/pi/build/src/narrative/turn-spine.js +73 -0
- package/dist/pi/build/src/tools/build-universal-bundles.js +8 -0
- package/dist/pi/build/src/tools/generate-capability-matrix.d.ts +7 -0
- package/dist/pi/build/src/tools/generate-capability-matrix.js +207 -0
- package/dist/pi/build/src/tools/validate-source-tree.js +5 -1
- package/dist/pi/context/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/pi/context/scripts/hooks/workflow-steering.js +160 -19
- package/dist/pi/context/scripts/telemetry/lib/session.sh +3 -0
- package/dist/pi/context/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/pi/context/scripts/telemetry/telemetry.sh +480 -59
- package/dist/pi/docs/context-map.md +4 -0
- package/dist/pi/docs/decisions/index.md +1 -0
- package/dist/pi/docs/decisions/writer-observed-execution.md +51 -0
- package/dist/pi/docs/fixture-ownership.md +5 -1
- package/dist/pi/docs/migrations.md +20 -0
- package/dist/pi/docs/public-workflow-cli.md +9 -0
- package/dist/pi/docs/spec/builder-flow-runtime.md +49 -8
- package/dist/pi/docs/spec/runtime-hook-surface.md +29 -1
- package/dist/pi/docs/specs/economics-record-contract.md +1 -1
- package/dist/pi/docs/specs/harness-capability-matrix.md +63 -21
- package/dist/pi/docs/workflow-usage-guide.md +4 -1
- package/dist/pi/evals/ci/run-baseline.sh +38 -0
- package/dist/pi/evals/fixtures/narrative-evals/README.md +62 -0
- package/dist/pi/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/dist/pi/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/dist/pi/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/dist/pi/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/dist/pi/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/dist/pi/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/dist/pi/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/dist/pi/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/dist/pi/evals/integration/test_capability_declarations.sh +183 -0
- package/dist/pi/evals/integration/test_economics_record.sh +42 -0
- package/dist/pi/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/dist/pi/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/dist/pi/evals/integration/test_goal_fit_hook.sh +13 -5
- package/dist/pi/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/dist/pi/evals/integration/test_narrative_evals.sh +174 -0
- package/dist/pi/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/dist/pi/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/dist/pi/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/dist/pi/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/dist/pi/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/dist/pi/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/dist/pi/evals/integration/test_narrative_source_contract.sh +228 -0
- package/dist/pi/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/dist/pi/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/dist/pi/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/dist/pi/evals/integration/test_telemetry_action_class.sh +265 -0
- package/dist/pi/evals/integration/test_telemetry_delegation.sh +291 -0
- package/dist/pi/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/dist/pi/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/dist/pi/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/dist/pi/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/dist/pi/evals/run.sh +12 -0
- package/dist/pi/evals/static/test_library_exports.sh +5 -0
- package/dist/pi/install.sh +1 -1
- package/dist/pi/schemas/grounded-execution-narrative.schema.json +292 -0
- package/dist/pi/schemas/narrative-eval-result.schema.json +205 -0
- package/dist/pi/schemas/narrative-runtime-projection.schema.json +134 -0
- package/dist/pi/schemas/narrative-source-manifest.schema.json +294 -0
- package/dist/pi/scripts/check-hachure-boundary.mjs +81 -0
- package/dist/pi/scripts/hooks/stop-goal-fit.js +182 -9
- package/dist/pi/scripts/hooks/workflow-steering.js +160 -19
- package/dist/pi/scripts/telemetry/economics-record.schema.json +1 -1
- package/dist/pi/scripts/telemetry/economics-record.sh +47 -3
- package/dist/pi/scripts/telemetry/lib/session.sh +3 -0
- package/dist/pi/scripts/telemetry/lib/transport.sh +12 -3
- package/dist/pi/scripts/telemetry/telemetry.sh +480 -59
- package/docs/context-map.md +4 -0
- package/docs/decisions/index.md +1 -0
- package/docs/decisions/writer-observed-execution.md +51 -0
- package/docs/fixture-ownership.md +5 -1
- package/docs/migrations.md +20 -0
- package/docs/public-workflow-cli.md +9 -0
- package/docs/spec/builder-flow-runtime.md +49 -8
- package/docs/spec/runtime-hook-surface.md +29 -1
- package/docs/specs/economics-record-contract.md +1 -1
- package/docs/specs/harness-capability-matrix.md +63 -21
- package/docs/workflow-usage-guide.md +4 -1
- package/evals/ci/run-baseline.sh +38 -0
- package/evals/fixtures/narrative-evals/README.md +62 -0
- package/evals/fixtures/narrative-evals/corpus.json +129 -0
- package/evals/fixtures/narrative-evals/scorer.mjs +522 -0
- package/evals/fixtures/narrative-grounding-validator/corpus.json +20 -0
- package/evals/fixtures/narrative-grounding-validator/prompt-injection-adversarial.txt +1 -0
- package/evals/fixtures/narrative-grounding-validator/prompt-injection-control.txt +1 -0
- package/evals/fixtures/narrative-grounding-validator/scorer.mjs +201 -0
- package/evals/fixtures/narrative-prose-renderer/corpus.json +15 -0
- package/evals/fixtures/narrative-prose-renderer/scorer.mjs +201 -0
- package/evals/fixtures/narrative-sources/expected-capture-completeness.json +13 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-fixture/report.json +1 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-fixture/state.json +1 -0
- package/evals/fixtures/narrative-sources/flow/runs/run-runtime/state.json +1 -0
- package/evals/fixtures/narrative-sources/repo/created.txt +1 -0
- package/evals/fixtures/narrative-sources/repo/fixture.txt +1 -0
- package/evals/fixtures/narrative-sources/session/agents/agent-fixture/events.jsonl +2 -0
- package/evals/fixtures/narrative-sources/session/agents/nested-worker/events.jsonl +1 -0
- package/evals/fixtures/narrative-sources/session/trust.bundle +1 -0
- package/evals/fixtures/narrative-sources/telemetry/full.jsonl +3 -0
- package/evals/fixtures/narrative-sources/telemetry/runtime.jsonl +4 -0
- package/evals/fixtures/narrative-sources/transcripts/session.txt +1 -0
- package/evals/integration/test_capability_declarations.sh +183 -0
- package/evals/integration/test_economics_record.sh +42 -0
- package/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/evals/integration/test_gate_review_inquiry_records.sh +42 -35
- package/evals/integration/test_goal_fit_hook.sh +13 -5
- package/evals/integration/test_goal_fit_narrative_exclusion.sh +68 -0
- package/evals/integration/test_narrative_evals.sh +174 -0
- package/evals/integration/test_narrative_grounded_envelope.sh +280 -0
- package/evals/integration/test_narrative_grounding_validator.sh +166 -0
- package/evals/integration/test_narrative_intent_annotation.sh +205 -0
- package/evals/integration/test_narrative_prose_renderer.sh +239 -0
- package/evals/integration/test_narrative_redaction_failclosed.sh +120 -0
- package/evals/integration/test_narrative_runtime_projection.sh +146 -0
- package/evals/integration/test_narrative_source_contract.sh +228 -0
- package/evals/integration/test_narrative_trust_isolation.sh +408 -0
- package/evals/integration/test_plain_stop_messaging.sh +91 -0
- package/evals/integration/test_session_resume_roundtrip.sh +228 -0
- package/evals/integration/test_telemetry_action_class.sh +265 -0
- package/evals/integration/test_telemetry_delegation.sh +291 -0
- package/evals/integration/test_telemetry_sanitize_usage.sh +155 -0
- package/evals/integration/test_telemetry_task_slug.sh +158 -0
- package/evals/integration/test_telemetry_tool_outcome.sh +279 -0
- package/evals/integration/test_workflow_sidecar_writer.sh +111 -2
- package/evals/run.sh +12 -0
- package/evals/static/test_library_exports.sh +5 -0
- package/package.json +9 -5
- package/schemas/grounded-execution-narrative.schema.json +292 -0
- package/schemas/narrative-eval-result.schema.json +205 -0
- package/schemas/narrative-runtime-projection.schema.json +134 -0
- package/schemas/narrative-source-manifest.schema.json +294 -0
- package/scripts/check-hachure-boundary.mjs +81 -0
- package/scripts/hooks/stop-goal-fit.js +182 -9
- package/scripts/hooks/workflow-steering.js +160 -19
- package/scripts/telemetry/economics-record.schema.json +1 -1
- package/scripts/telemetry/economics-record.sh +47 -3
- package/scripts/telemetry/lib/session.sh +3 -0
- package/scripts/telemetry/lib/transport.sh +12 -3
- package/scripts/telemetry/telemetry.sh +480 -59
- package/src/builder-flow-runtime.ts +102 -1
- package/src/builder-gate-action-envelope.ts +216 -37
- package/src/builder-lifecycle-authority.ts +48 -0
- package/src/cli/builder-flow-runtime.test.mjs +220 -7
- package/src/cli/builder-run.ts +71 -1
- package/src/cli/capability-declarations.test.mjs +117 -0
- package/src/cli/continuation-driver.test.mjs +332 -10
- package/src/cli/kit-metadata-security.test.mjs +90 -2
- package/src/cli/narrative-arch-isolation.test.mjs +198 -0
- package/src/cli/narrative-envelope.test.mjs +367 -0
- package/src/cli/narrative-grounding-validator.test.mjs +322 -0
- package/src/cli/narrative-intent.test.mjs +177 -0
- package/src/cli/narrative-policy-filter.test.mjs +66 -0
- package/src/cli/narrative-projection.test.mjs +236 -0
- package/src/cli/narrative-readers.test.mjs +196 -0
- package/src/cli/narrative-render.test.mjs +221 -0
- package/src/cli/narrative-render.ts +589 -0
- package/src/cli/narrative-resolver.test.mjs +114 -0
- package/src/cli/narrative-snapshot.test.mjs +149 -0
- package/src/cli/narrative-source-ids.test.mjs +84 -0
- package/src/cli/narrative-sources.ts +276 -0
- package/src/cli/narrative-statements.test.mjs +369 -0
- package/src/cli/narrative-turn-spine.test.mjs +74 -0
- package/src/cli/public-api.test.mjs +17 -0
- package/src/cli/public-contracts.ts +95 -0
- package/src/cli/sidecar-pure-helpers.test.mjs +216 -24
- package/src/cli/trust-bundle-policy-order.test.mjs +134 -1
- package/src/cli/workflow-sidecar.ts +563 -167
- package/src/cli/workflow.ts +15 -1
- package/src/cli/writer-observed-execution.test.mjs +102 -0
- package/src/cli.ts +8 -0
- package/src/continuation-driver.ts +32 -3
- package/src/continuation-validation.ts +362 -4
- package/src/flow-kit/action-metadata.ts +20 -1
- package/src/index.ts +241 -0
- package/src/lib/capability-declarations.ts +261 -0
- package/src/narrative/envelope.ts +624 -0
- package/src/narrative/eval-result.ts +175 -0
- package/src/narrative/grounding-validator.ts +610 -0
- package/src/narrative/integrity.ts +53 -0
- package/src/narrative/intent-economics.ts +119 -0
- package/src/narrative/intent.ts +216 -0
- package/src/narrative/policy-filter.ts +66 -0
- package/src/narrative/projection.ts +530 -0
- package/src/narrative/readers.ts +427 -0
- package/src/narrative/render.ts +82 -0
- package/src/narrative/resolver.ts +195 -0
- package/src/narrative/snapshot.ts +365 -0
- package/src/narrative/source-ids.ts +294 -0
- package/src/narrative/statements.ts +423 -0
- package/src/narrative/turn-spine.ts +99 -0
- package/src/tools/build-universal-bundles.ts +8 -0
- package/src/tools/generate-capability-matrix.ts +215 -0
- package/src/tools/validate-source-tree.ts +5 -1
- package/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/base/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/base/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/claude-code/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/claude-code/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/codex/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/codex/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/kiro/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/kiro/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/opencode/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/opencode/build/src/cli/sidecar-claim-explain.js +0 -87
- package/dist/pi/build/src/cli/sidecar-claim-explain.d.ts +0 -45
- package/dist/pi/build/src/cli/sidecar-claim-explain.js +0 -87
- package/src/cli/sidecar-claim-explain.ts +0 -130
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Grounded narrative faithfulness eval suite: one-command frozen corpus replay,
|
|
3
|
+
# schema-valid result emission, and the R3 scorer-teeth mutation battery (#612).
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
7
|
+
FIXTURES="$ROOT/evals/fixtures/narrative-evals"
|
|
8
|
+
SCORER="$FIXTURES/scorer.mjs"
|
|
9
|
+
TMP="$(mktemp -d)"
|
|
10
|
+
BACKUP="$TMP/scorer.mjs.original"
|
|
11
|
+
errors=0
|
|
12
|
+
|
|
13
|
+
_pass() { echo " ✓ $1"; }
|
|
14
|
+
_fail() { echo " ✗ $1"; errors=$((errors + 1)); }
|
|
15
|
+
restore_scorer() { if [[ -f "$BACKUP" ]]; then cp "$BACKUP" "$SCORER"; fi; }
|
|
16
|
+
cleanup() { restore_scorer; rm -rf "$TMP"; }
|
|
17
|
+
trap cleanup EXIT
|
|
18
|
+
|
|
19
|
+
echo "Narrative grounded evals integration"
|
|
20
|
+
if npm run build --silent; then _pass "TypeScript build completed"; else _fail "TypeScript build failed"; fi
|
|
21
|
+
cp "$SCORER" "$BACKUP"
|
|
22
|
+
|
|
23
|
+
# AC1: one command replays the whole frozen corpus and emits a schema-valid result.
|
|
24
|
+
if NARRATIVE_EVAL_RESULT_OUT="$TMP/result.json" node "$SCORER" all >"$TMP/scorer.out" 2>"$TMP/scorer.err"; then
|
|
25
|
+
_pass "AC1/AC2: frozen corpus meets every answer-key verdict"
|
|
26
|
+
else
|
|
27
|
+
_fail "corpus replay failed: $(cat "$TMP/scorer.out" "$TMP/scorer.err")"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
if grep -q 'fixture provenance: kontourai/flow-agents#612 narrative-evals-corpus/v1' "$TMP/scorer.out" \
|
|
31
|
+
&& grep -q 'scorer counts: accept=9 reject=5 known_gap=1 total=15' "$TMP/scorer.out" \
|
|
32
|
+
&& grep -q 'unsupported observed-claim rate=0' "$TMP/scorer.out" \
|
|
33
|
+
&& grep -q 'citation resolvability=1' "$TMP/scorer.out" \
|
|
34
|
+
&& grep -q 'material-claim coverage=1' "$TMP/scorer.out" \
|
|
35
|
+
&& grep -q 'epistemic classification accuracy=1' "$TMP/scorer.out"; then
|
|
36
|
+
_pass "R7/AC5: deterministic provenance, counts, and threshold lines present"
|
|
37
|
+
else
|
|
38
|
+
_fail "deterministic report is incomplete: $(cat "$TMP/scorer.out")"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# D8: the contradictory case is disclosed as a known_gap, never faked as detection.
|
|
42
|
+
if grep -q 'contradictory: expected=known_gap actual=known_gap' "$TMP/scorer.out"; then
|
|
43
|
+
_pass "D8: contradictory fixture recorded as a documented known_gap"
|
|
44
|
+
else
|
|
45
|
+
_fail "D8 contradictory fixture was not scored as a known_gap"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# AC3/R7: capability parity is DECLARED (queryCapability), not behavior-probed, for >=2 runtimes.
|
|
49
|
+
if grep -q 'capability parity: claude-code/intent_annotation=unsupported' "$TMP/scorer.out" \
|
|
50
|
+
&& grep -q 'capability parity: claude-code/per_delegation_trace_context=unsupported' "$TMP/scorer.out" \
|
|
51
|
+
&& grep -q 'capability parity: codex/intent_annotation=unsupported' "$TMP/scorer.out" \
|
|
52
|
+
&& grep -q 'capability parity: codex/per_delegation_trace_context=unsupported' "$TMP/scorer.out"; then
|
|
53
|
+
_pass "AC3/R7: declared capability parity emitted for claude-code and codex"
|
|
54
|
+
else
|
|
55
|
+
_fail "AC3 capability parity block is incomplete: $(cat "$TMP/scorer.out")"
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# R2/R6/AC6: the emitted result validates against the shipped schema in CI too.
|
|
59
|
+
if [[ -f "$TMP/result.json" ]] && node --input-type=module - "$ROOT" "$TMP/result.json" >"$TMP/schema.out" 2>&1 <<'NODE'
|
|
60
|
+
import { pathToFileURL } from 'node:url';
|
|
61
|
+
import path from 'node:path';
|
|
62
|
+
import fs from 'node:fs';
|
|
63
|
+
const [root, file] = process.argv.slice(2);
|
|
64
|
+
const api = await import(pathToFileURL(path.join(root, 'build/src/index.js')));
|
|
65
|
+
const value = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
66
|
+
if (value.schema_version !== 'narrative-eval-result/v1') { console.error('unexpected schema_version'); process.exit(1); }
|
|
67
|
+
const issues = api.validateNarrativeEvalResult(value);
|
|
68
|
+
if (issues.length > 0) { console.error(JSON.stringify(issues)); process.exit(1); }
|
|
69
|
+
// Negative control: a broken result must be rejected, proving the validator has teeth.
|
|
70
|
+
const broken = structuredClone(value); broken.metrics.unsupported_claim_rate = 2; broken.injected = true;
|
|
71
|
+
if (api.validateNarrativeEvalResult(broken).length === 0) { console.error('schema validator accepted a malformed result'); process.exit(1); }
|
|
72
|
+
NODE
|
|
73
|
+
then
|
|
74
|
+
_pass "R2/R6/AC6: emitted result validates against narrative-eval-result/v1 in-process and in CI"
|
|
75
|
+
else
|
|
76
|
+
_fail "emitted result failed schema validation: $(cat "$TMP/schema.out" 2>/dev/null || echo 'result.json missing')"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# R2 determinism: the emitted artifact must be byte-identical across runs (content-
|
|
80
|
+
# addressed fa1 ids must not leak the random temp path). Guards review finding HIGH-2.
|
|
81
|
+
NARRATIVE_EVAL_RESULT_OUT="$TMP/result-a.json" node "$SCORER" all >/dev/null 2>&1 || true
|
|
82
|
+
NARRATIVE_EVAL_RESULT_OUT="$TMP/result-b.json" node "$SCORER" all >/dev/null 2>&1 || true
|
|
83
|
+
if cmp -s "$TMP/result-a.json" "$TMP/result-b.json"; then
|
|
84
|
+
_pass "R2: emitted result is byte-identical across runs (deterministic artifact)"
|
|
85
|
+
else
|
|
86
|
+
_fail "emitted result is non-deterministic across runs: $(diff "$TMP/result-a.json" "$TMP/result-b.json" | head -5)"
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# HIGH-1 guard: material_claim_coverage must be COMPUTED from the canonical extraction,
|
|
90
|
+
# not a lockstep counter — removing a covering statement must drop covered below total.
|
|
91
|
+
if node --input-type=module - "$ROOT" >"$TMP/covteeth.out" 2>&1 <<'NODE'
|
|
92
|
+
import { pathToFileURL } from 'node:url';
|
|
93
|
+
import path from 'node:path';
|
|
94
|
+
import fs from 'node:fs';
|
|
95
|
+
import os from 'node:os';
|
|
96
|
+
import { createHash } from 'node:crypto';
|
|
97
|
+
const [root] = process.argv.slice(2);
|
|
98
|
+
const api = await import(pathToFileURL(path.join(root, 'build/src/index.js')));
|
|
99
|
+
const sha8 = (b) => createHash('sha256').update(b).digest('hex').slice(0, 8);
|
|
100
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'cov-teeth-'));
|
|
101
|
+
const sessionDir = path.join(temp, 'session'); const narrativeDir = path.join(temp, 'narrative');
|
|
102
|
+
fs.mkdirSync(sessionDir, { recursive: true });
|
|
103
|
+
const line = JSON.stringify({ command: 'npm test', result: 'fail', exitCode: 1 });
|
|
104
|
+
fs.writeFileSync(path.join(sessionDir, 'command-log.jsonl'), `${line}\n`);
|
|
105
|
+
const ref = `fa1:cmdlog:session:line-1/${sha8(Buffer.from(line))}`;
|
|
106
|
+
const at = '2026-01-01T00:00:00.000Z';
|
|
107
|
+
api.snapshotNarrative({ narrativeDir, narrativeId: 'cov', requests: [{ source: api.parseSourceId(ref), roots: { sessionDir } }], redactionFields: [], compiler: { name: 'cov', version: '1', policy_hash: 'fixture' }, captureCompleteness: { channels: { full: 'active' }, known_gaps: [] } }, { now: () => at });
|
|
108
|
+
const full = api.composeGroundedNarrative(narrativeDir, { compiledAt: at });
|
|
109
|
+
const covFull = api.materialEventCoverage(full, narrativeDir);
|
|
110
|
+
const stripped = JSON.parse(JSON.stringify(full));
|
|
111
|
+
const rt = stripped.sections.find((s) => s.authority === 'flow-agents' && s.kind === 'runtime-projection');
|
|
112
|
+
rt.embedded.turns = rt.embedded.turns.map((t) => ({ ...t, statements: t.statements.filter((s) => !/was observed to fail/.test(s.proposition)) }));
|
|
113
|
+
rt.embedded.document_statements = rt.embedded.document_statements.filter((s) => !/was observed to fail/.test(s.proposition));
|
|
114
|
+
const covStripped = api.materialEventCoverage(stripped, narrativeDir);
|
|
115
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
116
|
+
if (!(covFull.total >= 1 && covFull.covered === covFull.total && covStripped.total === covFull.total && covStripped.covered < covStripped.total)) {
|
|
117
|
+
console.error(`coverage metric has no teeth: full=${covFull.covered}/${covFull.total} stripped=${covStripped.covered}/${covStripped.total}`); process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
NODE
|
|
120
|
+
then
|
|
121
|
+
_pass "HIGH-1: material_claim_coverage is computed from the canonical extraction (drops when coverage is removed)"
|
|
122
|
+
else
|
|
123
|
+
_fail "material_claim_coverage does not react to removed coverage: $(cat "$TMP/covteeth.out")"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# R3/AC2: the mutation battery. For EACH corruption class, disable the scorer's
|
|
127
|
+
# detection at its named /* eval-check:<name> */ anchor, confirm the compiled
|
|
128
|
+
# scorer still parses, confirm the matching reject fixture flips to accept
|
|
129
|
+
# (teeth), then restore byte-for-byte and confirm the corpus rejects it again.
|
|
130
|
+
mutation_test() {
|
|
131
|
+
local check="$1" anchor="$2" call="$3" fixture="$4"
|
|
132
|
+
restore_scorer
|
|
133
|
+
node - "$SCORER" "$anchor" "$call" <<'NODE'
|
|
134
|
+
const fs = require('fs');
|
|
135
|
+
const [file, anchor, call] = process.argv.slice(2);
|
|
136
|
+
let text = fs.readFileSync(file, 'utf8');
|
|
137
|
+
const needle = `${anchor}\n ${call}`;
|
|
138
|
+
if (!text.includes(needle)) throw new Error(`mutation target missing: ${needle}`);
|
|
139
|
+
text = text.replace(needle, `${anchor}\n // mutation: check deliberately disabled`);
|
|
140
|
+
fs.writeFileSync(file, text);
|
|
141
|
+
NODE
|
|
142
|
+
if ! node --check "$SCORER" >/dev/null; then
|
|
143
|
+
_fail "${check} mutation produced invalid JavaScript"
|
|
144
|
+
elif node "$SCORER" "$check" >"$TMP/mutation-$check.out" 2>"$TMP/mutation-$check.err"; then
|
|
145
|
+
_fail "${check} scorer still passed after its detection was disabled"
|
|
146
|
+
elif grep -q "${fixture}: expected=reject actual=accept" "$TMP/mutation-$check.out"; then
|
|
147
|
+
_pass "scorer teeth: disabling ${check} flips ${fixture} reject to accept"
|
|
148
|
+
else
|
|
149
|
+
_fail "${check} mutation failed for an unrelated reason: $(cat "$TMP/mutation-$check.out" "$TMP/mutation-$check.err")"
|
|
150
|
+
fi
|
|
151
|
+
restore_scorer
|
|
152
|
+
if cmp -s "$BACKUP" "$SCORER" && node "$SCORER" "$check" >/dev/null 2>&1; then
|
|
153
|
+
_pass "${check} detection restored byte-for-byte and the corpus rejects again"
|
|
154
|
+
else
|
|
155
|
+
_fail "${check} detection did not restore cleanly"
|
|
156
|
+
fi
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
mutation_test support '/* eval-check:support */' 'supportCheck(state, statements);' hallucinated-statement
|
|
160
|
+
mutation_test citation '/* eval-check:citation */' 'citationCheck(state, verdict);' dangling-citation
|
|
161
|
+
mutation_test coverage '/* eval-check:coverage */' 'coverageCheck(state, verdict);' omitted-failure
|
|
162
|
+
mutation_test epistemic '/* eval-check:epistemic */' 'epistemicCheck(state, verdict);' mislabeled-inference
|
|
163
|
+
mutation_test injection '/* eval-check:injection */' 'injectionCheck(state, injection);' injection-followed
|
|
164
|
+
|
|
165
|
+
restore_scorer
|
|
166
|
+
cmp -s "$BACKUP" "$SCORER" || _fail "scorer was not restored after the mutation battery"
|
|
167
|
+
|
|
168
|
+
echo ""
|
|
169
|
+
if [[ "$errors" -eq 0 ]]; then
|
|
170
|
+
echo "narrative grounded evals tests passed: 15/15."
|
|
171
|
+
exit 0
|
|
172
|
+
fi
|
|
173
|
+
echo "narrative grounded evals tests FAILED: $errors issue(s)."
|
|
174
|
+
exit 1
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Frozen authorities compose into a deterministic, grounded execution narrative.
|
|
3
|
+
set -uo pipefail
|
|
4
|
+
|
|
5
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
6
|
+
FIXTURES="$ROOT/evals/fixtures/narrative-sources"
|
|
7
|
+
TMP="$(mktemp -d)"
|
|
8
|
+
errors=0
|
|
9
|
+
_pass() { echo " ✓ $1"; }
|
|
10
|
+
_fail() { echo " ✗ $1"; errors=$((errors + 1)); }
|
|
11
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
12
|
+
|
|
13
|
+
sha256_file() { node -e "const fs=require('fs'),c=require('crypto');process.stdout.write(c.createHash('sha256').update(fs.readFileSync(process.argv[1])).digest('hex'))" "$1"; }
|
|
14
|
+
sha8_line() { node -e "const fs=require('fs'),c=require('crypto');const l=fs.readFileSync(process.argv[1],'utf8').trimEnd().split(/\\r?\\n/)[Number(process.argv[2])];process.stdout.write(c.createHash('sha256').update(l).digest('hex').slice(0,8))" "$1" "$2"; }
|
|
15
|
+
telemetry_pin() { node -e "const fs=require('fs'),c=require('crypto');const l=fs.readFileSync(process.argv[1],'utf8').split('\\n').find(x=>x.trim()&&JSON.parse(x).event_id===process.argv[2]);process.stdout.write(c.createHash('sha256').update(l).digest('hex').slice(0,8))" "$1" "$2"; }
|
|
16
|
+
json_assert() {
|
|
17
|
+
node - "$1" "$2" <<'NODE'
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const value = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
|
|
20
|
+
if (!Function('value', `return Boolean(${process.argv[3]})`)(value)) process.exit(1);
|
|
21
|
+
NODE
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
echo "Narrative grounded envelope integration"
|
|
25
|
+
if npm run build --silent; then _pass "TypeScript build completed"; else _fail "TypeScript build failed"; fi
|
|
26
|
+
|
|
27
|
+
RAW="$TMP/raw"
|
|
28
|
+
ARTIFACT_ROOT="$TMP/artifacts"
|
|
29
|
+
SESSION="$RAW/fixture-session"
|
|
30
|
+
AGENTS_DIR="$SESSION/agents"
|
|
31
|
+
NESTED_EVENTS="$AGENTS_DIR/nested-worker/events.jsonl"
|
|
32
|
+
TELEMETRY="$RAW/telemetry"
|
|
33
|
+
FLOW="$RAW/flow"
|
|
34
|
+
REPO="$RAW/repo"
|
|
35
|
+
TRANSCRIPT="$RAW/canary.txt"
|
|
36
|
+
mkdir -p "$RAW"
|
|
37
|
+
cp -R "$FIXTURES/session" "$SESSION"
|
|
38
|
+
cp -R "$FIXTURES/telemetry" "$TELEMETRY"
|
|
39
|
+
cp -R "$FIXTURES/flow" "$FLOW"
|
|
40
|
+
cp -R "$FIXTURES/repo" "$REPO"
|
|
41
|
+
printf '%s\n' 'AC6_CANARY' >"$TRANSCRIPT"
|
|
42
|
+
|
|
43
|
+
# A foreign authority blob containing a configured sensitive key must be
|
|
44
|
+
# unavailable as a whole. Its verbatim bytes must never reach the snapshot.
|
|
45
|
+
FOREIGN_REPORT_FILE="$FLOW/runs/run-redacted/report.json"
|
|
46
|
+
mkdir -p "$(dirname "$FOREIGN_REPORT_FILE")"
|
|
47
|
+
printf '%s\n' '{"run_id":"run-redacted","nested":{"foreignSecret":"AC6_CANARY"}}' >"$FOREIGN_REPORT_FILE"
|
|
48
|
+
|
|
49
|
+
# Add one attributed nested-worker event beside the fixture's lineage-less event.
|
|
50
|
+
printf '%s\n' '{"kind":"delegation","at":"2026-07-14T13:00:03.000Z","target":"attributed-leaf","task":"attributed fixture","lineage":{"actor":"nested-worker"}}' >>"$NESTED_EVENTS"
|
|
51
|
+
|
|
52
|
+
# Genuine chained observations preserve fail -> retry.
|
|
53
|
+
node - "$ROOT/scripts/lib/command-log-chain.js" "$SESSION/command-log.jsonl" <<'NODE'
|
|
54
|
+
const fs = require('fs');
|
|
55
|
+
const chain = require(process.argv[2]);
|
|
56
|
+
const records = [
|
|
57
|
+
{ command: 'npm test', result: 'fail', exitCode: 1, capturedAt: '2026-07-14T13:00:04.000Z', source: 'narrative-envelope-fixture' },
|
|
58
|
+
{ command: 'npm test', result: 'pass', exitCode: 0, capturedAt: '2026-07-14T13:00:05.000Z', source: 'narrative-envelope-fixture' },
|
|
59
|
+
];
|
|
60
|
+
let previous = chain.CHAIN_GENESIS;
|
|
61
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
62
|
+
const record = records[index];
|
|
63
|
+
const hash = chain.computeChainHash(previous, record);
|
|
64
|
+
record._chain = { seq: index, prevHash: previous, hash };
|
|
65
|
+
previous = hash;
|
|
66
|
+
}
|
|
67
|
+
fs.writeFileSync(process.argv[3], records.map(JSON.stringify).join('\n') + '\n');
|
|
68
|
+
NODE
|
|
69
|
+
|
|
70
|
+
CMD0="$(node -e "const r=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8').split('\\n')[0]);process.stdout.write(r._chain.hash.slice(0,8))" "$SESSION/command-log.jsonl")"
|
|
71
|
+
CMD1="$(node -e "const r=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8').split('\\n')[1]);process.stdout.write(r._chain.hash.slice(0,8))" "$SESSION/command-log.jsonl")"
|
|
72
|
+
NESTED0="$(sha8_line "$NESTED_EVENTS" 0)"
|
|
73
|
+
NESTED1="$(sha8_line "$NESTED_EVENTS" 1)"
|
|
74
|
+
FLOW_STATE="$(sha256_file "$FLOW/runs/run-runtime/state.json")"; FLOW_STATE="${FLOW_STATE:0:8}"
|
|
75
|
+
FLOW_REPORT="$(sha256_file "$FLOW/runs/run-fixture/report.json")"; FLOW_REPORT="${FLOW_REPORT:0:8}"
|
|
76
|
+
FOREIGN_REPORT="$(sha256_file "$FOREIGN_REPORT_FILE")"; FOREIGN_REPORT="${FOREIGN_REPORT:0:8}"
|
|
77
|
+
BUNDLE="$(sha256_file "$SESSION/trust.bundle")"; BUNDLE="${BUNDLE:0:8}"
|
|
78
|
+
FILE_SHA="$(sha256_file "$REPO/created.txt")"
|
|
79
|
+
MISSING_SHA="$(printf 'missing fixture' | node -e "const c=require('crypto');let d='';process.stdin.on('data',x=>d+=x).on('end',()=>process.stdout.write(c.createHash('sha256').update(d).digest('hex')))")"
|
|
80
|
+
PATH_HASH="$(node -e "const c=require('crypto'),p=require('path');process.stdout.write(c.createHash('sha256').update(p.resolve(process.argv[1])).digest('hex').slice(0,8))" "$TRANSCRIPT")"
|
|
81
|
+
TURN="$(telemetry_pin "$TELEMETRY/runtime.jsonl" runtime-turn-explicit)"
|
|
82
|
+
TIMEOUT="$(telemetry_pin "$TELEMETRY/runtime.jsonl" runtime-tool-timeout)"
|
|
83
|
+
DERIVED="$(telemetry_pin "$TELEMETRY/runtime.jsonl" runtime-turn-derived)"
|
|
84
|
+
END="$(telemetry_pin "$TELEMETRY/runtime.jsonl" runtime-session-end)"
|
|
85
|
+
MCP="$(telemetry_pin "$TELEMETRY/full.jsonl" evt-mcp-gap)"
|
|
86
|
+
|
|
87
|
+
SOURCES=(
|
|
88
|
+
"fa1:telemetry:runtime/runtime-session:runtime-turn-explicit/$TURN"
|
|
89
|
+
"fa1:telemetry:runtime/runtime-session:runtime-tool-timeout/$TIMEOUT"
|
|
90
|
+
"fa1:flow-state:run-runtime:state/$FLOW_STATE"
|
|
91
|
+
"fa1:flow-report:run-fixture:report/$FLOW_REPORT"
|
|
92
|
+
"fa1:flow-report:run-redacted:report/$FOREIGN_REPORT"
|
|
93
|
+
"fa1:surface-explanation:fixture-session/$BUNDLE:claim-fixture"
|
|
94
|
+
"fa1:delegation:fixture-session/nested-worker:0/$NESTED0"
|
|
95
|
+
"fa1:delegation:fixture-session/nested-worker:1/$NESTED1"
|
|
96
|
+
"fa1:telemetry:runtime/runtime-session:runtime-turn-derived/$DERIVED"
|
|
97
|
+
"fa1:telemetry:runtime/runtime-session:runtime-session-end/$END"
|
|
98
|
+
"fa1:cmdlog:fixture-session:0/$CMD0"
|
|
99
|
+
"fa1:cmdlog:fixture-session:1/$CMD1"
|
|
100
|
+
"fa1:file:created.txt:$FILE_SHA"
|
|
101
|
+
"fa1:file:missing.txt:$MISSING_SHA"
|
|
102
|
+
"fa1:telemetry:full/session-fixture:evt-mcp-gap/$MCP"
|
|
103
|
+
"fa1:transcript:$PATH_HASH:0-$(wc -c <"$TRANSCRIPT" | tr -d ' ')"
|
|
104
|
+
)
|
|
105
|
+
ARGS=(narrative-sources snapshot --artifact-root "$ARTIFACT_ROOT" --narrative-id grounded-fixture
|
|
106
|
+
--telemetry-root "$TELEMETRY" --session-root "$SESSION" --flow-root "$FLOW" --repo-root "$REPO"
|
|
107
|
+
--transcript-path "$TRANSCRIPT" --redact-fields foreignSecret
|
|
108
|
+
--capture-completeness "$FIXTURES/expected-capture-completeness.json")
|
|
109
|
+
for source in "${SOURCES[@]}"; do ARGS+=(--source "$source"); done
|
|
110
|
+
|
|
111
|
+
export https_proxy=http://127.0.0.1:9 http_proxy=http://127.0.0.1:9 HTTPS_PROXY=http://127.0.0.1:9 HTTP_PROXY=http://127.0.0.1:9 NO_PROXY='*'
|
|
112
|
+
if node "$ROOT/build/src/cli.js" "${ARGS[@]}" >"$TMP/snapshot.json" 2>"$TMP/snapshot.err"; then _pass "AC9: snapshot succeeds with network disabled"; else _fail "snapshot failed: $(<"$TMP/snapshot.err")"; fi
|
|
113
|
+
|
|
114
|
+
NARRATIVE_DIR="$ARTIFACT_ROOT/.kontourai/narrative/grounded-fixture"
|
|
115
|
+
OUT1="$TMP/out-one"; OUT2="$TMP/out-two"
|
|
116
|
+
COMPILED_AT="2026-07-14T16:00:00.000Z"
|
|
117
|
+
if node "$ROOT/build/src/cli.js" narrative-sources compose --narrative-dir "$NARRATIVE_DIR" --compiled-at "$COMPILED_AT" --out-dir "$OUT1" --render >"$TMP/compose-one.json" 2>"$TMP/compose-one.err"; then _pass "AC1/AC9: compose validates and renders offline"; else _fail "compose failed: $(<"$TMP/compose-one.err")"; fi
|
|
118
|
+
if node "$ROOT/build/src/cli.js" narrative-sources compose --narrative-dir "$NARRATIVE_DIR" --compiled-at "$COMPILED_AT" --out-dir "$OUT2" --render >"$TMP/compose-two.json" 2>"$TMP/compose-two.err"; then _pass "AC7: second pinned compile succeeds"; else _fail "second compose failed: $(<"$TMP/compose-two.err")"; fi
|
|
119
|
+
ENVELOPE1="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync(process.argv[1])).envelopePath)" "$TMP/compose-one.json")"
|
|
120
|
+
RENDER1="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync(process.argv[1])).renderPath)" "$TMP/compose-one.json")"
|
|
121
|
+
ENVELOPE2="$(node -e "process.stdout.write(JSON.parse(require('fs').readFileSync(process.argv[1])).envelopePath)" "$TMP/compose-two.json")"
|
|
122
|
+
|
|
123
|
+
if cmp -s "$ENVELOPE1" "$ENVELOPE2"; then _pass "AC7: identical compiled-at produces byte-identical envelopes"; else _fail "AC7: deterministic envelopes differ"; fi
|
|
124
|
+
if json_assert "$ENVELOPE1" 'value.schema_version === "grounded-execution-narrative/v1" && ["manifest_sha256","schema_sha256","config_sha256","compiler_sha256"].every(k => /^[0-9a-f]{64}$/.test(value.provenance[k]))'; then _pass "AC1/AC7: schema and provenance hashes are present"; else _fail "AC1/AC7: envelope provenance is incomplete"; fi
|
|
125
|
+
if json_assert "$ENVELOPE1" 'JSON.stringify(value.sections.find(s=>s.authority==="flow-agents").embedded).includes("was observed to fail") && JSON.stringify(value).includes("was retried across 2 attempts") && JSON.stringify(value).includes("30000 ms timeout") && JSON.stringify(value).includes("classified as a no-op") && JSON.stringify(value).includes("created.txt")'; then _pass "AC3: failure, retry, timeout, no-op, and created-file facts survive"; else _fail "AC3: material runtime fact was dropped"; fi
|
|
126
|
+
if json_assert "$ENVELOPE1" 'JSON.stringify(value).includes("nested-worker") && [...value.sections.find(s=>s.authority==="flow-agents").embedded.turns.flatMap(t=>t.statements),...value.sections.find(s=>s.authority==="flow-agents").embedded.document_statements].some(s=>s.actor==="unattributed")'; then _pass "AC5: attributed and unattributed multi-agent facts survive"; else _fail "AC5: agent attribution disclosure is incomplete"; fi
|
|
127
|
+
if ! grep -R -q 'AC6_CANARY' "$NARRATIVE_DIR" "$OUT1" "$OUT2" \
|
|
128
|
+
&& grep -q 'redacted' "$RENDER1" \
|
|
129
|
+
&& node - "$NARRATIVE_DIR/source-manifest.json" "${SOURCES[4]}" <<'NODE'
|
|
130
|
+
const fs=require('fs'); const manifest=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
131
|
+
const entry=manifest.sources.find(source=>source.source_id===process.argv[3]);
|
|
132
|
+
if (!entry || entry.status!=='unavailable' || entry.unavailable_reason!=='redacted' || entry.sha256!==undefined) process.exit(1);
|
|
133
|
+
NODE
|
|
134
|
+
then _pass "AC6: foreign authority canary is wholly unavailable/redacted and absent"; else _fail "AC6: foreign authority canary leaked or was partially captured"; fi
|
|
135
|
+
|
|
136
|
+
# Every reference either resolves hash-verified or is the manifest-declared unavailable source.
|
|
137
|
+
if node --input-type=module - "$NARRATIVE_DIR" "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
138
|
+
import fs from 'node:fs';
|
|
139
|
+
const dir=process.argv[2], env=JSON.parse(fs.readFileSync(process.argv[3])), api=await import(`file://${process.argv[4]}`);
|
|
140
|
+
const manifest=JSON.parse(fs.readFileSync(`${dir}/source-manifest.json`));
|
|
141
|
+
const unavailable=new Set(manifest.sources.filter(s=>s.status==='unavailable').map(s=>s.source_id));
|
|
142
|
+
const refs=new Set(JSON.stringify(env).match(/fa1:[A-Za-z0-9%._~:/#-]+/g)??[]);
|
|
143
|
+
for (const ref of refs) { const r=api.resolveSource(dir,ref); if (r.status!=='resolved' && !unavailable.has(ref)) process.exit(1); }
|
|
144
|
+
NODE
|
|
145
|
+
then _pass "AC1: factual references resolve or carry declared unavailability"; else _fail "AC1: unresolved factual reference"; fi
|
|
146
|
+
|
|
147
|
+
# Removing grounding must fail the public validator.
|
|
148
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
149
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2])); delete env.conclusions[0].grounding;
|
|
150
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
151
|
+
NODE
|
|
152
|
+
then _pass "AC4: grounding-less conclusion is rejected"; else _fail "AC4: grounding-less conclusion validated"; fi
|
|
153
|
+
|
|
154
|
+
# A syntactically valid but nonexistent authority ref must not ground a
|
|
155
|
+
# conclusion, even when another section of that authority exists.
|
|
156
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
157
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
158
|
+
env.conclusions[0].grounding={kind:'flow_gate_derivation',source_ref:'fa1:flow-report:missing:report/00000000',pointer:'/gates/0'};
|
|
159
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
160
|
+
NODE
|
|
161
|
+
then _pass "AC4: nonexistent grounding source_ref is rejected"; else _fail "AC4: nonexistent grounding source_ref validated"; fi
|
|
162
|
+
|
|
163
|
+
# A grounding pointer must RFC6901-resolve within the exact frozen Flow blob.
|
|
164
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
165
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
166
|
+
const conclusion=env.conclusions.find(item=>item.grounding?.kind==='flow_gate_derivation');
|
|
167
|
+
if (!conclusion) process.exit(1);
|
|
168
|
+
conclusion.grounding.pointer='/definitely/not/present';
|
|
169
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
170
|
+
NODE
|
|
171
|
+
then _pass "AC4: nonexistent RFC6901 grounding pointer is rejected"; else _fail "AC4: nonexistent grounding pointer validated"; fi
|
|
172
|
+
|
|
173
|
+
# An existing Flow pointer is still invalid grounding unless its resolved value
|
|
174
|
+
# has the typed gate-summary shape consumed by the derivation.
|
|
175
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
176
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
177
|
+
const conclusion=env.conclusions.find(item=>item.grounding?.kind==='flow_gate_derivation');
|
|
178
|
+
if (!conclusion) process.exit(1);
|
|
179
|
+
conclusion.grounding.pointer='/run_id';
|
|
180
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
181
|
+
NODE
|
|
182
|
+
then _pass "AC4: existing non-gate Flow pointer is rejected"; else _fail "AC4: non-gate Flow pointer validated"; fi
|
|
183
|
+
|
|
184
|
+
# A proposition is a deterministic derivation of its Flow gate fields, not
|
|
185
|
+
# caller-supplied prose, even when its source and pointer otherwise validate.
|
|
186
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
187
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
188
|
+
const conclusion=env.conclusions.find(item=>item.grounding?.kind==='flow_gate_derivation');
|
|
189
|
+
if (!conclusion) process.exit(1);
|
|
190
|
+
conclusion.proposition='Gate result was replaced with free prose.';
|
|
191
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
192
|
+
NODE
|
|
193
|
+
then _pass "AC4: mismatched Flow proposition is rejected"; else _fail "AC4: mismatched Flow proposition validated"; fi
|
|
194
|
+
|
|
195
|
+
# Surface conclusions carry the same deterministic proposition discipline.
|
|
196
|
+
if node --input-type=module - "$ENVELOPE1" "$ROOT/build/src/index.js" <<'NODE'
|
|
197
|
+
import fs from 'node:fs'; const env=JSON.parse(fs.readFileSync(process.argv[2]));
|
|
198
|
+
const conclusion=env.conclusions.find(item=>item.grounding?.kind==='surface_explanation');
|
|
199
|
+
if (!conclusion) process.exit(1);
|
|
200
|
+
conclusion.proposition='Claim result was replaced with free prose.';
|
|
201
|
+
const api=await import(`file://${process.argv[3]}`); process.exit(api.validateGroundedNarrative(env).length ? 0 : 1);
|
|
202
|
+
NODE
|
|
203
|
+
then _pass "AC4: mismatched Surface proposition is rejected"; else _fail "AC4: mismatched Surface proposition validated"; fi
|
|
204
|
+
|
|
205
|
+
# A timezone-invalid window must retain the telemetry refs that made it
|
|
206
|
+
# unusable so the no_timezone derivation has complete, inspectable inputs.
|
|
207
|
+
if node --input-type=module - "$TMP/timezone-correlation" "$ROOT/build/src/index.js" <<'NODE'
|
|
208
|
+
import { createHash } from 'node:crypto';
|
|
209
|
+
import fs from 'node:fs';
|
|
210
|
+
import path from 'node:path';
|
|
211
|
+
const root=process.argv[2], api=await import(`file://${process.argv[3]}`);
|
|
212
|
+
const narrativeDir=path.join(root,'narrative'), telemetryDir=path.join(root,'telemetry'), flowRoot=path.join(root,'flow');
|
|
213
|
+
fs.mkdirSync(telemetryDir,{recursive:true}); fs.mkdirSync(path.join(flowRoot,'runs','timezone-run'),{recursive:true});
|
|
214
|
+
const telemetry=[
|
|
215
|
+
{session_id:'timezone-session',event_id:'turn-start',event_type:'turn.user',timestamp:'2026-07-14T13:00:00.000',hook:{turn_id:'turn-one'}},
|
|
216
|
+
{session_id:'timezone-session',event_id:'turn-end',event_type:'tool.result',timestamp:'2026-07-14T13:00:20.000',hook:{turn_id:'turn-one'},tool:{name:'read'}},
|
|
217
|
+
];
|
|
218
|
+
const lines=telemetry.map(JSON.stringify);
|
|
219
|
+
fs.writeFileSync(path.join(telemetryDir,'full.jsonl'),`${lines.join('\n')}\n`);
|
|
220
|
+
const stateBytes=Buffer.from(JSON.stringify({run_id:'timezone-run',session_id:'timezone-session',transitions:[{from:'planned',to:'executing',at:'2026-07-14T13:00:10.000Z'}]}));
|
|
221
|
+
const reportBytes=Buffer.from(JSON.stringify({run_id:'timezone-run',gate_summaries:[]}));
|
|
222
|
+
fs.writeFileSync(path.join(flowRoot,'runs','timezone-run','state.json'),stateBytes);
|
|
223
|
+
fs.writeFileSync(path.join(flowRoot,'runs','timezone-run','report.json'),reportBytes);
|
|
224
|
+
const sha8=bytes=>createHash('sha256').update(bytes).digest('hex').slice(0,8);
|
|
225
|
+
const telemetryRefs=telemetry.map((event,index)=>`fa1:telemetry:full/timezone-session:${event.event_id}/${sha8(Buffer.from(lines[index]))}`);
|
|
226
|
+
const requests=telemetryRefs.map(sourceId=>({source:api.parseSourceId(sourceId),roots:{telemetryDir}}));
|
|
227
|
+
requests.push(
|
|
228
|
+
{source:api.parseSourceId(`fa1:flow-state:timezone-run:state/${sha8(stateBytes)}`),roots:{flowRoot}},
|
|
229
|
+
{source:api.parseSourceId(`fa1:flow-report:timezone-run:report/${sha8(reportBytes)}`),roots:{flowRoot}},
|
|
230
|
+
);
|
|
231
|
+
api.snapshotNarrative({
|
|
232
|
+
narrativeDir,narrativeId:'timezone-correlation',requests,redactionFields:[],
|
|
233
|
+
compiler:{name:'grounded-envelope-integration',version:'1',policy_hash:'fixture'},
|
|
234
|
+
captureCompleteness:{channels:{full:'active'},known_gaps:[]},
|
|
235
|
+
},{now:()=> '2026-07-14T15:00:00.000Z'});
|
|
236
|
+
const envelope=api.composeGroundedNarrative(narrativeDir,{compiledAt:'2026-07-14T16:00:00.000Z'});
|
|
237
|
+
const unplaced=envelope.correlation.unplaced.filter(item=>item.reason==='no_timezone');
|
|
238
|
+
if (unplaced.length!==1) process.exit(1);
|
|
239
|
+
if (!telemetryRefs.every(ref=>unplaced.every(item=>item.rule.inputs.includes(ref)))) process.exit(1);
|
|
240
|
+
NODE
|
|
241
|
+
then _pass "AC correlation: no_timezone rule inputs retain offending telemetry refs"; else _fail "AC correlation: no_timezone rule inputs omit offending telemetry refs"; fi
|
|
242
|
+
|
|
243
|
+
# Extract the JSON string without normalization, then compare its decoded bytes
|
|
244
|
+
# directly to the content-addressed authority blob. Also prove all three hashes
|
|
245
|
+
# (section, manifest, and raw bytes) agree.
|
|
246
|
+
if node - "$NARRATIVE_DIR" "$ENVELOPE1" "$TMP" <<'NODE'
|
|
247
|
+
const fs=require('fs'),c=require('crypto'); const dir=process.argv[2],env=JSON.parse(fs.readFileSync(process.argv[3])),out=process.argv[4],m=JSON.parse(fs.readFileSync(`${dir}/source-manifest.json`));
|
|
248
|
+
for (const authority of ['flow','surface']) {
|
|
249
|
+
const section=env.sections.find(item=>item.authority===authority);
|
|
250
|
+
if (!section || typeof section.embedded_bytes!=='string') process.exit(1);
|
|
251
|
+
const entry=m.sources.find(item=>section.source_refs.includes(item.source_id));
|
|
252
|
+
if (!entry || entry.status!=='snapshotted') process.exit(1);
|
|
253
|
+
const raw=fs.readFileSync(`${dir}/sources/${entry.sha256}`);
|
|
254
|
+
const digest=c.createHash('sha256').update(raw).digest('hex');
|
|
255
|
+
if (section.sha256!==entry.sha256 || digest!==entry.sha256 || c.createHash('sha256').update(section.embedded_bytes).digest('hex')!==section.sha256) process.exit(1);
|
|
256
|
+
fs.writeFileSync(`${out}/${authority}.embedded`,section.embedded_bytes);
|
|
257
|
+
fs.writeFileSync(`${out}/${authority}.blob`,raw);
|
|
258
|
+
}
|
|
259
|
+
NODE
|
|
260
|
+
then
|
|
261
|
+
if cmp -s "$TMP/flow.embedded" "$TMP/flow.blob" && cmp -s "$TMP/surface.embedded" "$TMP/surface.blob"; then
|
|
262
|
+
_pass "AC8: Flow and Surface embedded_bytes are byte-identical to frozen blobs"
|
|
263
|
+
else
|
|
264
|
+
_fail "AC8: extracted authority bytes differ from frozen blobs"
|
|
265
|
+
fi
|
|
266
|
+
else _fail "AC8: foreign authority hash or embedded_bytes contract failed"; fi
|
|
267
|
+
|
|
268
|
+
# Mutating a copied blob must be detected, then restored byte-identically.
|
|
269
|
+
ENTRY_SHA="$(node -e "const m=JSON.parse(require('fs').readFileSync(process.argv[1]));process.stdout.write(m.sources.find(s=>s.status==='snapshotted').sha256)" "$NARRATIVE_DIR/source-manifest.json")"
|
|
270
|
+
BLOB="$NARRATIVE_DIR/sources/$ENTRY_SHA"; cp "$BLOB" "$TMP/blob.backup"; printf 'mutation' >"$BLOB"
|
|
271
|
+
if ! node "$ROOT/build/src/cli.js" narrative-sources verify --narrative-dir "$NARRATIVE_DIR" --json >"$TMP/mutated.json" 2>/dev/null; then _pass "AC2: post-compile blob mutation is detected"; else _fail "AC2: mutation passed verification"; fi
|
|
272
|
+
cp "$TMP/blob.backup" "$BLOB"
|
|
273
|
+
if cmp -s "$TMP/blob.backup" "$BLOB"; then _pass "AC2: mutated blob restored byte-identically"; else _fail "AC2: blob restoration differed"; fi
|
|
274
|
+
|
|
275
|
+
if node "$ROOT/build/src/cli.js" narrative-sources resolve --narrative-dir "$NARRATIVE_DIR" --source-id "${SOURCES[3]}" --json >/dev/null; then _pass "AC9: offline resolver succeeds"; else _fail "AC9: offline resolver failed"; fi
|
|
276
|
+
|
|
277
|
+
echo ""
|
|
278
|
+
if [[ "$errors" -eq 0 ]]; then echo "narrative grounded envelope tests passed."; exit 0; fi
|
|
279
|
+
echo "narrative grounded envelope tests FAILED: $errors issue(s)."
|
|
280
|
+
exit 1
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Deterministic grounding publication gate, adversarial corpus, and scorer-teeth proof (#623).
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
6
|
+
FIXTURES="$ROOT/evals/fixtures/narrative-grounding-validator"
|
|
7
|
+
TMP="$(mktemp -d)"
|
|
8
|
+
COMPILED="$ROOT/build/src/narrative/grounding-validator.js"
|
|
9
|
+
BACKUP="$TMP/grounding-validator.js.original"
|
|
10
|
+
errors=0
|
|
11
|
+
|
|
12
|
+
_pass() { echo " ✓ $1"; }
|
|
13
|
+
_fail() { echo " ✗ $1"; errors=$((errors + 1)); }
|
|
14
|
+
restore_compiled() {
|
|
15
|
+
if [[ -f "$BACKUP" ]]; then cp "$BACKUP" "$COMPILED"; fi
|
|
16
|
+
}
|
|
17
|
+
cleanup() { restore_compiled; rm -rf "$TMP"; }
|
|
18
|
+
trap cleanup EXIT
|
|
19
|
+
|
|
20
|
+
echo "Narrative grounding validator integration"
|
|
21
|
+
if npm run build --silent; then _pass "TypeScript build completed"; else _fail "TypeScript build failed"; fi
|
|
22
|
+
cp "$COMPILED" "$BACKUP"
|
|
23
|
+
|
|
24
|
+
if node "$FIXTURES/scorer.mjs" all >"$TMP/scorer.out" 2>"$TMP/scorer.err"; then
|
|
25
|
+
_pass "AC1-AC4/AC6: adversarial corpus meets expected accept/reject verdicts"
|
|
26
|
+
else
|
|
27
|
+
_fail "adversarial corpus failed: $(cat "$TMP/scorer.out" "$TMP/scorer.err")"
|
|
28
|
+
fi
|
|
29
|
+
if grep -q 'scorer counts: accept=2 reject=8 total=10' "$TMP/scorer.out" \
|
|
30
|
+
&& grep -q 'unsupported observed-claim rate=0' "$TMP/scorer.out" \
|
|
31
|
+
&& grep -q 'citation-resolver failures for published observed statements=0' "$TMP/scorer.out" \
|
|
32
|
+
&& grep -q 'fixture provenance: kontourai/flow-agents#623' "$TMP/scorer.out"; then
|
|
33
|
+
_pass "AC6: scorer prints fixture provenance, counts, and enforces both zero thresholds"
|
|
34
|
+
else
|
|
35
|
+
_fail "AC6 scorer report is incomplete: $(cat "$TMP/scorer.out")"
|
|
36
|
+
fi
|
|
37
|
+
if grep -q 'prompt-injection-inert: expected=accept actual=accept' "$TMP/scorer.out" \
|
|
38
|
+
&& ! grep -q 'NGV_CANARY_623' "$TMP/scorer.out" "$TMP/scorer.err"; then
|
|
39
|
+
_pass "AC4: cited prompt injection leaves verdict/classes/source_refs byte-identical and canary-free"
|
|
40
|
+
else
|
|
41
|
+
_fail "AC4 prompt-injection fixture changed grounded output or leaked its canary"
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Build one publishable narrative and one automatically projected unavailable
|
|
45
|
+
# citation. Both are composed through the real built CLI below.
|
|
46
|
+
node --input-type=module - "$ROOT" "$TMP" <<'NODE'
|
|
47
|
+
import { createHash } from 'node:crypto';
|
|
48
|
+
import fs from 'node:fs';
|
|
49
|
+
import path from 'node:path';
|
|
50
|
+
import { pathToFileURL } from 'node:url';
|
|
51
|
+
const root=process.argv[2], tmp=process.argv[3];
|
|
52
|
+
const api=await import(pathToFileURL(path.join(root,'build/src/index.js')));
|
|
53
|
+
const sha256=bytes=>createHash('sha256').update(bytes).digest('hex');
|
|
54
|
+
const compiler={name:'grounding-validator-integration',version:'1',policy_hash:'fixture'};
|
|
55
|
+
const captureCompleteness={channels:{},known_gaps:[]};
|
|
56
|
+
const repo=path.join(tmp,'repo'); fs.mkdirSync(repo,{recursive:true});
|
|
57
|
+
const bytes=Buffer.from('{"kind":"created-file-fixture","status":"created"}\n');
|
|
58
|
+
fs.writeFileSync(path.join(repo,'created.json'),bytes);
|
|
59
|
+
api.snapshotNarrative({
|
|
60
|
+
narrativeDir:path.join(tmp,'valid-narrative'),narrativeId:'valid-cli',redactionFields:[],compiler,captureCompleteness,
|
|
61
|
+
requests:[{source:api.parseSourceId(`fa1:file:created.json:${sha256(bytes)}`),roots:{repoRoot:repo}}],
|
|
62
|
+
},{now:()=> '2026-07-14T15:00:00.000Z'});
|
|
63
|
+
api.snapshotNarrative({
|
|
64
|
+
narrativeDir:path.join(tmp,'unresolved-narrative'),narrativeId:'unresolved-cli',redactionFields:[],compiler,captureCompleteness,
|
|
65
|
+
requests:[{source:api.parseSourceId(`fa1:file:missing.json:${'0'.repeat(64)}`),roots:{repoRoot:repo}}],
|
|
66
|
+
},{now:()=> '2026-07-14T15:00:00.000Z'});
|
|
67
|
+
NODE
|
|
68
|
+
|
|
69
|
+
if node "$ROOT/build/src/cli.js" narrative-sources compose \
|
|
70
|
+
--narrative-dir "$TMP/valid-narrative" --compiled-at "2026-07-14T16:00:00.000Z" \
|
|
71
|
+
--out-dir "$TMP/valid-out" >"$TMP/valid-compose.out" 2>"$TMP/valid-compose.err"; then
|
|
72
|
+
_pass "R1/R4: built CLI publishes a fully grounded narrative"
|
|
73
|
+
else
|
|
74
|
+
_fail "valid built-CLI compose failed: $(cat "$TMP/valid-compose.err")"
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
if node "$ROOT/build/src/cli.js" narrative-sources compose \
|
|
78
|
+
--narrative-dir "$TMP/unresolved-narrative" --compiled-at "2026-07-14T16:00:00.000Z" \
|
|
79
|
+
--out-dir "$TMP/unresolved-out" >"$TMP/unresolved-compose.out" 2>"$TMP/unresolved-compose.err"; then
|
|
80
|
+
_pass "completeness disclosure: manifest-declared unavailable source remains publishable"
|
|
81
|
+
else
|
|
82
|
+
_fail "typed unavailable-source disclosure was incorrectly rejected: $(cat "$TMP/unresolved-compose.err")"
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# Couple the real AC1 scorer verdict to the real CLI publication boundary by
|
|
86
|
+
# forcing that typed verdict at the stable branch anchor. The scorer above
|
|
87
|
+
# proves the production citation branch creates this violation; this proves
|
|
88
|
+
# compose refuses the same verdict before writeEnvelope.
|
|
89
|
+
node - "$COMPILED" <<'NODE'
|
|
90
|
+
const fs=require('fs'); const file=process.argv[2]; let text=fs.readFileSync(file,'utf8');
|
|
91
|
+
const anchor='/* grounding-check:citation */';
|
|
92
|
+
if (!text.includes(anchor)) throw new Error('citation mutation anchor missing');
|
|
93
|
+
text=text.replace(anchor, `${anchor}\n violations.push({ code: "unresolved_citation", statement_id: "forced", source_ref: "fa1:flow-state:absent:state/00000000", reason: "not_captured", detail: "forced integration verdict" });`);
|
|
94
|
+
fs.writeFileSync(file,text);
|
|
95
|
+
NODE
|
|
96
|
+
if node --check "$COMPILED" >/dev/null \
|
|
97
|
+
&& ! node "$ROOT/build/src/cli.js" narrative-sources compose \
|
|
98
|
+
--narrative-dir "$TMP/valid-narrative" --compiled-at "2026-07-14T16:00:00.000Z" \
|
|
99
|
+
--out-dir "$TMP/forced-violation-out" >"$TMP/forced-violation.out" 2>"$TMP/forced-violation.err" \
|
|
100
|
+
&& grep -q 'narrative grounding gate failed: unresolved_citation' "$TMP/forced-violation.err" \
|
|
101
|
+
&& [[ ! -e "$TMP/forced-violation-out" ]]; then
|
|
102
|
+
_pass "AC1/R4: typed grounding violation crosses the built CLI gate and writes no envelope"
|
|
103
|
+
else
|
|
104
|
+
_fail "AC1 typed verdict did not fail closed at the CLI boundary: $(cat "$TMP/forced-violation.err" 2>/dev/null || true)"
|
|
105
|
+
fi
|
|
106
|
+
restore_compiled
|
|
107
|
+
|
|
108
|
+
# A validator exception must remain upstream of writeEnvelope.
|
|
109
|
+
node - "$COMPILED" <<'NODE'
|
|
110
|
+
const fs=require('fs'); const file=process.argv[2]; let text=fs.readFileSync(file,'utf8');
|
|
111
|
+
const anchor='/* grounding-check:citation */';
|
|
112
|
+
if (!text.includes(anchor)) throw new Error('citation mutation anchor missing');
|
|
113
|
+
text=text.replace(anchor, `${anchor}\n throw new Error("AC5 injected validator failure");`);
|
|
114
|
+
fs.writeFileSync(file,text);
|
|
115
|
+
NODE
|
|
116
|
+
if node --check "$COMPILED" >/dev/null \
|
|
117
|
+
&& ! node "$ROOT/build/src/cli.js" narrative-sources compose \
|
|
118
|
+
--narrative-dir "$TMP/valid-narrative" --compiled-at "2026-07-14T16:00:00.000Z" \
|
|
119
|
+
--out-dir "$TMP/throw-out" >"$TMP/throw.out" 2>"$TMP/throw.err" \
|
|
120
|
+
&& grep -q 'AC5 injected validator failure' "$TMP/throw.err" \
|
|
121
|
+
&& [[ ! -e "$TMP/throw-out" ]]; then
|
|
122
|
+
_pass "AC5/R4: validator-internal exception fails closed before content-addressed write"
|
|
123
|
+
else
|
|
124
|
+
_fail "AC5 validator exception did not fail closed: $(cat "$TMP/throw.err" 2>/dev/null || true)"
|
|
125
|
+
fi
|
|
126
|
+
restore_compiled
|
|
127
|
+
cmp -s "$BACKUP" "$COMPILED" || _fail "compiled validator was not restored after AC5 mutation"
|
|
128
|
+
|
|
129
|
+
mutation_test() {
|
|
130
|
+
local check="$1" anchor="$2" call="$3"
|
|
131
|
+
restore_compiled
|
|
132
|
+
node - "$COMPILED" "$anchor" "$call" <<'NODE'
|
|
133
|
+
const fs=require('fs'); const [file,anchor,call]=process.argv.slice(2); let text=fs.readFileSync(file,'utf8');
|
|
134
|
+
const needle=`${anchor}\n ${call}`;
|
|
135
|
+
if (!text.includes(needle)) throw new Error(`mutation target missing: ${needle}`);
|
|
136
|
+
text=text.replace(needle, `${anchor}\n // mutation: check deliberately disabled`);
|
|
137
|
+
fs.writeFileSync(file,text);
|
|
138
|
+
NODE
|
|
139
|
+
if ! node --check "$COMPILED" >/dev/null; then
|
|
140
|
+
_fail "${check} mutation produced invalid JavaScript"
|
|
141
|
+
elif node "$FIXTURES/scorer.mjs" "$check" >"$TMP/mutation-$check.out" 2>"$TMP/mutation-$check.err"; then
|
|
142
|
+
_fail "${check} scorer still passed after its validator branch was disabled"
|
|
143
|
+
elif grep -q 'expected=reject actual=accept' "$TMP/mutation-$check.out"; then
|
|
144
|
+
_pass "scorer teeth: disabling ${check} check flips reject to accept"
|
|
145
|
+
else
|
|
146
|
+
_fail "${check} mutation failed for an unrelated reason: $(cat "$TMP/mutation-$check.out" "$TMP/mutation-$check.err")"
|
|
147
|
+
fi
|
|
148
|
+
restore_compiled
|
|
149
|
+
if cmp -s "$BACKUP" "$COMPILED" && node "$FIXTURES/scorer.mjs" "$check" >/dev/null; then
|
|
150
|
+
_pass "${check} compiled branch restored byte-for-byte and corpus rejects again"
|
|
151
|
+
else
|
|
152
|
+
_fail "${check} compiled branch did not restore cleanly"
|
|
153
|
+
fi
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
mutation_test citation '/* grounding-check:citation */' 'violations.push(...citationViolations(statements, narrativeDir, resolver, declaredUnavailable));'
|
|
157
|
+
mutation_test material '/* grounding-check:material */' 'violations.push(...materialViolations(deriveMaterialEvents(manifest, resolved), statements));'
|
|
158
|
+
mutation_test epistemic '/* grounding-check:epistemic */' 'violations.push(...epistemicViolations(statements));'
|
|
159
|
+
|
|
160
|
+
echo ""
|
|
161
|
+
if [[ "$errors" -eq 0 ]]; then
|
|
162
|
+
echo "narrative grounding validator tests passed: 14/14."
|
|
163
|
+
exit 0
|
|
164
|
+
fi
|
|
165
|
+
echo "narrative grounding validator tests FAILED: $errors issue(s)."
|
|
166
|
+
exit 1
|