@kontourai/flow-agents 2.3.0 → 3.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 +16 -0
- package/.github/workflows/ci.yml +44 -0
- package/.github/workflows/trust-reconcile.yml +62 -4
- package/AGENTS.md +4 -4
- package/CHANGELOG.md +62 -0
- package/CONTEXT.md +35 -0
- package/README.md +9 -3
- package/agents/dev.json +1 -1
- package/agents/tool-code-reviewer.json +1 -1
- package/agents/tool-planner.json +3 -3
- package/agents/tool-verifier.json +3 -3
- package/build/src/cli/assignment-provider.d.ts +1 -0
- package/build/src/cli/assignment-provider.js +748 -0
- package/build/src/cli/console-learning-projection.js +3 -2
- package/build/src/cli/effective-assignment-provider-settings.d.ts +1 -0
- package/build/src/cli/effective-assignment-provider-settings.js +125 -0
- package/build/src/cli/init.js +104 -21
- package/build/src/cli/kit.js +37 -6
- package/build/src/cli/pull-work-provider.js +1 -1
- package/build/src/cli/usage-feedback.js +3 -3
- package/build/src/cli/validate-hook-influence.js +1 -0
- package/build/src/cli/validate-workflow-artifacts.js +27 -7
- package/build/src/cli/workflow-artifact-cleanup-audit.js +36 -2
- package/build/src/cli/workflow-sidecar.d.ts +14 -7
- package/build/src/cli/workflow-sidecar.js +938 -168
- package/build/src/cli.js +6 -0
- package/build/src/flow-kit/validate.d.ts +23 -0
- package/build/src/flow-kit/validate.js +67 -1
- package/build/src/index.d.ts +1 -1
- package/build/src/index.js +1 -1
- package/build/src/lib/flow-resolver.d.ts +6 -4
- package/build/src/lib/flow-resolver.js +125 -58
- package/build/src/lib/local-artifact-root.d.ts +14 -2
- package/build/src/lib/local-artifact-root.js +22 -5
- package/build/src/lib/workflow-learning-projection.js +2 -2
- package/build/src/runtime-adapters.d.ts +12 -0
- package/build/src/runtime-adapters.js +56 -16
- package/build/src/tools/build-universal-bundles.js +49 -16
- package/build/src/tools/generate-context-map.js +10 -8
- package/build/src/tools/validate-source-tree.js +24 -1
- package/console.telemetry.json +22 -0
- package/context/contracts/artifact-contract.md +40 -7
- package/context/contracts/assignment-provider-contract.md +239 -0
- package/context/contracts/builder-kit-workflow-state-contract.md +5 -2
- package/context/contracts/decision-registry-contract.md +265 -0
- package/context/contracts/delivery-contract.md +3 -1
- package/context/contracts/execution-contract.md +25 -0
- package/context/contracts/governance-adapter-contract.md +2 -0
- package/context/contracts/knowledge-store-contract.md +197 -0
- package/context/contracts/planning-contract.md +4 -1
- package/context/contracts/review-contract.md +7 -3
- package/context/contracts/sandbox-policy.md +2 -0
- package/context/contracts/standing-directives.md +13 -0
- package/context/contracts/verification-contract.md +11 -1
- package/context/contracts/work-item-contract.md +3 -1
- package/context/deferred/parallelization.md +1 -1
- package/context/gate-awareness.md +4 -4
- package/context/scripts/git-status.sh +2 -2
- package/context/scripts/hooks/config-protection.js +502 -2
- package/context/scripts/hooks/lib/config-protection-remedies.js +69 -0
- package/context/scripts/hooks/run-hook.js +14 -1
- package/context/scripts/hooks/stop-goal-fit.js +1140 -99
- package/context/scripts/hooks/workflow-steering.js +212 -6
- package/context/settings/assignment-provider-settings.json +33 -0
- package/docs/adr/0007-flow-skill-kit-tool-boundary.md +2 -0
- package/docs/adr/0015-flow-flow-agents-boundary-reconciliation.md +35 -0
- package/docs/adr/0019-kit-dependency-ownership.md +62 -0
- package/docs/adr/0020-trust-reconcile-manifest-and-claim-classification.md +290 -0
- package/docs/adr/0021-assignment-leases-and-stale-claim-takeover.md +221 -0
- package/docs/adr/0022-fail-closed-delivery-reconciliation-with-governed-exemptions.md +463 -0
- package/docs/agent-system-guidebook.md +3 -3
- package/docs/agent-usage-feedback-loop.md +6 -6
- package/docs/context-map.md +10 -7
- package/docs/decisions/decision-records.md +57 -0
- package/docs/decisions/index.md +17 -0
- package/docs/decisions/knowledge-store-provider.md +51 -0
- package/docs/decisions/model-routing.md +63 -0
- package/docs/decisions/promotion-gate.md +52 -0
- package/docs/decisions/standing-directives.md +66 -0
- package/docs/developer-architecture.md +1 -1
- package/docs/fixture-ownership.md +4 -0
- package/docs/flow-kit-repository-contract.md +5 -5
- package/docs/getting-started.md +12 -2
- package/docs/integrations/harness-install.md +2 -1
- package/docs/kit-authoring-guide.md +64 -5
- package/docs/knowledge-kit.md +5 -1
- package/docs/learnings/2026-07-improvement-program.md +203 -0
- package/docs/migrations.md +6 -5
- package/docs/north-star.md +2 -2
- package/docs/operating-layers.md +4 -3
- package/docs/repository-structure.md +5 -5
- package/docs/skills-map.md +8 -8
- package/docs/spec/runtime-hook-surface.md +19 -15
- package/docs/spikes/graph-provider-2026-07.md +155 -0
- package/docs/standards-register.md +7 -7
- package/docs/trust-anchor-adoption.md +105 -4
- package/docs/work-item-adapters.md +1 -1
- package/docs/workflow-artifact-lifecycle.md +72 -9
- package/docs/workflow-eval-strategy.md +3 -3
- package/docs/workflow-shared-contracts.md +3 -2
- package/docs/workflow-usage-guide.md +260 -21
- package/evals/acceptance/DEMO-false-completion.md +20 -11
- package/evals/acceptance/prove-capture-teeth-declared.sh +15 -15
- package/evals/acceptance/prove-capture-teeth.sh +11 -11
- package/evals/acceptance/test_kiro_harness.sh +1 -1
- package/evals/ci/antigaming-suite.sh +5 -0
- package/evals/ci/run-baseline.sh +71 -1
- package/evals/fixtures/assignment-provider/actor-a.json +6 -0
- package/evals/fixtures/assignment-provider/actor-b.json +6 -0
- package/evals/fixtures/assignment-provider/github-issue-claimed.json +27 -0
- package/evals/fixtures/assignment-provider/github-issue-unassigned.json +7 -0
- package/evals/fixtures/assignment-provider/liveness-fresh.json +9 -0
- package/evals/fixtures/assignment-provider/liveness-stale.json +9 -0
- package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/flows/review.flow.json +26 -0
- package/evals/fixtures/flow-kit-repository/invalid-bad-dependency/kit.json +13 -0
- package/evals/fixtures/flow-kit-repository/valid-with-dependency/flows/review.flow.json +26 -0
- package/evals/fixtures/flow-kit-repository/valid-with-dependency/kit.json +13 -0
- package/evals/fixtures/hook-influence/cases.json +32 -0
- package/evals/fixtures/pull-work-provider/github-issues.json +6 -6
- package/evals/fixtures/trust-reconcile-exploits/fabricated-attestation.json +59 -0
- package/evals/fixtures/trust-reconcile-exploits/no-label-bypass.json +36 -0
- package/evals/fixtures/trust-reconcile-exploits/skip-assumed-bypass.json +59 -0
- package/evals/fixtures/trust-reconcile-exploits/status-misassertion.json +48 -0
- package/evals/fixtures/trust-reconcile-exploits/waived-command-check.json +44 -0
- package/evals/fixtures/trust-reconcile-mixed-bundle/mixed-bundle.json +159 -0
- package/evals/fixtures/trust-reconcile-ws3/ws3-bundle.json +920 -0
- package/evals/integration/test_actor_identity.sh +254 -0
- package/evals/integration/test_assignment_provider_github.sh +318 -0
- package/evals/integration/test_assignment_provider_local_file.sh +222 -0
- package/evals/integration/test_builder_step_producers.sh +33 -23
- package/evals/integration/test_bundle_install.sh +22 -16
- package/evals/integration/test_bundle_lifecycle.sh +11 -11
- package/evals/integration/test_captured_fail_reconciliation.sh +50 -50
- package/evals/integration/test_checkpoint_signing.sh +43 -0
- package/evals/integration/test_claim_lookup.sh +4 -4
- package/evals/integration/test_codex_hook_resolution.sh +114 -0
- package/evals/integration/test_command_log_concurrency.sh +8 -8
- package/evals/integration/test_command_log_fork_classification.sh +3 -3
- package/evals/integration/test_command_log_integrity.sh +16 -16
- package/evals/integration/test_console_learning_projection.sh +1 -1
- package/evals/integration/test_critique_supersession_roundtrip.sh +182 -0
- package/evals/integration/test_dual_emit_flow_step.sh +145 -0
- package/evals/integration/test_enforcer_expects_driven.sh +12 -12
- package/evals/integration/test_evidence_capture_hook.sh +14 -13
- package/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/evals/integration/test_flow_agents_statusline.sh +2 -2
- package/evals/integration/test_flow_kit_install_git.sh +52 -0
- package/evals/integration/test_flow_kit_repository.sh +2 -0
- package/evals/integration/test_flowdef_session_activation.sh +6 -6
- package/evals/integration/test_flowdef_union_floor_regression.sh +429 -0
- package/evals/integration/test_gate_bypass_chain.sh +52 -40
- package/evals/integration/test_gate_lockdown.sh +97 -73
- package/evals/integration/test_gate_review_inquiry_records.sh +3 -3
- package/evals/integration/test_goal_fit_escape_hatch.sh +10 -10
- package/evals/integration/test_goal_fit_ghost_session.sh +104 -0
- package/evals/integration/test_goal_fit_hook.sh +32 -32
- package/evals/integration/test_goal_fit_rederive.sh +9 -9
- package/evals/integration/test_hook_category_behaviors.sh +103 -0
- package/evals/integration/test_hook_influence_cases.sh +1 -0
- package/evals/integration/test_install_merge.sh +262 -1
- package/evals/integration/test_kit_identity_trust.sh +6 -6
- package/evals/integration/test_liveness_conflict_injection.sh +587 -0
- package/evals/integration/test_liveness_heartbeat.sh +677 -0
- package/evals/integration/test_liveness_verdict.sh +394 -0
- package/evals/integration/test_local_flow_kit_install.sh +15 -0
- package/evals/integration/test_phase_map_and_gate_claim.sh +63 -11
- package/evals/integration/test_promote_gate.sh +178 -0
- package/evals/integration/test_publish_delivery.sh +23 -6
- package/evals/integration/test_pull_work_assignment_join.sh +132 -0
- package/evals/integration/test_pull_work_liveness_preflight.sh +394 -0
- package/evals/integration/test_pull_work_provider.sh +2 -2
- package/evals/integration/test_reconcile_soundness.sh +37 -13
- package/evals/integration/test_resolvefirststep_security.sh +22 -0
- package/evals/integration/test_runtime_adapter_activation.sh +87 -18
- package/evals/integration/test_session_resume_roundtrip.sh +147 -0
- package/evals/integration/test_sidecar_field_preservation.sh +249 -0
- package/evals/integration/test_trust_reconcile.sh +11 -10
- package/evals/integration/test_trust_reconcile_manifest.sh +79 -0
- package/evals/integration/test_trust_reconcile_mixed_bundle.sh +96 -0
- package/evals/integration/test_trust_reconcile_negatives.sh +759 -0
- package/evals/integration/test_usage_feedback_global.sh +5 -5
- package/evals/integration/test_validate_artifacts_portability.sh +60 -0
- package/evals/integration/test_verify_cli.sh +2 -2
- package/evals/integration/test_veritas_governance_kit.sh +117 -0
- package/evals/integration/test_workflow_artifact_cleanup_audit.sh +26 -1
- package/evals/integration/test_workflow_artifacts.sh +33 -0
- package/evals/integration/test_workflow_sidecar_writer.sh +802 -74
- package/evals/integration/test_workflow_steering_hook.sh +175 -5
- package/evals/lib/codex-provider.sh +1 -1
- package/evals/lib/node.sh +19 -1
- package/evals/run.sh +32 -0
- package/evals/static/test_decisions.sh +150 -0
- package/evals/static/test_flowdef_codeowners_coverage.sh +62 -0
- package/evals/static/test_knowledge_providers.sh +23 -0
- package/evals/static/test_package.sh +19 -10
- package/evals/static/test_universal_bundles.sh +48 -3
- package/evals/static/test_workflow_skills.sh +41 -8
- package/kits/builder/flows/build.flow.json +3 -74
- package/kits/builder/flows/publish-learn.flow.json +90 -0
- package/kits/builder/kit.json +11 -0
- package/kits/builder/skills/builder-shape/SKILL.md +1 -1
- package/kits/builder/skills/deliver/SKILL.md +32 -11
- package/kits/builder/skills/design-probe/SKILL.md +4 -4
- package/kits/builder/skills/evidence-gate/SKILL.md +26 -1
- package/kits/builder/skills/execute-plan/SKILL.md +2 -2
- package/kits/builder/skills/fix-bug/SKILL.md +2 -0
- package/kits/builder/skills/gate-review/SKILL.md +6 -6
- package/kits/builder/skills/idea-to-backlog/SKILL.md +1 -1
- package/kits/builder/skills/learning-review/SKILL.md +7 -7
- package/kits/builder/skills/pickup-probe/SKILL.md +5 -4
- package/kits/builder/skills/plan-work/SKILL.md +27 -5
- package/kits/builder/skills/pull-work/SKILL.md +148 -5
- package/kits/builder/skills/release-readiness/SKILL.md +4 -4
- package/kits/builder/skills/review-work/SKILL.md +24 -1
- package/kits/builder/skills/tdd-workflow/SKILL.md +2 -0
- package/kits/builder/skills/verify-work/SKILL.md +8 -1
- package/kits/catalog.json +6 -0
- package/kits/knowledge/kit.json +35 -0
- package/kits/knowledge/providers/conformance/fixtures/git-repo/CONTEXT.md +12 -0
- package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/old-sprocket-shape.md +13 -0
- package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/sprocket-shape.md +14 -0
- package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/decisions/widget-format.md +14 -0
- package/kits/knowledge/providers/conformance/fixtures/git-repo/docs/learnings/fixture-learning.md +7 -0
- package/kits/knowledge/providers/conformance/fixtures/work-item/issues.json +30 -0
- package/kits/knowledge/providers/conformance/suite.test.js +125 -0
- package/kits/knowledge/providers/git-repo/index.js +236 -0
- package/kits/knowledge/providers/health/health-pass.test.js +99 -0
- package/kits/knowledge/providers/health/index.js +153 -0
- package/kits/knowledge/providers/index.js +24 -0
- package/kits/knowledge/providers/lib/model.js +91 -0
- package/kits/knowledge/providers/lib/schema-validate.js +119 -0
- package/kits/knowledge/providers/markdown-vault/index.js +169 -0
- package/kits/knowledge/providers/work-item/index.js +204 -0
- package/kits/veritas-governance/adapter/readiness-to-trust-bundle.mjs +178 -0
- package/kits/veritas-governance/docs/README.md +75 -0
- package/kits/veritas-governance/fixtures/readiness/not-ready.readiness-report.json +4645 -0
- package/kits/veritas-governance/fixtures/readiness/ready.readiness-report.json +4403 -0
- package/kits/veritas-governance/flows/readiness-check.flow.json +35 -0
- package/kits/veritas-governance/kit.json +16 -0
- package/package.json +11 -5
- package/packaging/README.md +2 -2
- package/packaging/conformance/fixtures/config-protection--allow-read-state-json.json +20 -0
- package/packaging/conformance/fixtures/config-protection--block-write-state-json.json +20 -0
- package/packaging/conformance/fixtures/stop-goal-fit--block-bundle-disputed-claim.json +1 -1
- package/packaging/conformance/fixtures/stop-goal-fit--block-capture-contradicts-claimed-pass.json +1 -1
- package/packaging/manifest.json +9 -10
- package/schemas/assignment-provider-settings.schema.json +125 -0
- package/schemas/decision-record.schema.json +109 -0
- package/schemas/knowledge/edge.schema.json +54 -0
- package/schemas/knowledge/health-report.schema.json +45 -0
- package/schemas/knowledge/node.schema.json +49 -0
- package/schemas/knowledge/proposal.schema.json +53 -0
- package/schemas/workflow-evidence.schema.json +1 -1
- package/schemas/workflow-state.schema.json +5 -0
- package/scripts/README.md +8 -3
- package/scripts/check-content-boundary.cjs +1 -1
- package/scripts/check-decisions.cjs +356 -0
- package/scripts/ci/derive-claim-status.mjs +74 -0
- package/scripts/ci/trust-reconcile.js +957 -103
- package/scripts/git-status.sh +2 -2
- package/scripts/hooks/claude-telemetry-hook.js +37 -3
- package/scripts/hooks/codex-telemetry-hook.js +36 -2
- package/scripts/hooks/config-protection.js +102 -30
- package/scripts/hooks/evidence-capture.js +3 -3
- package/scripts/hooks/lib/actor-identity.js +368 -0
- package/scripts/hooks/lib/config-protection-remedies.js +69 -0
- package/scripts/hooks/lib/liveness-heartbeat.js +361 -0
- package/scripts/hooks/lib/liveness-policy.js +127 -0
- package/scripts/hooks/lib/liveness-read.js +105 -12
- package/scripts/hooks/lib/liveness-write.js +46 -0
- package/scripts/hooks/lib/local-artifact-paths.js +12 -6
- package/scripts/hooks/opencode-telemetry-hook.js +27 -1
- package/scripts/hooks/pi-telemetry-hook.js +27 -1
- package/scripts/hooks/stop-goal-fit.js +157 -26
- package/scripts/hooks/workflow-steering.js +77 -3
- package/scripts/install-codex-home.sh +138 -38
- package/scripts/statusline/flow-agents-statusline.js +2 -2
- package/src/cli/assignment-provider.ts +845 -0
- package/src/cli/console-learning-projection.ts +3 -2
- package/src/cli/effective-assignment-provider-settings.ts +112 -0
- package/src/cli/init.ts +101 -21
- package/src/cli/kit.ts +37 -6
- package/src/cli/public-api.test.mjs +58 -6
- package/src/cli/pull-work-provider.ts +1 -1
- package/src/cli/trust-bundle-policy-order.test.mjs +87 -0
- package/src/cli/usage-feedback.ts +3 -3
- package/src/cli/validate-hook-influence.ts +1 -0
- package/src/cli/validate-workflow-artifacts.ts +27 -7
- package/src/cli/veritas-readiness-adapter.test.mjs +267 -0
- package/src/cli/workflow-artifact-cleanup-audit.ts +35 -2
- package/src/cli/workflow-sidecar.ts +933 -168
- package/src/cli.ts +6 -0
- package/src/flow-kit/validate.ts +74 -1
- package/src/index.ts +6 -2
- package/src/lib/flow-resolver.ts +123 -55
- package/src/lib/local-artifact-root.ts +24 -5
- package/src/lib/workflow-learning-projection.ts +2 -2
- package/src/runtime-adapters.ts +61 -15
- package/src/tools/build-universal-bundles.ts +49 -16
- package/src/tools/generate-context-map.ts +10 -8
- package/src/tools/validate-source-tree.ts +24 -1
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# gate-bypass chain (adversarial review HIGH/A01/A04).
|
|
4
4
|
#
|
|
5
5
|
# Exploit chain (pre-fix):
|
|
6
|
-
# 1. Traversal via active_flow_id: "builder.../../../.flow-agents/slug/fake-flow"
|
|
7
|
-
# splits into kitId="builder" / flowName="../../../.flow-agents/slug/fake-flow"
|
|
6
|
+
# 1. Traversal via active_flow_id: "builder.../../../.kontourai/flow-agents/slug/fake-flow"
|
|
7
|
+
# splits into kitId="builder" / flowName="../../../.kontourai/flow-agents/slug/fake-flow"
|
|
8
8
|
# → path.join escapes kits/ → loads attacker-authored fake-flow.flow.json
|
|
9
|
-
# directly from .flow-agents/ (agent-writable location).
|
|
9
|
+
# directly from .kontourai/flow-agents/ (agent-writable location).
|
|
10
10
|
# 2. Fake flow has gates:{g:{step:"verify",expects:[]}} → declaredClaimTypes=Set{}
|
|
11
11
|
# (empty, NOT null) → old if/else isSelectedClaim returns false for EVERY claim
|
|
12
12
|
# → bundleEnforcement emits ZERO warnings → tamper-detection bypassed → exit 0.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# 1. Layer 1 — traversal closed: pre-fix path.join escapes kits/, post-fix returns null.
|
|
24
24
|
# 2. Layer 2 — empty-Set closed: pre-fix 0 claims selected, post-fix exit 2.
|
|
25
25
|
# 3. Full chain end-to-end: traversal current.json + fake empty-expects flow under
|
|
26
|
-
# .flow-agents/ + disputed workflow.* bundle → PRE-FIX exit 0, POST-FIX exit 2.
|
|
26
|
+
# .kontourai/flow-agents/ + disputed workflow.* bundle → PRE-FIX exit 0, POST-FIX exit 2.
|
|
27
27
|
# 4. Legit session regression: builder.build/verify with real flow still works.
|
|
28
28
|
#
|
|
29
29
|
# Deterministic, no model spend, self-cleaning.
|
|
@@ -48,11 +48,11 @@ trap cleanup EXIT
|
|
|
48
48
|
# ─── Helper: seed a minimal in-progress workflow artifact ─────────────────────
|
|
49
49
|
seed_repo_inprogress() { # $1=dir $2=slug
|
|
50
50
|
local p="$1" slug="$2"
|
|
51
|
-
mkdir -p "$p/.flow-agents/$slug"
|
|
51
|
+
mkdir -p "$p/.kontourai/flow-agents/$slug"
|
|
52
52
|
printf '# Repo\n' > "$p/AGENTS.md"
|
|
53
53
|
printf '%s' "{\"schema_version\":\"1.0\",\"task_slug\":\"$slug\",\"status\":\"in_progress\",\"phase\":\"execution\",\"updated_at\":\"2026-06-27T00:00:00Z\",\"next_action\":{\"status\":\"in_progress\",\"summary\":\"Testing\"}}" \
|
|
54
|
-
> "$p/.flow-agents/$slug/state.json"
|
|
55
|
-
cat > "$p/.flow-agents/$slug/$slug--deliver.md" << MD
|
|
54
|
+
> "$p/.kontourai/flow-agents/$slug/state.json"
|
|
55
|
+
cat > "$p/.kontourai/flow-agents/$slug/$slug--deliver.md" << MD
|
|
56
56
|
# $slug
|
|
57
57
|
|
|
58
58
|
branch: main
|
|
@@ -72,7 +72,7 @@ seed_disputed_bundle() { # $1=bundle_path $2=slug
|
|
|
72
72
|
import json, sys
|
|
73
73
|
bundle_path, slug = sys.argv[1], sys.argv[2]
|
|
74
74
|
bundle = {
|
|
75
|
-
"schemaVersion":
|
|
75
|
+
"schemaVersion": 5,
|
|
76
76
|
"source": "flow-agents/workflow-sidecar",
|
|
77
77
|
"claims": [{
|
|
78
78
|
"id": "c-dispute",
|
|
@@ -109,10 +109,10 @@ const path = require('path');
|
|
|
109
109
|
const repoRoot = '/repo';
|
|
110
110
|
|
|
111
111
|
// Exact exploit string from the task description
|
|
112
|
-
const malId = 'builder.../../../.flow-agents/slug/fake-flow';
|
|
112
|
+
const malId = 'builder.../../../.kontourai/flow-agents/slug/fake-flow';
|
|
113
113
|
const dot = malId.indexOf('.'); // 7
|
|
114
114
|
const kitId = malId.slice(0, dot); // 'builder'
|
|
115
|
-
const flowName = malId.slice(dot + 1); // '../../../.flow-agents/slug/fake-flow'
|
|
115
|
+
const flowName = malId.slice(dot + 1); // '../../../.kontourai/flow-agents/slug/fake-flow'
|
|
116
116
|
|
|
117
117
|
console.log(' Traversal flowId: \"' + malId + '\"');
|
|
118
118
|
console.log(' Parsed: kitId=\"' + kitId + '\" flowName=\"' + flowName + '\"');
|
|
@@ -121,7 +121,7 @@ console.log(' Parsed: kitId=\"' + kitId + '\" flowName=\"' + flowName + '\"');
|
|
|
121
121
|
const preFix = path.join(repoRoot, 'kits', kitId, 'flows', flowName + '.flow.json');
|
|
122
122
|
console.log(' PRE-FIX path.join: ' + preFix);
|
|
123
123
|
const escaped = !preFix.startsWith(path.join(repoRoot, 'kits') + '/');
|
|
124
|
-
console.log(' PRE-FIX escapes kits/: ' + escaped + ' → would load attacker file under .flow-agents/');
|
|
124
|
+
console.log(' PRE-FIX escapes kits/: ' + escaped + ' → would load attacker file under .kontourai/flow-agents/');
|
|
125
125
|
|
|
126
126
|
if (!escaped) {
|
|
127
127
|
console.error('ERROR: expected traversal to escape kits/ with this flowId');
|
|
@@ -140,8 +140,8 @@ const repoRoot = '$ROOT';
|
|
|
140
140
|
|
|
141
141
|
// Traversal IDs — all must return null (slug validation rejects '.', '/', etc.)
|
|
142
142
|
const cases = [
|
|
143
|
-
['builder.../../../.flow-agents/slug/fake-flow', 'verify'], // exact exploit from task
|
|
144
|
-
['builder../../../.flow-agents/x/fake', 'verify'], // double-dot variant
|
|
143
|
+
['builder.../../../.kontourai/flow-agents/slug/fake-flow', 'verify'], // exact exploit from task
|
|
144
|
+
['builder../../../.kontourai/flow-agents/x/fake', 'verify'], // double-dot variant
|
|
145
145
|
['builder.../etc/passwd', 'verify'], // etc/passwd probe
|
|
146
146
|
['kit-id.flow/../../secret', 'step'], // different separator
|
|
147
147
|
['builder.build', '../../../etc'], // traversal in stepId
|
|
@@ -173,23 +173,35 @@ console.log('builder.build/verify: gateId=' + result.gateId + ' expects=' + resu
|
|
|
173
173
|
" 2>&1 && _pass "Legit builder.build/verify resolves correctly (no over-rejection)" \
|
|
174
174
|
|| _fail "Legit builder.build/verify regression"
|
|
175
175
|
|
|
176
|
-
# Validate FLOW_AGENTS_FLOW_DEFS_DIR under .flow-agents is rejected
|
|
176
|
+
# Validate FLOW_AGENTS_FLOW_DEFS_DIR under .kontourai/flow-agents is rejected
|
|
177
177
|
T1_DIR="$TMP/t1-override"
|
|
178
|
-
mkdir -p "$T1_DIR/.flow-agents/fake-flows"
|
|
179
|
-
cat > "$T1_DIR/.flow-agents/fake-flows/builder.build.flow.json" << 'JSON'
|
|
178
|
+
mkdir -p "$T1_DIR/.kontourai/flow-agents/fake-flows"
|
|
179
|
+
cat > "$T1_DIR/.kontourai/flow-agents/fake-flows/builder.build.flow.json" << 'JSON'
|
|
180
180
|
{"id":"fake","version":"0.0","gates":{"g":{"step":"verify","expects":[]}}}
|
|
181
181
|
JSON
|
|
182
182
|
node -e "
|
|
183
183
|
const r = require('$RESOLVER');
|
|
184
|
-
// Override points INTO .flow-agents (agent-writable) — must fall back to kits/
|
|
185
|
-
process.env.FLOW_AGENTS_FLOW_DEFS_DIR = '$T1_DIR/.flow-agents/fake-flows';
|
|
184
|
+
// Override points INTO .kontourai/flow-agents (agent-writable) — must fall back to kits/
|
|
185
|
+
process.env.FLOW_AGENTS_FLOW_DEFS_DIR = '$T1_DIR/.kontourai/flow-agents/fake-flows';
|
|
186
186
|
const result = r.resolveFlowStep('builder.build', 'verify', '$T1_DIR');
|
|
187
187
|
delete process.env.FLOW_AGENTS_FLOW_DEFS_DIR;
|
|
188
188
|
// Falls back to repoRoot/kits/ which has no builder.build flow → null
|
|
189
189
|
// This confirms the agent-writable FLOW_DEFS_DIR override was rejected
|
|
190
|
-
console.log('FLOW_DEFS_DIR under .flow-agents: result =', result, '(null = override rejected)');
|
|
191
|
-
" 2>&1 && _pass "FLOW_AGENTS_FLOW_DEFS_DIR under .flow-agents is ignored (agent-writable protection)" \
|
|
192
|
-
|| _fail "FLOW_AGENTS_FLOW_DEFS_DIR .flow-agents bypass not blocked"
|
|
190
|
+
console.log('FLOW_DEFS_DIR under .kontourai/flow-agents: result =', result, '(null = override rejected)');
|
|
191
|
+
" 2>&1 && _pass "FLOW_AGENTS_FLOW_DEFS_DIR under .kontourai/flow-agents is ignored (agent-writable protection)" \
|
|
192
|
+
|| _fail "FLOW_AGENTS_FLOW_DEFS_DIR .kontourai/flow-agents bypass not blocked"
|
|
193
|
+
|
|
194
|
+
ln -s "$T1_DIR/.kontourai/flow-agents/fake-flows" "$TMP/safe-looking-flow-defs"
|
|
195
|
+
node -e "
|
|
196
|
+
const r = require('$RESOLVER');
|
|
197
|
+
// Override LOOKS safe but resolves through a symlink into agent-writable runtime artifacts.
|
|
198
|
+
process.env.FLOW_AGENTS_FLOW_DEFS_DIR = '$TMP/safe-looking-flow-defs';
|
|
199
|
+
const result = r.resolveFlowStep('builder.build', 'verify', '$T1_DIR');
|
|
200
|
+
delete process.env.FLOW_AGENTS_FLOW_DEFS_DIR;
|
|
201
|
+
console.log('FLOW_DEFS_DIR symlink to .kontourai/flow-agents: result =', result, '(null = symlink override rejected)');
|
|
202
|
+
if (result !== null) process.exit(1);
|
|
203
|
+
" 2>&1 && _pass "FLOW_AGENTS_FLOW_DEFS_DIR symlink into .kontourai/flow-agents is ignored" \
|
|
204
|
+
|| _fail "FLOW_AGENTS_FLOW_DEFS_DIR symlink into .kontourai/flow-agents bypass not blocked"
|
|
193
205
|
|
|
194
206
|
|
|
195
207
|
# ─── Test 2: Empty-Set closed — Layer 2 union form ───────────────────────────
|
|
@@ -198,11 +210,11 @@ echo "=== 2. Layer 2 — Empty-Set defense: union isSelectedClaim + empty-expect
|
|
|
198
210
|
|
|
199
211
|
T2_DIR="$TMP/t2-empty-set"
|
|
200
212
|
seed_repo_inprogress "$T2_DIR" "empty-set-test"
|
|
201
|
-
seed_disputed_bundle "$T2_DIR/.flow-agents/empty-set-test/trust.bundle" "empty-set-test"
|
|
213
|
+
seed_disputed_bundle "$T2_DIR/.kontourai/flow-agents/empty-set-test/trust.bundle" "empty-set-test"
|
|
202
214
|
printf '%s' '{"artifact_dir":"empty-set-test","active_flow_id":"builder.build","active_step_id":"verify"}' \
|
|
203
|
-
> "$T2_DIR/.flow-agents/current.json"
|
|
215
|
+
> "$T2_DIR/.kontourai/flow-agents/current.json"
|
|
204
216
|
|
|
205
|
-
# Fake flow with empty expects[] (loaded via FLOW_DEFS_DIR — NOT under .flow-agents)
|
|
217
|
+
# Fake flow with empty expects[] (loaded via FLOW_DEFS_DIR — NOT under .kontourai/flow-agents)
|
|
206
218
|
mkdir -p "$TMP/fake-flows-safe"
|
|
207
219
|
cat > "$TMP/fake-flows-safe/builder.build.flow.json" << 'JSON'
|
|
208
220
|
{"id":"builder.build","version":"0.0","gates":{"fake-gate":{"step":"verify","expects":[]}}}
|
|
@@ -262,19 +274,19 @@ echo ""
|
|
|
262
274
|
echo "=== 3. Full exploit chain: traversal current.json + fake empty-expects flow + disputed bundle ==="
|
|
263
275
|
echo ""
|
|
264
276
|
echo "Setup: T3_DIR has kits/ so findRepoRoot returns T3_DIR."
|
|
265
|
-
echo "Traversal flowId 'builder.../../../.flow-agents/slug/fake-flow' with repoRoot=T3_DIR resolves to:"
|
|
266
|
-
echo " T3_DIR/.flow-agents/slug/fake-flow.flow.json (agent-writable — the fake flow)"
|
|
277
|
+
echo "Traversal flowId 'builder.../../../.kontourai/flow-agents/slug/fake-flow' with repoRoot=T3_DIR resolves to:"
|
|
278
|
+
echo " T3_DIR/.kontourai/flow-agents/slug/fake-flow.flow.json (agent-writable — the fake flow)"
|
|
267
279
|
|
|
268
280
|
T3_DIR="$TMP/t3-full-chain"
|
|
269
281
|
mkdir -p "$T3_DIR/kits" # ensures findRepoRoot returns T3_DIR
|
|
270
282
|
seed_repo_inprogress "$T3_DIR" "exploit-test"
|
|
271
|
-
seed_disputed_bundle "$T3_DIR/.flow-agents/exploit-test/trust.bundle" "exploit-test"
|
|
283
|
+
seed_disputed_bundle "$T3_DIR/.kontourai/flow-agents/exploit-test/trust.bundle" "exploit-test"
|
|
272
284
|
|
|
273
285
|
# Place the fake flow exactly where the traversal would resolve it:
|
|
274
|
-
# path.join(T3_DIR, "kits", "builder", "flows", "../../../.flow-agents/slug/fake-flow.flow.json")
|
|
275
|
-
# = T3_DIR/.flow-agents/slug/fake-flow.flow.json
|
|
276
|
-
mkdir -p "$T3_DIR/.flow-agents/slug"
|
|
277
|
-
cat > "$T3_DIR/.flow-agents/slug/fake-flow.flow.json" << 'JSON'
|
|
286
|
+
# path.join(T3_DIR, "kits", "builder", "flows", "../../../.kontourai/flow-agents/slug/fake-flow.flow.json")
|
|
287
|
+
# = T3_DIR/.kontourai/flow-agents/slug/fake-flow.flow.json
|
|
288
|
+
mkdir -p "$T3_DIR/.kontourai/flow-agents/slug"
|
|
289
|
+
cat > "$T3_DIR/.kontourai/flow-agents/slug/fake-flow.flow.json" << 'JSON'
|
|
278
290
|
{
|
|
279
291
|
"id": "fake-bypass",
|
|
280
292
|
"version": "0.0",
|
|
@@ -288,15 +300,15 @@ cat > "$T3_DIR/.flow-agents/slug/fake-flow.flow.json" << 'JSON'
|
|
|
288
300
|
JSON
|
|
289
301
|
|
|
290
302
|
# current.json: traversal active_flow_id pointing to the fake flow
|
|
291
|
-
printf '%s' '{"artifact_dir":"exploit-test","active_flow_id":"builder.../../../.flow-agents/slug/fake-flow","active_step_id":"verify"}' \
|
|
292
|
-
> "$T3_DIR/.flow-agents/current.json"
|
|
303
|
+
printf '%s' '{"artifact_dir":"exploit-test","active_flow_id":"builder.../../../.kontourai/flow-agents/slug/fake-flow","active_step_id":"verify"}' \
|
|
304
|
+
> "$T3_DIR/.kontourai/flow-agents/current.json"
|
|
293
305
|
|
|
294
306
|
echo ""
|
|
295
307
|
echo "--- 3a. PRE-FIX: demonstrate traversal would load the fake flow ---"
|
|
296
308
|
node -e "
|
|
297
309
|
const path = require('path');
|
|
298
310
|
const repoRoot = '$T3_DIR';
|
|
299
|
-
const flowId = 'builder.../../../.flow-agents/slug/fake-flow';
|
|
311
|
+
const flowId = 'builder.../../../.kontourai/flow-agents/slug/fake-flow';
|
|
300
312
|
const dot = flowId.indexOf('.');
|
|
301
313
|
const kitId = flowId.slice(0, dot);
|
|
302
314
|
const flowName = flowId.slice(dot + 1);
|
|
@@ -353,13 +365,13 @@ echo ""
|
|
|
353
365
|
echo "=== 4. Regression: legit builder.build/verify session passes (no false-block) ==="
|
|
354
366
|
|
|
355
367
|
T4_DIR="$TMP/t4-legit"
|
|
356
|
-
mkdir -p "$T4_DIR/.flow-agents/legit-test"
|
|
368
|
+
mkdir -p "$T4_DIR/.kontourai/flow-agents/legit-test"
|
|
357
369
|
printf '# Repo\n' > "$T4_DIR/AGENTS.md"
|
|
358
370
|
printf '%s' '{"artifact_dir":"legit-test","active_flow_id":"builder.build","active_step_id":"verify"}' \
|
|
359
|
-
> "$T4_DIR/.flow-agents/current.json"
|
|
371
|
+
> "$T4_DIR/.kontourai/flow-agents/current.json"
|
|
360
372
|
printf '%s' '{"schema_version":"1.0","task_slug":"legit-test","status":"delivered","phase":"done","updated_at":"2026-06-27T00:00:00Z","next_action":{"status":"done","summary":"done"}}' \
|
|
361
|
-
> "$T4_DIR/.flow-agents/legit-test/state.json"
|
|
362
|
-
cat > "$T4_DIR/.flow-agents/legit-test/legit-test--deliver.md" << 'MD'
|
|
373
|
+
> "$T4_DIR/.kontourai/flow-agents/legit-test/state.json"
|
|
374
|
+
cat > "$T4_DIR/.kontourai/flow-agents/legit-test/legit-test--deliver.md" << 'MD'
|
|
363
375
|
# legit-test
|
|
364
376
|
|
|
365
377
|
branch: main
|
|
@@ -376,10 +388,10 @@ type: deliver
|
|
|
376
388
|
MD
|
|
377
389
|
|
|
378
390
|
# Write a CLEAN trust.bundle for builder.verify.tests (status=verified, passing evidence)
|
|
379
|
-
python3 - "$T4_DIR/.flow-agents/legit-test/trust.bundle" << 'PY'
|
|
391
|
+
python3 - "$T4_DIR/.kontourai/flow-agents/legit-test/trust.bundle" << 'PY'
|
|
380
392
|
import json, sys
|
|
381
393
|
bundle = {
|
|
382
|
-
"schemaVersion":
|
|
394
|
+
"schemaVersion": 5,
|
|
383
395
|
"source": "flow-agents/workflow-sidecar",
|
|
384
396
|
"claims": [{
|
|
385
397
|
"id": "c-legit",
|