@kontourai/flow-agents 1.4.0 → 2.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/CODEOWNERS +29 -0
- package/.github/actions/trust-verify/action.yml +145 -0
- package/.github/workflows/ci.yml +11 -4
- package/.github/workflows/kit-gates-demo.yml +2 -2
- package/.github/workflows/publish-npm.yml +10 -2
- package/.github/workflows/release-please.yml +1 -1
- package/.github/workflows/trust-reconcile.yml +113 -0
- package/AGENTS.md +13 -0
- package/CHANGELOG.md +95 -0
- package/CONTRIBUTING.md +4 -4
- package/README.md +1 -0
- package/agents/tool-planner.json +1 -1
- package/build/src/cli/init.js +242 -20
- package/build/src/cli/validate-workflow-artifacts.js +19 -2
- package/build/src/cli/verify.d.ts +1 -0
- package/build/src/cli/verify.js +90 -0
- package/build/src/cli/workflow-sidecar.d.ts +300 -8
- package/build/src/cli/workflow-sidecar.js +1934 -83
- package/build/src/cli.js +2 -3
- package/build/src/lib/flow-resolver.d.ts +82 -0
- package/build/src/lib/flow-resolver.js +237 -0
- package/build/src/tools/build-universal-bundles.js +34 -22
- package/build/src/tools/generate-context-map.js +3 -16
- package/build/src/tools/validate-source-tree.d.ts +1 -1
- package/build/src/tools/validate-source-tree.js +42 -162
- package/context/contracts/artifact-contract.md +10 -0
- package/context/contracts/delivery-contract.md +1 -0
- package/context/contracts/review-contract.md +1 -0
- package/context/contracts/verification-contract.md +2 -0
- package/context/gate-awareness.md +39 -0
- package/context/scripts/hooks/stop-goal-fit.js +632 -70
- package/docs/adr/0001-flow-agents-consumes-flow.md +1 -1
- package/docs/adr/0002-flow-kits-as-extension-unit.md +1 -1
- package/docs/adr/0004-gates-expect-surface-claims.md +2 -0
- package/docs/adr/0005-kubernetes-inspired-resource-contracts.md +2 -0
- package/docs/adr/0007-skill-audit.md +1 -1
- package/docs/adr/0009-canonical-hook-core-kit-boundary.md +95 -0
- package/docs/adr/0010-workflow-trust-state-as-hachure-bundle.md +139 -0
- package/docs/adr/0011-mcp-posture.md +100 -0
- package/docs/adr/0012-agent-coordination-as-liveness-claims.md +119 -0
- package/docs/adr/0013-context-lifecycle.md +151 -0
- package/docs/adr/0014-core-vs-domain-kit-boundary.md +143 -0
- package/docs/adr/0015-flow-flow-agents-boundary-reconciliation.md +120 -0
- package/docs/adr/0016-three-hard-boundary-model.md +71 -0
- package/docs/adr/0017-anti-gaming-trust-security-model.md +155 -0
- package/docs/agent-system-guidebook.md +5 -12
- package/docs/context-map.md +4 -10
- package/docs/index.md +3 -2
- package/docs/integrations/framework-adapter.md +19 -6
- package/docs/integrations/index.md +2 -2
- package/docs/north-star.md +4 -4
- package/docs/operating-layers.md +3 -3
- package/docs/plans/adr-0010-phase2-gate-recompute.md +55 -0
- package/docs/repository-structure.md +2 -2
- package/docs/skills-map.md +1 -0
- package/docs/spec/runtime-hook-surface.md +62 -9
- package/docs/standards-register.md +3 -3
- package/docs/survey-utterance-check.md +1 -1
- package/docs/trust-anchor-adoption.md +197 -0
- package/docs/verifiable-trust.md +95 -0
- package/docs/veritas-integration.md +2 -2
- package/docs/workflow-usage-guide.md +69 -0
- package/evals/acceptance/DEMO-false-completion.md +144 -0
- package/evals/acceptance/demo-cast.sh +92 -0
- package/evals/acceptance/demo-false-completion.sh +72 -0
- package/evals/acceptance/demo-real-evidence.sh +104 -0
- package/evals/acceptance/demo.tape +29 -0
- package/evals/acceptance/prove-capture-teeth-declared.sh +335 -0
- package/evals/acceptance/prove-capture-teeth.sh +114 -0
- package/evals/acceptance/prove-teeth.sh +105 -0
- package/evals/ci/antigaming-suite.sh +54 -0
- package/evals/ci/run-baseline.sh +2 -0
- package/evals/fixtures/flow-kit-repository/invalid-missing-extension-asset/flows/review.flow.json +26 -0
- package/evals/fixtures/flow-kit-repository/invalid-missing-extension-asset/kit.json +20 -0
- package/evals/fixtures/flow-kit-repository/valid-unknown-extension/flows/review.flow.json +26 -0
- package/evals/fixtures/flow-kit-repository/valid-unknown-extension/kit.json +18 -0
- package/evals/integration/test_builder_step_producers.sh +379 -0
- package/evals/integration/test_bundle_install.sh +35 -71
- package/evals/integration/test_bundle_lifecycle.sh +39 -2
- package/evals/integration/test_captured_fail_reconciliation.sh +820 -0
- package/evals/integration/test_checkpoint_signing.sh +489 -0
- package/evals/integration/test_claim_lookup.sh +352 -0
- package/evals/integration/test_command_log_integrity.sh +275 -0
- package/evals/integration/test_context_map.sh +0 -2
- package/evals/integration/test_dual_emit_flow_step.sh +278 -0
- package/evals/integration/test_enforcer_expects_driven.sh +281 -0
- package/evals/integration/test_evidence_capture_hook.sh +185 -0
- package/evals/integration/test_flow_kit_repository.sh +2 -0
- package/evals/integration/test_flowdef_session_activation.sh +273 -0
- package/evals/integration/test_flowdef_session_history_preservation.sh +250 -0
- package/evals/integration/test_gate_bypass_chain.sh +448 -0
- package/evals/integration/test_gate_lockdown.sh +1137 -0
- package/evals/integration/test_gate_review_inquiry_records.sh +399 -0
- package/evals/integration/test_goal_fit_escape_hatch.sh +73 -0
- package/evals/integration/test_goal_fit_hook.sh +69 -4
- package/evals/integration/test_goal_fit_rederive.sh +263 -0
- package/evals/integration/test_install_merge.sh +1176 -0
- package/evals/integration/test_mint_attestation.sh +373 -0
- package/evals/integration/test_phase_map_and_gate_claim.sh +365 -0
- package/evals/integration/test_publish_delivery.sh +269 -0
- package/evals/integration/test_reconcile_soundness.sh +528 -0
- package/evals/integration/test_resolvefirststep_security.sh +208 -0
- package/evals/integration/test_session_resume_roundtrip.sh +286 -0
- package/evals/integration/test_trust_checkpoint.sh +325 -0
- package/evals/integration/test_trust_reconcile.sh +293 -0
- package/evals/integration/test_verify_cli.sh +208 -0
- package/evals/integration/test_workflow_sidecar_writer.sh +549 -34
- package/evals/lib/node.sh +0 -6
- package/evals/run.sh +45 -0
- package/evals/static/test_workflow_skills.sh +6 -13
- package/install.sh +0 -7
- package/integrations/strands-ts/README.md +25 -15
- package/integrations/veritas/flow-agents.adapter.json +1 -2
- package/kits/builder/flows/build.flow.json +59 -12
- package/kits/builder/kit.json +85 -15
- package/kits/builder/skills/continue-work/SKILL.md +116 -0
- package/kits/builder/skills/deliver/SKILL.md +36 -6
- package/kits/builder/skills/design-probe/SKILL.md +28 -0
- package/kits/builder/skills/execute-plan/SKILL.md +9 -1
- package/kits/builder/skills/gate-review/SKILL.md +234 -0
- package/kits/builder/skills/learning-review/SKILL.md +30 -0
- package/kits/builder/skills/pickup-probe/SKILL.md +29 -0
- package/kits/builder/skills/plan-work/SKILL.md +13 -1
- package/kits/builder/skills/pull-work/SKILL.md +19 -0
- package/kits/knowledge/adapters/default-store/index.js +38 -0
- package/kits/knowledge/adapters/flow-runner/index.js +1620 -0
- package/kits/knowledge/adapters/obsidian-store/index.js +36 -6
- package/kits/knowledge/docs/store-contract.md +314 -0
- package/kits/knowledge/evals/audit-freshness/suite.test.js +368 -0
- package/kits/knowledge/evals/canonicalize-category/suite.test.js +383 -0
- package/kits/knowledge/evals/contract-suite/suite.test.js +111 -0
- package/kits/knowledge/evals/detect-contradictions/suite.test.js +324 -0
- package/kits/knowledge/evals/entities/suite.test.js +40 -0
- package/kits/knowledge/evals/glossary-sync/suite.test.js +416 -0
- package/kits/knowledge/evals/hygiene-review/suite.test.js +396 -0
- package/kits/knowledge/evals/retirement/suite.test.js +145 -0
- package/kits/knowledge/flows/audit-freshness.flow.json +44 -0
- package/kits/knowledge/flows/canonicalize-category.flow.json +44 -0
- package/kits/knowledge/flows/detect-contradictions.flow.json +44 -0
- package/kits/knowledge/flows/glossary-sync.flow.json +61 -0
- package/kits/knowledge/flows/hygiene-review.flow.json +43 -0
- package/kits/knowledge/kit.json +51 -1
- package/package.json +4 -4
- package/packaging/conformance/README.md +10 -2
- package/packaging/conformance/fixtures/evidence-capture--allow-records-command.json +29 -0
- package/packaging/conformance/fixtures/stop-goal-fit--block-bundle-disputed-claim.json +29 -0
- package/packaging/conformance/fixtures/stop-goal-fit--block-capture-contradicts-claimed-pass.json +30 -0
- package/packaging/conformance/fixtures/stop-goal-fit--block-mode.json +23 -0
- package/packaging/conformance/fixtures/stop-goal-fit--off-mode.json +24 -0
- package/packaging/conformance/fixtures/stop-goal-fit--warn-active-delivery.json +5 -2
- package/packaging/conformance/fixtures/stop-goal-fit--warn-no-bundle.json +23 -0
- package/packaging/conformance/fixtures/workflow-steering--reground-active-prompt.json +30 -0
- package/packaging/conformance/fixtures/workflow-steering--reground-session-start.json +30 -0
- package/packaging/conformance/run-conformance.js +1 -1
- package/scripts/README.md +2 -1
- package/scripts/build-universal-bundles.js +0 -1
- package/scripts/ci/mint-attestation.js +221 -0
- package/scripts/ci/trust-reconcile.js +545 -0
- package/scripts/hooks/config-protection.js +423 -1
- package/scripts/hooks/evidence-capture.js +348 -0
- package/scripts/hooks/lib/liveness-read.js +113 -0
- package/scripts/hooks/run-hook.js +6 -1
- package/scripts/hooks/stop-goal-fit.js +1471 -79
- package/scripts/hooks/workflow-steering.js +135 -5
- package/scripts/install-codex-home.sh +39 -0
- package/scripts/install-merge.js +330 -0
- package/src/cli/init.ts +218 -20
- package/src/cli/validate-workflow-artifacts.ts +18 -2
- package/src/cli/verify.ts +100 -0
- package/src/cli/workflow-sidecar.ts +2064 -77
- package/src/cli.ts +2 -3
- package/src/lib/flow-resolver.ts +284 -0
- package/src/tools/build-universal-bundles.ts +34 -21
- package/src/tools/generate-context-map.ts +3 -17
- package/src/tools/validate-source-tree.ts +44 -104
- package/build/src/tools/filter-installed-packs.d.ts +0 -2
- package/build/src/tools/filter-installed-packs.js +0 -135
- package/packaging/packs.json +0 -49
- package/scripts/filter-installed-packs.js +0 -2
- package/src/tools/filter-installed-packs.ts +0 -132
|
@@ -9,24 +9,316 @@ export declare function writeJson(file: string, payload: AnyObj): void;
|
|
|
9
9
|
export declare function loadJson(file: string, fallback?: AnyObj): AnyObj;
|
|
10
10
|
export declare function appendJsonl(file: string, payload: AnyObj): void;
|
|
11
11
|
/**
|
|
12
|
-
* Validate a Hachure trust.bundle
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
* Validate a Hachure trust.bundle using @kontourai/surface's canonical validator
|
|
13
|
+
* (surface is the authoritative owner of trust-bundle schema validation per ADR 0010 / ADR 0015).
|
|
14
|
+
* Returns `{ valid, errors, available }`. When @kontourai/surface is unavailable,
|
|
15
|
+
* `available` is false and `valid` is true (fail-open) so callers can choose to treat
|
|
16
|
+
* unvalidated bundles as acceptable or gate on `available`. Surface is REQUIRED for
|
|
17
|
+
* bundle writes per ADR 0010 Phase 4c — `assertBundleWritten` enforces this on the
|
|
18
|
+
* write path. Surface's validator is equivalent-or-stronger than the prior hachure
|
|
19
|
+
* JSON-Schema validator: it validates the same structural constraints plus cross-reference
|
|
20
|
+
* integrity (evidence/event → claim references) that the JSON schema did not enforce.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateTrustBundle(bundle: unknown): Promise<{
|
|
23
|
+
valid: boolean;
|
|
24
|
+
errors: string[];
|
|
25
|
+
available: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Validate a record against the canonical hachure inquiry-record.schema.json
|
|
29
|
+
* (https://kontourai.io/schemas/surface/inquiry-record.schema.json).
|
|
30
|
+
* Returns `{ valid, errors, available }`. Fail-open when hachure is not installed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateInquiryRecord(record: unknown): {
|
|
20
33
|
valid: boolean;
|
|
21
34
|
errors: string[];
|
|
22
35
|
available: boolean;
|
|
23
36
|
};
|
|
37
|
+
type SurfaceInquiry = {
|
|
38
|
+
id: string;
|
|
39
|
+
question: string;
|
|
40
|
+
askedBy: string;
|
|
41
|
+
askedAt: string;
|
|
42
|
+
target?: {
|
|
43
|
+
subjectType: string;
|
|
44
|
+
subjectId: string;
|
|
45
|
+
fieldOrBehavior: string;
|
|
46
|
+
qualifiers?: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
type SurfaceInquiryRecord = {
|
|
51
|
+
id: string;
|
|
52
|
+
inquiry: SurfaceInquiry;
|
|
53
|
+
outcome: "matched" | "derived" | "unsupported";
|
|
54
|
+
resolutionPath: {
|
|
55
|
+
claimIds: string[];
|
|
56
|
+
ruleId?: string;
|
|
57
|
+
ruleVersion?: string;
|
|
58
|
+
identityLinkIds?: string[];
|
|
59
|
+
transitiveRuleIds?: string[];
|
|
60
|
+
};
|
|
61
|
+
answer?: {
|
|
62
|
+
value: unknown;
|
|
63
|
+
status: string;
|
|
64
|
+
};
|
|
65
|
+
inputSnapshot: Array<{
|
|
66
|
+
claimId: string;
|
|
67
|
+
status: string;
|
|
68
|
+
}>;
|
|
69
|
+
statusFunctionVersion: string;
|
|
70
|
+
resolvedAt: string;
|
|
71
|
+
};
|
|
72
|
+
type SurfaceModule = {
|
|
73
|
+
deriveClaimStatus: (args: {
|
|
74
|
+
claim: Record<string, unknown>;
|
|
75
|
+
evidence: Record<string, unknown>[];
|
|
76
|
+
events: Record<string, unknown>[];
|
|
77
|
+
policies: Record<string, unknown>[];
|
|
78
|
+
now?: Date;
|
|
79
|
+
}) => {
|
|
80
|
+
status: string;
|
|
81
|
+
policyId: string | undefined;
|
|
82
|
+
};
|
|
83
|
+
generateClaimId: (subjectId: string, surface: string, fieldOrBehavior: string) => string;
|
|
84
|
+
statusFunctionVersion: string;
|
|
85
|
+
resolveInquiry: (bundle: Record<string, unknown>, inquiry: SurfaceInquiry, options?: {
|
|
86
|
+
now?: Date;
|
|
87
|
+
}) => SurfaceInquiryRecord;
|
|
88
|
+
buildTrustReport: (bundle: Record<string, unknown>, options?: {
|
|
89
|
+
now?: Date;
|
|
90
|
+
}) => Record<string, unknown>;
|
|
91
|
+
buildDerivationDrilldown: (report: Record<string, unknown>, claimId: string) => Record<string, unknown>;
|
|
92
|
+
/** Canonical trust-bundle validator from @kontourai/surface. Throws on invalid input; returns TrustBundle on success. */
|
|
93
|
+
validateTrustBundle: (input: unknown) => Record<string, unknown>;
|
|
94
|
+
/** Freeze a derivation checkpoint from a report. */
|
|
95
|
+
checkpointFromReport: (report: Record<string, unknown>) => Record<string, unknown>;
|
|
96
|
+
/** Diff two derivations (prior checkpoint → later report) and emit freshness transition events. */
|
|
97
|
+
diffFreshness: (prior: Record<string, unknown>, next: Record<string, unknown>) => Array<Record<string, unknown>>;
|
|
98
|
+
/** Wrap a TrustBundle as an in-toto Statement v1. */
|
|
99
|
+
toInTotoStatement: (bundle: Record<string, unknown>, options: {
|
|
100
|
+
subjects: Array<{
|
|
101
|
+
name: string;
|
|
102
|
+
digest: Record<string, string>;
|
|
103
|
+
}>;
|
|
104
|
+
}) => {
|
|
105
|
+
_type: "https://in-toto.io/Statement/v1";
|
|
106
|
+
subject: Array<{
|
|
107
|
+
name: string;
|
|
108
|
+
digest: Record<string, string>;
|
|
109
|
+
}>;
|
|
110
|
+
predicateType: "https://hachure.org/v1/bundle";
|
|
111
|
+
predicate: Record<string, unknown>;
|
|
112
|
+
};
|
|
113
|
+
/** Sign an in-toto Statement with Sigstore keyless signing. Returns null when no OIDC identity is available (fail-open). */
|
|
114
|
+
signStatementWithSigstore: (statement: {
|
|
115
|
+
_type: "https://in-toto.io/Statement/v1";
|
|
116
|
+
subject: Array<{
|
|
117
|
+
name: string;
|
|
118
|
+
digest: Record<string, string>;
|
|
119
|
+
}>;
|
|
120
|
+
predicateType: "https://hachure.org/v1/bundle";
|
|
121
|
+
predicate: Record<string, unknown>;
|
|
122
|
+
}) => Promise<{
|
|
123
|
+
envelope: {
|
|
124
|
+
payloadType: "application/vnd.in-toto+json";
|
|
125
|
+
payload: string;
|
|
126
|
+
signatures: Array<{
|
|
127
|
+
keyid: string;
|
|
128
|
+
sig: string;
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
131
|
+
sigstoreBundle: unknown;
|
|
132
|
+
assuranceLevel: "signed";
|
|
133
|
+
} | null>;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Build a Hachure trust.bundle from raw check/criterion/critique inputs.
|
|
137
|
+
* trust.bundle is the PRIMARY artifact (ADR 0010 Phase 4a producer inversion).
|
|
138
|
+
* Callers pass raw inputs directly — not bespoke-sidecar-shaped objects.
|
|
139
|
+
* Derives claim statuses using @kontourai/surface's canonical versioned function.
|
|
140
|
+
* Returns null when Surface is unavailable (caller skips the bundle write).
|
|
141
|
+
* @param slug Task slug (used as subjectId prefix)
|
|
142
|
+
* @param timestamp ISO-8601 timestamp for createdAt / updatedAt / observedAt
|
|
143
|
+
* @param checks Normalized check objects (from record-evidence --check-json / --surface-trust-json)
|
|
144
|
+
* @param criteria Acceptance criteria objects (from acceptance.json .criteria array)
|
|
145
|
+
* @param critiques Critique objects (from critique.json .critiques array)
|
|
146
|
+
* @param commandLog Optional parsed command-log.jsonl entries (capture-authoritative fold)
|
|
147
|
+
*/
|
|
148
|
+
export declare function buildTrustBundle(slug: string, timestamp: string, checks: AnyObj[], criteria: AnyObj[], critiques: AnyObj[], commandLog?: AnyObj[], flowAgentsDir?: string): Promise<AnyObj | null>;
|
|
149
|
+
/**
|
|
150
|
+
* Fail-open wrapper: builds (via Surface), validates, and writes a trust.bundle.
|
|
151
|
+
* Accepts raw check/criterion/critique inputs directly (ADR 0010 Phase 4a).
|
|
152
|
+
* trust.bundle is written as the PRIMARY artifact; bespoke sidecars are the
|
|
153
|
+
* caller's responsibility to emit as back-compat projections AFTER this call.
|
|
154
|
+
* ANY error is caught and logged to stderr — this function NEVER throws and
|
|
155
|
+
* NEVER affects the exit code of its caller.
|
|
156
|
+
* Returns { written: false } if Surface is unavailable (fail-open; does NOT
|
|
157
|
+
* fall back to hand-rolled status derivation).
|
|
158
|
+
* @param checks Normalized check objects (same as buildTrustBundle)
|
|
159
|
+
* @param criteria Acceptance criteria objects (same as buildTrustBundle)
|
|
160
|
+
* @param critiques Critique objects (same as buildTrustBundle)
|
|
161
|
+
*/
|
|
162
|
+
export declare function writeTrustBundle(dir: string, slug: string, timestamp: string, checks: AnyObj[], criteria: AnyObj[], critiques: AnyObj[]): Promise<{
|
|
163
|
+
written: boolean;
|
|
164
|
+
errors: string[];
|
|
165
|
+
}>;
|
|
24
166
|
export declare function sidecarBase(slug: string): AnyObj;
|
|
25
167
|
export declare function validateEvidenceRef(ref: AnyObj, label: string): AnyObj;
|
|
26
168
|
export declare function normalizeEvidenceRefs(raw: unknown, label: string): AnyObj[];
|
|
27
169
|
export declare function normalizeCheck(raw: AnyObj): AnyObj;
|
|
28
170
|
export declare function writeState(dir: string, slug: string, status: string, phase: string, timestamp: string, summary: string, next?: string): void;
|
|
29
171
|
export declare function normalizeFinding(raw: AnyObj): AnyObj;
|
|
172
|
+
/**
|
|
173
|
+
* Build and write trust.checkpoint.json for a completed run.
|
|
174
|
+
* Skips silently when:
|
|
175
|
+
* - trust.bundle is absent (no evidence recorded yet)
|
|
176
|
+
* - Surface is unavailable (checkpointFromReport not found)
|
|
177
|
+
* The caller wraps this in .catch() so it never breaks the parent command.
|
|
178
|
+
*
|
|
179
|
+
* Increment B1 — checkpoint signing at the release boundary:
|
|
180
|
+
* After the checkpoint is written, attempts Sigstore keyless signing (OIDC).
|
|
181
|
+
* - CI/OIDC available: writes trust.checkpoint.sig.json (cosign-verifiable DSSE envelope)
|
|
182
|
+
* and writes attestation:{status:"signed",...} to trust.checkpoint.attestation.json.
|
|
183
|
+
* - Local (no OIDC): writes trust.checkpoint.intoto.json (unsigned in-toto statement)
|
|
184
|
+
* and writes attestation:{status:"unsigned",...} to trust.checkpoint.attestation.json.
|
|
185
|
+
* Signing is ALWAYS fail-open — a signing failure never breaks the seal.
|
|
186
|
+
*/
|
|
187
|
+
export declare function sealTrustCheckpoint(dir: string, slug: string, sealedAt: string, status: string, phase: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Publish the session's trust artifacts to the committed delivery/ path.
|
|
190
|
+
*
|
|
191
|
+
* Copies trust.bundle, trust.checkpoint.json, and (if present)
|
|
192
|
+
* trust.checkpoint.intoto.json / trust.checkpoint.sig.json from the
|
|
193
|
+
* session artifact dir to <repoRoot>/delivery/.
|
|
194
|
+
*
|
|
195
|
+
* Fail-soft: if trust.bundle is absent, returns without throwing.
|
|
196
|
+
* Idempotent: overwrites on re-delivery.
|
|
197
|
+
*/
|
|
198
|
+
export declare function publishDelivery(dir: string, repoRoot: string): Promise<void>;
|
|
30
199
|
export declare function validateLearningCorrection(record: AnyObj): void;
|
|
31
200
|
export declare function normalizeLearning(raw: AnyObj, timestamp: string): AnyObj;
|
|
201
|
+
/** Shape of a claim from the trust.bundle */
|
|
202
|
+
export interface TrustClaim {
|
|
203
|
+
id: string;
|
|
204
|
+
subjectType: string;
|
|
205
|
+
subjectId: string;
|
|
206
|
+
surface: string;
|
|
207
|
+
claimType: string;
|
|
208
|
+
fieldOrBehavior: string;
|
|
209
|
+
value: string;
|
|
210
|
+
createdAt: string;
|
|
211
|
+
updatedAt: string;
|
|
212
|
+
status: "verified" | "disputed" | "assumed" | "proposed" | "rejected" | "stale" | "unknown";
|
|
213
|
+
}
|
|
214
|
+
/** Shape of the trust.bundle file */
|
|
215
|
+
export interface BundleFile {
|
|
216
|
+
schemaVersion: number;
|
|
217
|
+
source: string;
|
|
218
|
+
claims: TrustClaim[];
|
|
219
|
+
evidence: AnyObj[];
|
|
220
|
+
events: AnyObj[];
|
|
221
|
+
policies: AnyObj[];
|
|
222
|
+
}
|
|
223
|
+
/** The gate block signal read from .flow-agents/.goal-fit-block-streak.json */
|
|
224
|
+
export interface GateBlockSignal {
|
|
225
|
+
/** True when the streak file exists AND count >= 1 */
|
|
226
|
+
blocked: boolean;
|
|
227
|
+
/** The hash from the streak file (for rationale citation) */
|
|
228
|
+
hash: string | null;
|
|
229
|
+
/** The consecutive block count */
|
|
230
|
+
count: number;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The gate-review calibration verdict, stored in InquiryRecord.answer.value.
|
|
234
|
+
* This is gate-review's value-add over the canonical InquiryRecord outcome.
|
|
235
|
+
*/
|
|
236
|
+
export type GateCalibration = "correct" | "false_block" | "missed_block";
|
|
237
|
+
/**
|
|
238
|
+
* Read the gate block signal from .flow-agents/.goal-fit-block-streak.json
|
|
239
|
+
* (written by scripts/hooks/stop-goal-fit.js when block mode fires).
|
|
240
|
+
* The file sits at <artifact-root>/.goal-fit-block-streak.json — one level
|
|
241
|
+
* above the session artifact dir. Fail-open: returns { blocked: false } when
|
|
242
|
+
* the file is absent or unreadable.
|
|
243
|
+
*
|
|
244
|
+
* @param artifactRoot The .flow-agents root dir (parent of session slug dir).
|
|
245
|
+
*/
|
|
246
|
+
export declare function readGateBlockSignal(artifactRoot: string): GateBlockSignal;
|
|
247
|
+
/**
|
|
248
|
+
* Derive the gate-review calibration from a resolved InquiryRecord and the
|
|
249
|
+
* block signal. Pure function — no I/O.
|
|
250
|
+
*
|
|
251
|
+
* Mapping (mirrors SKILL.md Bundle-Claim to Classification table):
|
|
252
|
+
* outcome="matched", status="disputed"|"rejected", blocked=true → correct
|
|
253
|
+
* outcome="matched", status="verified"|"assumed", blocked=true → false_block
|
|
254
|
+
* outcome="matched", status="assumed", blocked=true → false_block
|
|
255
|
+
* outcome="matched", status="stale"|"unknown", blocked=false → missed_block
|
|
256
|
+
* outcome="matched", status="proposed", any → missed_block
|
|
257
|
+
* outcome="unsupported" (absent claim), any → missed_block
|
|
258
|
+
* outcome="derived", satisfied=true, any → correct/false_block by blocked flag
|
|
259
|
+
* fallthrough → missed_block
|
|
260
|
+
*/
|
|
261
|
+
export declare function deriveGateCalibration(outcome: "matched" | "derived" | "unsupported", answerStatus: string | undefined, blocked: boolean): GateCalibration;
|
|
262
|
+
/**
|
|
263
|
+
* Compose the advisory proposed-fix string for a gate-review finding.
|
|
264
|
+
* Pure function — no I/O.
|
|
265
|
+
*/
|
|
266
|
+
export declare function gateAdvisoryFix(calibration: GateCalibration, claimId: string, answerStatus: string | undefined): string;
|
|
267
|
+
/**
|
|
268
|
+
* Build an array of canonical InquiryRecords for all gate-fire and missed-block
|
|
269
|
+
* candidates in the bundle, using Surface's resolveInquiry. Returns null when
|
|
270
|
+
* Surface is unavailable (caller skips the output file — no fork fallback).
|
|
271
|
+
*
|
|
272
|
+
* @param bundle Parsed trust.bundle (BundleFile shape)
|
|
273
|
+
* @param blockSignal Result of readGateBlockSignal()
|
|
274
|
+
* @param slug Task slug (used in inquiry ids and session_slug)
|
|
275
|
+
* @param expectedCriterionIds Optional list of expected criterion IDs to check
|
|
276
|
+
* for absent claims (missed_block detection).
|
|
277
|
+
* @param surface Loaded Surface module (must have resolveInquiry)
|
|
278
|
+
* @param now Optional timestamp override for deterministic tests
|
|
279
|
+
*/
|
|
280
|
+
export declare function buildGateInquiryRecords(bundle: BundleFile, blockSignal: GateBlockSignal, slug: string, expectedCriterionIds: string[], surface: SurfaceModule, now?: Date): AnyObj[];
|
|
281
|
+
export interface ClaimEvidenceItem {
|
|
282
|
+
evidenceType: string;
|
|
283
|
+
label: string;
|
|
284
|
+
execution: {
|
|
285
|
+
runner: string;
|
|
286
|
+
label: string;
|
|
287
|
+
isError: boolean;
|
|
288
|
+
exitCode: number | null;
|
|
289
|
+
} | null;
|
|
290
|
+
passing: boolean;
|
|
291
|
+
summary: string;
|
|
292
|
+
}
|
|
293
|
+
export interface ClaimExplanation {
|
|
294
|
+
found: boolean;
|
|
295
|
+
status: string;
|
|
296
|
+
value: string;
|
|
297
|
+
claimType: string;
|
|
298
|
+
evidence: ClaimEvidenceItem[];
|
|
299
|
+
policy: {
|
|
300
|
+
id: string;
|
|
301
|
+
requiredEvidence: string[];
|
|
302
|
+
requiredMethods?: string[];
|
|
303
|
+
acceptanceCriteria: string[];
|
|
304
|
+
reviewAuthority: string;
|
|
305
|
+
} | null;
|
|
306
|
+
why: {
|
|
307
|
+
directInputs: AnyObj[];
|
|
308
|
+
leafClaims: AnyObj[];
|
|
309
|
+
diagnostics: AnyObj[];
|
|
310
|
+
transparencyGaps: AnyObj[];
|
|
311
|
+
changeRecords: AnyObj[];
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Build a structured explanation for a specific claim.
|
|
316
|
+
* PURE: report + bundle + id in, structured explanation out.
|
|
317
|
+
* No fs, no CLI, no .flow-agents paths. Promotable to Surface #171.
|
|
318
|
+
*
|
|
319
|
+
* @param report TrustReport from buildTrustReport(bundle) — required for derived status
|
|
320
|
+
* @param bundle Raw parsed trust.bundle (BundleFile shape)
|
|
321
|
+
* @param claimId The claim id to explain
|
|
322
|
+
*/
|
|
323
|
+
export declare function buildClaimExplanation(report: Record<string, unknown>, bundle: Record<string, unknown>, claimId: string): ClaimExplanation;
|
|
32
324
|
export {};
|