@kontourai/flow-agents 2.4.0 → 3.1.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 +8 -0
- package/.github/workflows/ci.yml +20 -0
- package/.github/workflows/trust-reconcile.yml +62 -4
- package/CHANGELOG.md +38 -0
- package/CONTEXT.md +88 -1
- package/README.md +4 -0
- package/build/src/cli/assignment-provider.d.ts +144 -0
- package/build/src/cli/assignment-provider.js +805 -0
- 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/validate-workflow-artifacts.js +5 -1
- package/build/src/cli/workflow-sidecar.d.ts +2 -2
- package/build/src/cli/workflow-sidecar.js +549 -145
- package/build/src/cli.js +6 -0
- package/build/src/lib/flow-resolver.d.ts +12 -6
- package/build/src/lib/flow-resolver.js +30 -14
- package/build/src/tools/validate-source-tree.js +2 -0
- package/context/contracts/artifact-contract.md +2 -0
- package/context/contracts/assignment-provider-contract.md +248 -0
- package/context/contracts/builder-kit-workflow-state-contract.md +2 -0
- package/context/contracts/decision-registry-contract.md +2 -0
- package/context/contracts/delivery-contract.md +2 -0
- 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 +2 -0
- package/context/contracts/probe-docs-write-contract.md +187 -0
- package/context/contracts/review-contract.md +2 -0
- package/context/contracts/sandbox-policy.md +2 -0
- package/context/contracts/standing-directives.md +13 -0
- package/context/contracts/verification-contract.md +2 -0
- package/context/contracts/work-item-contract.md +2 -0
- package/context/scripts/hooks/config-protection.js +14 -1
- package/context/scripts/hooks/lib/config-protection-remedies.js +9 -0
- package/context/scripts/hooks/stop-goal-fit.js +4 -2
- package/context/scripts/hooks/workflow-steering.js +42 -0
- package/context/settings/assignment-provider-settings.json +33 -0
- package/docs/adr/0001-flow-agents-consumes-flow.md +2 -0
- package/docs/adr/0002-flow-kits-as-extension-unit.md +2 -0
- package/docs/adr/0003-flow-agents-coordinates-kits-and-adapters.md +2 -0
- 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/0006-typescript-first-source-policy.md +2 -0
- package/docs/adr/0007-flow-skill-kit-tool-boundary.md +2 -0
- package/docs/adr/0007-skill-audit.md +2 -0
- package/docs/adr/0008-kit-operation-boundary.md +2 -0
- package/docs/adr/0009-canonical-hook-core-kit-boundary.md +2 -0
- package/docs/adr/0010-workflow-trust-state-as-hachure-bundle.md +2 -0
- package/docs/adr/0011-mcp-posture.md +2 -0
- package/docs/adr/0012-agent-coordination-as-liveness-claims.md +2 -0
- package/docs/adr/0013-context-lifecycle.md +2 -0
- package/docs/adr/0014-core-vs-domain-kit-boundary.md +2 -0
- package/docs/adr/0015-flow-flow-agents-boundary-reconciliation.md +2 -0
- package/docs/adr/0016-three-hard-boundary-model.md +2 -0
- package/docs/adr/0017-anti-gaming-trust-security-model.md +2 -0
- package/docs/adr/0018-freeze-local-shell-heuristics.md +2 -0
- package/docs/adr/0019-kit-dependency-ownership.md +2 -0
- package/docs/adr/0020-trust-reconcile-manifest-and-claim-classification.md +2 -0
- package/docs/adr/0021-assignment-leases-and-stale-claim-takeover.md +3 -1
- package/docs/adr/0022-fail-closed-delivery-reconciliation-with-governed-exemptions.md +182 -0
- package/docs/adr/README.md +49 -0
- package/docs/adr/index.md +34 -0
- package/docs/context-map.md +1 -0
- package/docs/decisions/agent-coordination.md +20 -0
- package/docs/decisions/anti-gaming-trust-security.md +20 -0
- package/docs/decisions/context-lifecycle.md +18 -0
- package/docs/decisions/core-domain-kit-boundary.md +18 -0
- package/docs/decisions/flow-flow-agents-boundary.md +18 -0
- package/docs/decisions/flow-kit.md +20 -0
- package/docs/decisions/flow-skill-kit-tool-boundary.md +20 -0
- package/docs/decisions/graph-knowledge-provider.md +63 -0
- package/docs/decisions/hook-core-kit-boundary.md +18 -0
- package/docs/decisions/index.md +22 -0
- package/docs/decisions/kit-dependency-ownership.md +18 -0
- package/docs/decisions/kit-operation-boundary.md +18 -0
- package/docs/decisions/knowledge-promote-sub-flow.md +59 -0
- package/docs/decisions/knowledge-store-provider.md +51 -0
- package/docs/decisions/kontour-resource-contract.md +18 -0
- package/docs/decisions/mcp-posture.md +18 -0
- package/docs/decisions/model-routing.md +63 -0
- package/docs/decisions/standing-directives.md +66 -0
- package/docs/decisions/three-hard-boundary-model.md +18 -0
- package/docs/decisions/trust-reconcile.md +20 -0
- package/docs/decisions/typescript-source-policy.md +48 -0
- package/docs/decisions/workflow-enforcement.md +18 -0
- package/docs/decisions/workflow-trust-state.md +20 -0
- package/docs/fixture-ownership.md +1 -0
- package/docs/workflow-shared-contracts.md +2 -1
- package/docs/workflow-usage-guide.md +7 -1
- package/evals/ci/run-baseline.sh +10 -0
- 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/hostile-effective-state.json +11 -0
- package/evals/fixtures/assignment-provider/liveness-fresh.json +9 -0
- package/evals/fixtures/assignment-provider/liveness-stale.json +9 -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_critique_supersession_roundtrip.sh +182 -0
- package/evals/integration/test_current_json_per_actor.sh +516 -0
- package/evals/integration/test_ensure_session_ownership_guard.sh +435 -0
- package/evals/integration/test_fixture_retirement_audit.sh +2 -2
- package/evals/integration/test_gate_lockdown.sh +10 -0
- package/evals/integration/test_publish_delivery.sh +21 -4
- package/evals/integration/test_pull_work_assignment_join.sh +132 -0
- package/evals/integration/test_pull_work_liveness_preflight.sh +20 -7
- package/evals/integration/test_reconcile_soundness.sh +33 -9
- package/evals/integration/test_trust_reconcile.sh +9 -8
- package/evals/integration/test_trust_reconcile_negatives.sh +608 -0
- package/evals/integration/test_workflow_sidecar_writer.sh +91 -3
- package/evals/run.sh +14 -0
- package/evals/static/test_flowdef_codeowners_coverage.sh +6 -0
- package/evals/static/test_knowledge_providers.sh +32 -0
- package/evals/static/test_workflow_skills.sh +15 -2
- package/kits/builder/skills/deliver/SKILL.md +36 -0
- package/kits/builder/skills/design-probe/SKILL.md +37 -0
- package/kits/builder/skills/pickup-probe/SKILL.md +4 -4
- package/kits/builder/skills/pull-work/SKILL.md +78 -10
- package/kits/knowledge/adapters/default-store/index.js +92 -4
- package/kits/knowledge/adapters/obsidian-store/index.js +69 -4
- package/kits/knowledge/adapters/shared/codec.js +141 -0
- package/kits/knowledge/docs/README.md +121 -2
- package/kits/knowledge/docs/store-contract.md +112 -4
- package/kits/knowledge/evals/contract-suite/suite.test.js +176 -0
- package/kits/knowledge/flows/promote.flow.json +84 -0
- package/kits/knowledge/kit.json +50 -0
- package/kits/knowledge/promote/distill.js +96 -0
- package/kits/knowledge/promote/fixtures/contradiction-registry/CONTEXT.md +7 -0
- package/kits/knowledge/promote/fixtures/contradiction-registry/docs/decisions/cache-eviction-policy.md +12 -0
- package/kits/knowledge/promote/fixtures/contradiction-registry/docs/decisions/cache-eviction.md +12 -0
- package/kits/knowledge/promote/fixtures/repo/CONTEXT.md +11 -0
- package/kits/knowledge/promote/fixtures/repo/docs/decisions/index.md +9 -0
- package/kits/knowledge/promote/fixtures/repo/docs/decisions/liveness-claim.md +12 -0
- package/kits/knowledge/promote/fixtures/session/acceptance.json +9 -0
- package/kits/knowledge/promote/fixtures/session/agents/tool-planner/events.jsonl +1 -0
- package/kits/knowledge/promote/fixtures/session/agents/tool-verifier/events.jsonl +1 -0
- package/kits/knowledge/promote/fixtures/session/agents/tool-worker-1-1/events.jsonl +1 -0
- package/kits/knowledge/promote/fixtures/session/kontourai-flow-agents-287--deliver.md +47 -0
- package/kits/knowledge/promote/fixtures/session/learning.json +35 -0
- package/kits/knowledge/promote/fixtures/session/state.json +19 -0
- package/kits/knowledge/promote/health.js +137 -0
- package/kits/knowledge/promote/index.js +176 -0
- package/kits/knowledge/promote/ingest.js +103 -0
- package/kits/knowledge/promote/lib.js +132 -0
- package/kits/knowledge/promote/link.js +84 -0
- package/kits/knowledge/promote/promote.test.js +174 -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 +143 -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 +25 -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/neo4j/connection.js +121 -0
- package/kits/knowledge/providers/neo4j/cypher.js +190 -0
- package/kits/knowledge/providers/neo4j/fake-driver.js +123 -0
- package/kits/knowledge/providers/neo4j/fixtures/spike-ground-truth.json +29 -0
- package/kits/knowledge/providers/neo4j/graph-queries.js +210 -0
- package/kits/knowledge/providers/neo4j/index.js +280 -0
- package/kits/knowledge/providers/neo4j/integration.test.js +122 -0
- package/kits/knowledge/providers/neo4j/neo4j.test.js +219 -0
- package/kits/knowledge/providers/neo4j/sync.js +235 -0
- package/kits/knowledge/providers/work-item/index.js +204 -0
- package/package.json +7 -3
- package/schemas/assignment-provider-settings.schema.json +125 -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/scripts/README.md +1 -0
- package/scripts/ci/trust-reconcile.js +521 -24
- package/scripts/freeze-adrs.mjs +364 -0
- package/scripts/hooks/config-protection.js +14 -1
- package/scripts/hooks/evidence-capture.js +4 -1
- package/scripts/hooks/lib/config-protection-remedies.js +9 -0
- package/scripts/hooks/lib/current-pointer.js +123 -0
- package/scripts/hooks/lib/liveness-heartbeat.js +75 -35
- package/scripts/hooks/stop-goal-fit.js +4 -2
- package/scripts/hooks/workflow-steering.js +42 -0
- package/scripts/statusline/flow-agents-statusline.js +3 -1
- package/src/cli/assignment-provider.ts +927 -0
- package/src/cli/effective-assignment-provider-settings.ts +112 -0
- package/src/cli/validate-workflow-artifacts.ts +5 -1
- package/src/cli/workflow-sidecar.ts +577 -139
- package/src/cli.ts +6 -0
- package/src/lib/flow-resolver.ts +35 -14
- package/src/tools/validate-source-tree.ts +2 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_ensure_session_ownership_guard.sh — ensure-session's pre-entry ownership guard (#291).
|
|
3
|
+
#
|
|
4
|
+
# Exercises `enforceEnsureSessionOwnership()` (src/cli/workflow-sidecar.ts) against a temp
|
|
5
|
+
# ARTIFACT_ROOT, reusing #290's local-file assignment ⋈ liveness join
|
|
6
|
+
# (`computeEffectiveState`/`performLocalClaim`/`performLocalSupersede`, exported in
|
|
7
|
+
# src/cli/assignment-provider.ts). Fully deterministic: two fixed test-actor identities
|
|
8
|
+
# (--actor eval-actor-a-session / eval-actor-b-session), no network, no `gh` process. Follows
|
|
9
|
+
# test_assignment_provider_local_file.sh's pass/fail/json_query idiom exactly.
|
|
10
|
+
#
|
|
11
|
+
# Plan sections (see .kontourai/flow-agents/kontourai-flow-agents-291/
|
|
12
|
+
# kontourai-flow-agents-291--plan-work.md, Wave 3 "Ownership-guard eval"):
|
|
13
|
+
# 1. Actor A ensure-session on a free subject → exit 0; a durable local-file claim is
|
|
14
|
+
# established (AC5).
|
|
15
|
+
# 2. Actor B ensure-session on the SAME subject while A's claim is fresh (a real liveness event
|
|
16
|
+
# is manufactured so the join classifies it `held`, not merely `reclaimable`) → exit nonzero,
|
|
17
|
+
# naming A's holder identity (AC1); plus two hostile-string sanitization variants (AC9): a
|
|
18
|
+
# crafted hostile LIVENESS event (liveness-only holder, no assignment record) and the
|
|
19
|
+
# `hostile-effective-state.json` fixture via --effective-state-json (github-style hostile
|
|
20
|
+
# assignee string).
|
|
21
|
+
# 3. Actor A re-running ensure-session on its OWN subject → exit 0, no refusal (AC4).
|
|
22
|
+
# 4. A manufactured stale claim (real assignment record + a liveness event whose `at` is well
|
|
23
|
+
# past its ttlSeconds) → refuses without --supersede-stale (naming the flag), succeeds with
|
|
24
|
+
# --supersede-stale (AC2, both halves; audit-trail supersede entry confirmed).
|
|
25
|
+
# 5. A human-held fixture (assignment record with actor.human set) → any actor's ensure-session
|
|
26
|
+
# → exit nonzero, ask-first remediation, no auto-reclaim (AC3).
|
|
27
|
+
# 6. Concurrency: two REAL, concurrently-launched ensure-session processes on the same fresh
|
|
28
|
+
# subject (background `&` + `wait`, genuine OS-process concurrency, not a sequential
|
|
29
|
+
# simulation) → exactly one becomes the confirmed holder; the assignment record stays valid,
|
|
30
|
+
# single-holder, single-audit-entry JSON (no corrupted/partial write, no double claim) (AC6).
|
|
31
|
+
set -uo pipefail
|
|
32
|
+
|
|
33
|
+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
34
|
+
source "$ROOT/evals/lib/node.sh"
|
|
35
|
+
|
|
36
|
+
CLI="$ROOT/build/src/cli.js"
|
|
37
|
+
FIXTURES="$ROOT/evals/fixtures/assignment-provider"
|
|
38
|
+
HOSTILE_EFFECTIVE_STATE_FIXTURE="$FIXTURES/hostile-effective-state.json"
|
|
39
|
+
ACTOR_IDENTITY_HELPER="$ROOT/scripts/hooks/lib/actor-identity.js"
|
|
40
|
+
|
|
41
|
+
TMPDIR_EVAL="$(mktemp -d)"
|
|
42
|
+
trap 'rm -rf "$TMPDIR_EVAL"' EXIT
|
|
43
|
+
ARTIFACT_ROOT="$TMPDIR_EVAL/artifact-root"
|
|
44
|
+
|
|
45
|
+
errors=0
|
|
46
|
+
pass() { echo " ✓ $1"; }
|
|
47
|
+
fail() { echo " ✗ $1"; errors=$((errors + 1)); }
|
|
48
|
+
|
|
49
|
+
json_query() {
|
|
50
|
+
node -e 'const fs=require("fs"); let cur=JSON.parse(fs.readFileSync(process.argv[1],"utf8")); for (const part of process.argv[2].split(".")) cur=part==="length" ? cur.length : (Array.isArray(cur) ? cur[Number(part)] : cur[part]); console.log(cur);' "$1" "$2"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# actor_key_from_record <assignment-record.json> — recomputes the SAME holderActorKey
|
|
54
|
+
# computeEffectiveState (src/cli/assignment-provider.ts) itself derives: record.actor_key when
|
|
55
|
+
# present (F1 fix, fix-plan iteration 1 — the canonical resolveActor().actor string
|
|
56
|
+
# performLocalClaim/performLocalSupersede now persist), else serializeActor(record.actor) as a
|
|
57
|
+
# back-compat fallback for any pre-F1 record with no actor_key field. The eval never hand-derives
|
|
58
|
+
# (and risks drifting from) the actual holder-key format ensure-session's guard produces for an
|
|
59
|
+
# explicit --actor override.
|
|
60
|
+
actor_key_from_record() {
|
|
61
|
+
node -e '
|
|
62
|
+
const fs = require("fs");
|
|
63
|
+
const { serializeActor } = require(process.argv[1]);
|
|
64
|
+
const rec = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
65
|
+
process.stdout.write(rec.actor_key || serializeActor(rec.actor));
|
|
66
|
+
' "$ACTOR_IDENTITY_HELPER" "$1"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# append_liveness_event <root> <subjectId> <actor> <at-iso> [ttlSeconds]
|
|
70
|
+
append_liveness_event() {
|
|
71
|
+
local root="$1" subject="$2" actor="$3" at="$4" ttl="${5:-1800}"
|
|
72
|
+
mkdir -p "$root/liveness"
|
|
73
|
+
node -e '
|
|
74
|
+
const fs = require("fs");
|
|
75
|
+
const evt = { type: "claim", subjectId: process.argv[1], actor: process.argv[2], at: process.argv[3], ttlSeconds: Number(process.argv[4]) };
|
|
76
|
+
fs.appendFileSync(process.argv[5], JSON.stringify(evt) + "\n");
|
|
77
|
+
' "$subject" "$actor" "$at" "$ttl" "$root/liveness/events.jsonl"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if [[ ! -f "$CLI" ]]; then
|
|
81
|
+
echo "build/src/cli.js not found — run 'npm run build' first" >&2
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
84
|
+
flow_agents_build_ts || { echo "build failed" >&2; exit 1; }
|
|
85
|
+
|
|
86
|
+
echo "=== ensure-session ownership guard (#291) ==="
|
|
87
|
+
|
|
88
|
+
# ─── 1. Actor A claims a free subject via ensure-session (AC5) ─────────────────────────────
|
|
89
|
+
echo "--- 1. free subject: ensure-session establishes a durable claim (AC5) ---"
|
|
90
|
+
|
|
91
|
+
SUBJECT_WORK_ITEM="kontourai/flow-agents#9101"
|
|
92
|
+
SLUG="kontourai-flow-agents-9101"
|
|
93
|
+
|
|
94
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
95
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
96
|
+
--work-item "$SUBJECT_WORK_ITEM" \
|
|
97
|
+
--actor eval-actor-a-session \
|
|
98
|
+
--source-request "Actor A claims a free subject." \
|
|
99
|
+
--summary "Actor A establishes the first claim on a free subject." \
|
|
100
|
+
>"$TMPDIR_EVAL/a-ensure.out" 2>"$TMPDIR_EVAL/a-ensure.err"; then
|
|
101
|
+
pass "actor A's ensure-session on a free subject exits 0 (AC5)"
|
|
102
|
+
else
|
|
103
|
+
fail "actor A's ensure-session on a free subject unexpectedly failed: $(cat "$TMPDIR_EVAL/a-ensure.out" "$TMPDIR_EVAL/a-ensure.err")"
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
node "$CLI" assignment-provider status \
|
|
107
|
+
--provider local-file --artifact-root "$ARTIFACT_ROOT" --subject-id "$SLUG" \
|
|
108
|
+
> "$TMPDIR_EVAL/status-after-a.json"
|
|
109
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-after-a.json" "assignment.record.status")" == "claimed" ]] && pass "assignment-provider status confirms a durable claim record exists for actor A (AC5)" || fail "assignment-provider status did not show a durable claim record for actor A: $(cat "$TMPDIR_EVAL/status-after-a.json")"
|
|
110
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-after-a.json" "assignment.assignee")" == *"eval-actor-a-session"* ]] && pass "assignment-provider status reports actor A as the claim holder (AC5)" || fail "assignment-provider status did not report actor A as holder: $(cat "$TMPDIR_EVAL/status-after-a.json")"
|
|
111
|
+
|
|
112
|
+
A_RECORD="$ARTIFACT_ROOT/assignment/$SLUG.json"
|
|
113
|
+
[[ -f "$A_RECORD" ]] && pass "ensure-session's free-branch claim wrote assignment/$SLUG.json (AC5)" || fail "ensure-session's free-branch claim did not write assignment/$SLUG.json"
|
|
114
|
+
ACTOR_KEY_A="$(actor_key_from_record "$A_RECORD")"
|
|
115
|
+
[[ -n "$ACTOR_KEY_A" ]] && pass "actor A's serialized actor key was recovered from the on-disk record" || fail "could not recover actor A's serialized actor key from the on-disk record"
|
|
116
|
+
|
|
117
|
+
# ─── 2. Actor B refused on A's fresh claim (AC1), plus two AC9 sanitization variants ────────
|
|
118
|
+
echo "--- 2. fresh other-actor claim refuses entry (AC1); hostile-string sanitization (AC9) ---"
|
|
119
|
+
|
|
120
|
+
NOW_ISO="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
121
|
+
append_liveness_event "$ARTIFACT_ROOT" "$SLUG" "$ACTOR_KEY_A" "$NOW_ISO" 1800
|
|
122
|
+
|
|
123
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
124
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
125
|
+
--work-item "$SUBJECT_WORK_ITEM" \
|
|
126
|
+
--actor eval-actor-b-session \
|
|
127
|
+
--source-request "Actor B attempts to enter A's fresh claim." \
|
|
128
|
+
--summary "Actor B should be refused." \
|
|
129
|
+
>"$TMPDIR_EVAL/b-ensure.out" 2>"$TMPDIR_EVAL/b-ensure.err"; then
|
|
130
|
+
fail "actor B's ensure-session on A's fresh-held subject should have exited nonzero (AC1)"
|
|
131
|
+
else
|
|
132
|
+
pass "actor B's ensure-session on A's fresh-held subject exits nonzero (AC1)"
|
|
133
|
+
fi
|
|
134
|
+
grep -qF "eval-actor-a-session" "$TMPDIR_EVAL/b-ensure.err" && pass "refusal message names actor A's holder identity (AC1)" || fail "refusal message did not name actor A's holder identity: $(cat "$TMPDIR_EVAL/b-ensure.err")"
|
|
135
|
+
grep -qiF "takeover" "$TMPDIR_EVAL/b-ensure.err" && pass "refusal message offers remediation (pick different work or consider a takeover) (AC1)" || fail "refusal message lacked remediation text: $(cat "$TMPDIR_EVAL/b-ensure.err")"
|
|
136
|
+
|
|
137
|
+
B_DIR="$ARTIFACT_ROOT/$SLUG"
|
|
138
|
+
# A's session dir already legitimately exists (A owns it, from section 1) — a refused entry must
|
|
139
|
+
# never leave any trace of actor B's identity in A's own sidecar.
|
|
140
|
+
if grep -qF "eval-actor-b-session" "$B_DIR/state.json" 2>/dev/null; then
|
|
141
|
+
fail "actor B's refused entry unexpectedly left a trace in A's state.json"
|
|
142
|
+
else
|
|
143
|
+
pass "actor B's refused entry left no trace in A's state.json"
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# AC9 variant 1: a crafted HOSTILE liveness event (no assignment record at all — the
|
|
147
|
+
# "liveness_claim_present_assignment_lagging" join row) — proves the guard sanitizes a holder
|
|
148
|
+
# actor string sourced directly from an attacker-postable liveness stream, not merely from a
|
|
149
|
+
# well-formed assignment record.
|
|
150
|
+
HOSTILE_LIVENESS_SLUG="ensure-guard-hostile-liveness"
|
|
151
|
+
HOSTILE_LIVENESS_ACTOR=$'hostile-liveness-actor\x1b[31;1mFAKE\x07-holder'
|
|
152
|
+
append_liveness_event "$ARTIFACT_ROOT" "$HOSTILE_LIVENESS_SLUG" "$HOSTILE_LIVENESS_ACTOR" "$NOW_ISO" 1800
|
|
153
|
+
|
|
154
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
155
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
156
|
+
--task-slug "$HOSTILE_LIVENESS_SLUG" \
|
|
157
|
+
--actor eval-actor-hostile-reader \
|
|
158
|
+
--source-request "Reader against a hostile liveness-only holder." \
|
|
159
|
+
--summary "Should refuse, sanitized." \
|
|
160
|
+
>"$TMPDIR_EVAL/hostile-liveness.out" 2>"$TMPDIR_EVAL/hostile-liveness.err"; then
|
|
161
|
+
fail "ensure-session against a hostile liveness-only holder should have refused (AC1, AC9)"
|
|
162
|
+
else
|
|
163
|
+
pass "ensure-session against a hostile liveness-only holder refuses (AC1 liveness_claim_present_assignment_lagging row, AC9)"
|
|
164
|
+
fi
|
|
165
|
+
if grep -qF $'\x1b[31;1m' "$TMPDIR_EVAL/hostile-liveness.err" || grep -qF $'\x07' "$TMPDIR_EVAL/hostile-liveness.err"; then
|
|
166
|
+
fail "hostile liveness-event holder actor's raw ANSI/control bytes leaked into the refusal message (AC9)"
|
|
167
|
+
else
|
|
168
|
+
pass "hostile liveness-event holder actor's raw ANSI/control bytes never leak into the refusal message (AC9)"
|
|
169
|
+
fi
|
|
170
|
+
grep -qF "hostile-liveness-actor" "$TMPDIR_EVAL/hostile-liveness.err" && pass "the sanitized (non-control-byte) portion of the hostile holder actor string still appears in the refusal message (AC9)" || fail "sanitized portion of the hostile holder actor string was unexpectedly dropped entirely: $(cat "$TMPDIR_EVAL/hostile-liveness.err")"
|
|
171
|
+
|
|
172
|
+
# AC9 variant 2: hostile-effective-state.json (github-style hostile assignee string) via
|
|
173
|
+
# --effective-state-json — the escape hatch for non-local-file providers (Conflict #5).
|
|
174
|
+
HOSTILE_EFFECTIVE_SLUG="ensure-guard-hostile-effective-state"
|
|
175
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
176
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
177
|
+
--task-slug "$HOSTILE_EFFECTIVE_SLUG" \
|
|
178
|
+
--actor eval-actor-hostile-reader-2 \
|
|
179
|
+
--effective-state-json "$HOSTILE_EFFECTIVE_STATE_FIXTURE" \
|
|
180
|
+
--source-request "Reader against a hostile precomputed effective-state fixture." \
|
|
181
|
+
--summary "Should refuse, sanitized." \
|
|
182
|
+
>"$TMPDIR_EVAL/hostile-effective.out" 2>"$TMPDIR_EVAL/hostile-effective.err"; then
|
|
183
|
+
fail "ensure-session --effective-state-json against the hostile fixture should have refused (AC3, AC9)"
|
|
184
|
+
else
|
|
185
|
+
pass "ensure-session --effective-state-json against the hostile fixture refuses (human-held, AC3, AC9)"
|
|
186
|
+
fi
|
|
187
|
+
if grep -qF $'\x1b[31;1m' "$TMPDIR_EVAL/hostile-effective.err" || grep -qF $'\x07' "$TMPDIR_EVAL/hostile-effective.err"; then
|
|
188
|
+
fail "hostile --effective-state-json assignee's raw ANSI/control bytes leaked into the refusal message (AC9)"
|
|
189
|
+
else
|
|
190
|
+
pass "hostile --effective-state-json assignee's raw ANSI/control bytes never leak into the refusal message (AC9)"
|
|
191
|
+
fi
|
|
192
|
+
grep -qF "hostile-assignee" "$TMPDIR_EVAL/hostile-effective.err" && pass "the sanitized portion of the hostile --effective-state-json assignee string still appears in the refusal message (AC9)" || fail "sanitized portion of the hostile --effective-state-json assignee string was unexpectedly dropped entirely: $(cat "$TMPDIR_EVAL/hostile-effective.err")"
|
|
193
|
+
|
|
194
|
+
# ─── 3. Actor A re-entering its own subject succeeds (AC4) ─────────────────────────────────
|
|
195
|
+
echo "--- 3. self re-entry succeeds with no spurious refusal (AC4) ---"
|
|
196
|
+
|
|
197
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
198
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
199
|
+
--work-item "$SUBJECT_WORK_ITEM" \
|
|
200
|
+
--actor eval-actor-a-session \
|
|
201
|
+
--source-request "Actor A resumes its own session." \
|
|
202
|
+
--summary "Actor A resumes." \
|
|
203
|
+
>"$TMPDIR_EVAL/a-reentry.out" 2>"$TMPDIR_EVAL/a-reentry.err"; then
|
|
204
|
+
pass "actor A re-running ensure-session on its own fresh claim succeeds (AC4)"
|
|
205
|
+
else
|
|
206
|
+
fail "actor A's self re-entry unexpectedly refused: $(cat "$TMPDIR_EVAL/a-reentry.out" "$TMPDIR_EVAL/a-reentry.err")"
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
# ─── 3b. F1 (fix-plan iteration 1, HIGH): cross-tool self-recognition for an EXPLICIT-OVERRIDE
|
|
210
|
+
# actor (FLOW_AGENTS_ACTOR / --actor). This is the reviewer's exact live repro: a claim
|
|
211
|
+
# established via ensure-session under a bare override value must be recognized as self by a
|
|
212
|
+
# DIFFERENT tool invocation (`assignment-provider status --self-actor <bare value>`), and a fresh
|
|
213
|
+
# liveness heartbeat for that same bare value must join against the claim record too. Before the
|
|
214
|
+
# fix, computeEffectiveState keyed everything on serializeActor(record.actor) — a TRIPLE
|
|
215
|
+
# (`explicit-override:<value>:<host>`) for an override actor — while every other tool (including
|
|
216
|
+
# --self-actor here) uses the BARE value, so this cross-tool check failed even though the guard's
|
|
217
|
+
# OWN internal self-check passed (it always re-derives the same wrapped key on both sides).
|
|
218
|
+
echo "--- 3b. cross-tool self-recognition for an explicit-override actor: assignment-provider status --self-actor recognizes an ensure-session claim (F1, fix-plan iteration 1) ---"
|
|
219
|
+
|
|
220
|
+
CANONICAL_WORK_ITEM="kontourai/flow-agents#9103"
|
|
221
|
+
CANONICAL_SLUG="kontourai-flow-agents-9103"
|
|
222
|
+
CANONICAL_ACTOR="canonical-x"
|
|
223
|
+
|
|
224
|
+
if FLOW_AGENTS_ACTOR="$CANONICAL_ACTOR" flow_agents_node "workflow-sidecar" ensure-session \
|
|
225
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
226
|
+
--work-item "$CANONICAL_WORK_ITEM" \
|
|
227
|
+
--source-request "canonical-x claims a free subject via FLOW_AGENTS_ACTOR (no --actor flag)." \
|
|
228
|
+
--summary "canonical-x establishes the first claim." \
|
|
229
|
+
>"$TMPDIR_EVAL/canonical-ensure.out" 2>"$TMPDIR_EVAL/canonical-ensure.err"; then
|
|
230
|
+
pass "FLOW_AGENTS_ACTOR=canonical-x ensure-session on a free subject exits 0 (F1 setup)"
|
|
231
|
+
else
|
|
232
|
+
fail "FLOW_AGENTS_ACTOR=canonical-x ensure-session unexpectedly failed: $(cat "$TMPDIR_EVAL/canonical-ensure.out" "$TMPDIR_EVAL/canonical-ensure.err")"
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
CANONICAL_RECORD="$ARTIFACT_ROOT/assignment/$CANONICAL_SLUG.json"
|
|
236
|
+
[[ -f "$CANONICAL_RECORD" ]] && pass "canonical-x's claim record exists on disk (F1 setup)" || fail "canonical-x's claim record was not written"
|
|
237
|
+
CANONICAL_ACTOR_KEY_FIELD="$(json_query "$CANONICAL_RECORD" "actor_key")"
|
|
238
|
+
if [[ "$CANONICAL_ACTOR_KEY_FIELD" == "$CANONICAL_ACTOR" ]]; then
|
|
239
|
+
pass "the claim record's actor_key is the canonical BARE value 'canonical-x', not a serialized explicit-override triple (F1)"
|
|
240
|
+
else
|
|
241
|
+
fail "the claim record's actor_key was not the expected bare canonical value: got '$CANONICAL_ACTOR_KEY_FIELD'"
|
|
242
|
+
fi
|
|
243
|
+
|
|
244
|
+
# (a) assignment-provider status --self-actor canonical-x (the BARE value, exactly what
|
|
245
|
+
# `liveness whoami` / `liveness claim --actor` / pull-work's --self-actor would all use) must
|
|
246
|
+
# recognize this claim as self -- effective_state:held, reason:self_is_holder, NOT reclaimable.
|
|
247
|
+
node "$CLI" assignment-provider status \
|
|
248
|
+
--provider local-file --artifact-root "$ARTIFACT_ROOT" --subject-id "$CANONICAL_SLUG" \
|
|
249
|
+
--liveness-events-json <(echo '[]') \
|
|
250
|
+
--self-actor "$CANONICAL_ACTOR" \
|
|
251
|
+
> "$TMPDIR_EVAL/status-canonical-self.json"
|
|
252
|
+
CANONICAL_SELF_STATE="$(json_query "$TMPDIR_EVAL/status-canonical-self.json" "effective.effective_state")"
|
|
253
|
+
CANONICAL_SELF_REASON="$(json_query "$TMPDIR_EVAL/status-canonical-self.json" "effective.reason")"
|
|
254
|
+
if [[ "$CANONICAL_SELF_STATE" == "held" && "$CANONICAL_SELF_REASON" == "self_is_holder" ]]; then
|
|
255
|
+
pass "assignment-provider status --self-actor canonical-x (bare value) recognizes the ensure-session claim as self: held/self_is_holder, not reclaimable (F1 -- the reviewer's exact repro, now fixed)"
|
|
256
|
+
else
|
|
257
|
+
fail "assignment-provider status --self-actor canonical-x did NOT recognize the claim as self: effective_state=$CANONICAL_SELF_STATE reason=$CANONICAL_SELF_REASON (expected held/self_is_holder): $(cat "$TMPDIR_EVAL/status-canonical-self.json")"
|
|
258
|
+
fi
|
|
259
|
+
|
|
260
|
+
# (b) symmetric case: a FRESH liveness heartbeat for canonical-x (the bare value, exactly what a
|
|
261
|
+
# real heartbeat/liveness-claim event would record as `actor`) must join against the SAME record
|
|
262
|
+
# via fresh_liveness_heartbeat, with a DIFFERENT (or no) --self-actor -- proving the join itself
|
|
263
|
+
# matches on the canonical actor_key, not merely the redundant self-check.
|
|
264
|
+
CANONICAL_HEARTBEAT_NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
265
|
+
append_liveness_event "$ARTIFACT_ROOT" "$CANONICAL_SLUG" "$CANONICAL_ACTOR" "$CANONICAL_HEARTBEAT_NOW" 1800
|
|
266
|
+
|
|
267
|
+
node "$CLI" assignment-provider status \
|
|
268
|
+
--provider local-file --artifact-root "$ARTIFACT_ROOT" --subject-id "$CANONICAL_SLUG" \
|
|
269
|
+
--liveness-stream "$ARTIFACT_ROOT/liveness/events.jsonl" \
|
|
270
|
+
--self-actor "eval-actor-some-other-reader" \
|
|
271
|
+
> "$TMPDIR_EVAL/status-canonical-heartbeat.json"
|
|
272
|
+
CANONICAL_HEARTBEAT_STATE="$(json_query "$TMPDIR_EVAL/status-canonical-heartbeat.json" "effective.effective_state")"
|
|
273
|
+
CANONICAL_HEARTBEAT_REASON="$(json_query "$TMPDIR_EVAL/status-canonical-heartbeat.json" "effective.reason")"
|
|
274
|
+
if [[ "$CANONICAL_HEARTBEAT_STATE" == "held" && "$CANONICAL_HEARTBEAT_REASON" == "fresh_liveness_heartbeat" ]]; then
|
|
275
|
+
pass "a fresh liveness heartbeat for canonical-x (bare value) joins against the ensure-session claim via fresh_liveness_heartbeat, under a DIFFERENT self-actor (F1 -- proves the assignment <-> liveness join itself matches, not just the self-check)"
|
|
276
|
+
else
|
|
277
|
+
fail "the fresh liveness heartbeat for canonical-x did not join against the claim: effective_state=$CANONICAL_HEARTBEAT_STATE reason=$CANONICAL_HEARTBEAT_REASON (expected held/fresh_liveness_heartbeat): $(cat "$TMPDIR_EVAL/status-canonical-heartbeat.json")"
|
|
278
|
+
fi
|
|
279
|
+
|
|
280
|
+
# ─── 4. Stale (reclaimable) claim: refuse without the flag, succeed with it (AC2) ──────────
|
|
281
|
+
echo "--- 4. reclaimable (stale) claim: refuse without --supersede-stale, succeed with it (AC2) ---"
|
|
282
|
+
|
|
283
|
+
STALE_SLUG="ensure-guard-stale-takeover"
|
|
284
|
+
flow_agents_node "workflow-sidecar" ensure-session \
|
|
285
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
286
|
+
--task-slug "$STALE_SLUG" \
|
|
287
|
+
--actor eval-actor-stale-holder \
|
|
288
|
+
--source-request "Establish the original (soon-to-be-stale) claim." \
|
|
289
|
+
--summary "Original holder." \
|
|
290
|
+
>"$TMPDIR_EVAL/stale-setup.out" 2>"$TMPDIR_EVAL/stale-setup.err"
|
|
291
|
+
STALE_RECORD="$ARTIFACT_ROOT/assignment/$STALE_SLUG.json"
|
|
292
|
+
ACTOR_KEY_STALE_HOLDER="$(actor_key_from_record "$STALE_RECORD")"
|
|
293
|
+
# A liveness event whose `at` is well past ttlSeconds (1800s) relative to real wall-clock now —
|
|
294
|
+
# matches evals/fixtures/assignment-provider/liveness-stale.json's "well in the past" convention.
|
|
295
|
+
append_liveness_event "$ARTIFACT_ROOT" "$STALE_SLUG" "$ACTOR_KEY_STALE_HOLDER" "2026-06-01T10:00:00Z" 1800
|
|
296
|
+
|
|
297
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
298
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
299
|
+
--task-slug "$STALE_SLUG" \
|
|
300
|
+
--actor eval-actor-b-session \
|
|
301
|
+
--source-request "Actor B attempts a stale takeover without --supersede-stale." \
|
|
302
|
+
--summary "Should refuse, naming the flag." \
|
|
303
|
+
>"$TMPDIR_EVAL/stale-refuse.out" 2>"$TMPDIR_EVAL/stale-refuse.err"; then
|
|
304
|
+
fail "ensure-session on a reclaimable (stale) subject without --supersede-stale should have refused (AC2)"
|
|
305
|
+
else
|
|
306
|
+
pass "ensure-session on a reclaimable (stale) subject without --supersede-stale refuses (AC2)"
|
|
307
|
+
fi
|
|
308
|
+
grep -qF -- "--supersede-stale" "$TMPDIR_EVAL/stale-refuse.err" && pass "stale-claim refusal names --supersede-stale explicitly (AC2)" || fail "stale-claim refusal did not name --supersede-stale: $(cat "$TMPDIR_EVAL/stale-refuse.err")"
|
|
309
|
+
|
|
310
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
311
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
312
|
+
--task-slug "$STALE_SLUG" \
|
|
313
|
+
--actor eval-actor-b-session \
|
|
314
|
+
--supersede-stale \
|
|
315
|
+
--source-request "Actor B takes over the stale claim explicitly." \
|
|
316
|
+
--summary "Explicit takeover." \
|
|
317
|
+
>"$TMPDIR_EVAL/stale-supersede.out" 2>"$TMPDIR_EVAL/stale-supersede.err"; then
|
|
318
|
+
pass "ensure-session --supersede-stale on a reclaimable (stale) subject succeeds (AC2)"
|
|
319
|
+
else
|
|
320
|
+
fail "ensure-session --supersede-stale on a reclaimable (stale) subject unexpectedly failed: $(cat "$TMPDIR_EVAL/stale-supersede.out" "$TMPDIR_EVAL/stale-supersede.err")"
|
|
321
|
+
fi
|
|
322
|
+
|
|
323
|
+
node "$CLI" assignment-provider status \
|
|
324
|
+
--provider local-file --artifact-root "$ARTIFACT_ROOT" --subject-id "$STALE_SLUG" \
|
|
325
|
+
> "$TMPDIR_EVAL/status-after-supersede.json"
|
|
326
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-after-supersede.json" "assignment.assignee")" == *"eval-actor-b-session"* ]] && pass "assignment-provider status confirms actor B is the new holder after --supersede-stale takeover (AC2)" || fail "assignment-provider status did not confirm actor B as the new holder: $(cat "$TMPDIR_EVAL/status-after-supersede.json")"
|
|
327
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-after-supersede.json" "assignment.record.audit_trail.length")" == "2" ]] && pass "supersede takeover appended a second audit_trail entry (claim + supersede) (AC2)" || fail "supersede takeover did not append a second audit_trail entry: $(cat "$TMPDIR_EVAL/status-after-supersede.json")"
|
|
328
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-after-supersede.json" "assignment.record.audit_trail.1.transition")" == "supersede" ]] && pass "audit trail records the supersede transition from the stale-claim takeover (AC2)" || fail "audit trail did not record a supersede transition: $(cat "$TMPDIR_EVAL/status-after-supersede.json")"
|
|
329
|
+
|
|
330
|
+
# ─── 5. Human-held: never auto-reclaims (AC3) ──────────────────────────────────────────────
|
|
331
|
+
echo "--- 5. human-held subject: ask-first refusal, never auto-reclaims (AC3) ---"
|
|
332
|
+
|
|
333
|
+
HUMAN_SLUG="ensure-guard-human-held"
|
|
334
|
+
mkdir -p "$ARTIFACT_ROOT/assignment"
|
|
335
|
+
cat > "$ARTIFACT_ROOT/assignment/$HUMAN_SLUG.json" <<HUMANEOF
|
|
336
|
+
{
|
|
337
|
+
"schema_version": "1.0",
|
|
338
|
+
"role": "AssignmentClaimRecord",
|
|
339
|
+
"subject_id": "$HUMAN_SLUG",
|
|
340
|
+
"actor": {
|
|
341
|
+
"runtime": "github",
|
|
342
|
+
"session_id": "n-a",
|
|
343
|
+
"host": "n-a",
|
|
344
|
+
"human": "alice-human"
|
|
345
|
+
},
|
|
346
|
+
"claimed_at": "2026-06-15T09:00:00Z",
|
|
347
|
+
"ttl_seconds": 1800,
|
|
348
|
+
"branch": "main",
|
|
349
|
+
"artifact_dir": "$HUMAN_SLUG",
|
|
350
|
+
"status": "claimed",
|
|
351
|
+
"audit_trail": [
|
|
352
|
+
{ "at": "2026-06-15T09:00:00Z", "transition": "claim", "from_actor": null, "to_actor": { "runtime": "github", "session_id": "n-a", "host": "n-a", "human": "alice-human" }, "reason": "human assignment" }
|
|
353
|
+
]
|
|
354
|
+
}
|
|
355
|
+
HUMANEOF
|
|
356
|
+
HUMAN_RECORD_BEFORE="$(cat "$ARTIFACT_ROOT/assignment/$HUMAN_SLUG.json")"
|
|
357
|
+
|
|
358
|
+
if flow_agents_node "workflow-sidecar" ensure-session \
|
|
359
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
360
|
+
--task-slug "$HUMAN_SLUG" \
|
|
361
|
+
--actor eval-actor-c-session \
|
|
362
|
+
--source-request "Any actor attempts entry on a human-held subject." \
|
|
363
|
+
--summary "Should refuse, ask-first." \
|
|
364
|
+
>"$TMPDIR_EVAL/human-held.out" 2>"$TMPDIR_EVAL/human-held.err"; then
|
|
365
|
+
fail "ensure-session on a human-held subject should have refused (AC3)"
|
|
366
|
+
else
|
|
367
|
+
pass "ensure-session on a human-held subject refuses (AC3)"
|
|
368
|
+
fi
|
|
369
|
+
grep -qiF "human" "$TMPDIR_EVAL/human-held.err" && pass "human-held refusal message references the human assignment (AC3)" || fail "human-held refusal message did not reference the human assignment: $(cat "$TMPDIR_EVAL/human-held.err")"
|
|
370
|
+
grep -qiF "confirm" "$TMPDIR_EVAL/human-held.err" && pass "human-held refusal message asks for confirmation before proceeding, never auto-reclaims (AC3)" || fail "human-held refusal message lacked ask-first remediation: $(cat "$TMPDIR_EVAL/human-held.err")"
|
|
371
|
+
[[ ! -d "$ARTIFACT_ROOT/$HUMAN_SLUG" ]] && pass "human-held refusal never created a session directory (no auto-reclaim side effect) (AC3)" || fail "human-held refusal unexpectedly created a session directory"
|
|
372
|
+
HUMAN_RECORD_AFTER="$(cat "$ARTIFACT_ROOT/assignment/$HUMAN_SLUG.json")"
|
|
373
|
+
[[ "$HUMAN_RECORD_BEFORE" == "$HUMAN_RECORD_AFTER" ]] && pass "human-held assignment record is byte-identical after the refused attempt (never auto-reclaimed) (AC3)" || fail "human-held assignment record was mutated by a refused ensure-session attempt"
|
|
374
|
+
|
|
375
|
+
# ─── 6. Concurrency: exactly one holder, no corrupted/partial record (AC6) ─────────────────
|
|
376
|
+
echo "--- 6. genuine concurrent ensure-session race: exactly one holder wins (AC6) ---"
|
|
377
|
+
|
|
378
|
+
RACE_SLUG="ensure-guard-race"
|
|
379
|
+
(
|
|
380
|
+
flow_agents_node "workflow-sidecar" ensure-session \
|
|
381
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
382
|
+
--task-slug "$RACE_SLUG" \
|
|
383
|
+
--actor eval-race-actor-a \
|
|
384
|
+
--source-request "Race participant A." \
|
|
385
|
+
--summary "Race participant A." \
|
|
386
|
+
>"$TMPDIR_EVAL/race-a.out" 2>"$TMPDIR_EVAL/race-a.err"
|
|
387
|
+
echo $? > "$TMPDIR_EVAL/race-a.rc"
|
|
388
|
+
) &
|
|
389
|
+
RACE_PID_A=$!
|
|
390
|
+
(
|
|
391
|
+
flow_agents_node "workflow-sidecar" ensure-session \
|
|
392
|
+
--artifact-root "$ARTIFACT_ROOT" \
|
|
393
|
+
--task-slug "$RACE_SLUG" \
|
|
394
|
+
--actor eval-race-actor-b \
|
|
395
|
+
--source-request "Race participant B." \
|
|
396
|
+
--summary "Race participant B." \
|
|
397
|
+
>"$TMPDIR_EVAL/race-b.out" 2>"$TMPDIR_EVAL/race-b.err"
|
|
398
|
+
echo $? > "$TMPDIR_EVAL/race-b.rc"
|
|
399
|
+
) &
|
|
400
|
+
RACE_PID_B=$!
|
|
401
|
+
wait "$RACE_PID_A" "$RACE_PID_B"
|
|
402
|
+
|
|
403
|
+
RACE_RC_A="$(cat "$TMPDIR_EVAL/race-a.rc")"
|
|
404
|
+
RACE_RC_B="$(cat "$TMPDIR_EVAL/race-b.rc")"
|
|
405
|
+
if { [[ "$RACE_RC_A" -eq 0 && "$RACE_RC_B" -ne 0 ]] || [[ "$RACE_RC_A" -ne 0 && "$RACE_RC_B" -eq 0 ]]; }; then
|
|
406
|
+
pass "genuine concurrent ensure-session race: exactly one process wins (rc_a=$RACE_RC_A rc_b=$RACE_RC_B) (AC6)"
|
|
407
|
+
else
|
|
408
|
+
fail "genuine concurrent ensure-session race: exactly one process should win (rc_a=$RACE_RC_A rc_b=$RACE_RC_B) (AC6)"
|
|
409
|
+
fi
|
|
410
|
+
|
|
411
|
+
RACE_RECORD="$ARTIFACT_ROOT/assignment/$RACE_SLUG.json"
|
|
412
|
+
if node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$RACE_RECORD" 2>/dev/null; then
|
|
413
|
+
pass "race winner's on-disk assignment record is valid, uncorrupted JSON (AC6)"
|
|
414
|
+
else
|
|
415
|
+
fail "race winner's on-disk assignment record is missing or corrupted JSON (AC6)"
|
|
416
|
+
fi
|
|
417
|
+
node "$CLI" assignment-provider status \
|
|
418
|
+
--provider local-file --artifact-root "$ARTIFACT_ROOT" --subject-id "$RACE_SLUG" \
|
|
419
|
+
> "$TMPDIR_EVAL/status-race.json"
|
|
420
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-race.json" "assignment.record.audit_trail.length")" == "1" ]] && pass "race winner's on-disk record has exactly one audit_trail entry (no lost/merged/double claim) (AC6)" || fail "race winner's on-disk record does not have exactly one audit_trail entry: $(cat "$TMPDIR_EVAL/status-race.json")"
|
|
421
|
+
|
|
422
|
+
if [[ "$RACE_RC_A" -eq 0 ]]; then
|
|
423
|
+
EXPECTED_RACE_HOLDER="eval-race-actor-a"
|
|
424
|
+
else
|
|
425
|
+
EXPECTED_RACE_HOLDER="eval-race-actor-b"
|
|
426
|
+
fi
|
|
427
|
+
[[ "$(json_query "$TMPDIR_EVAL/status-race.json" "assignment.assignee")" == *"$EXPECTED_RACE_HOLDER"* ]] && pass "on-disk record holder matches the process that actually exited 0 (no silent overwrite by the loser) (AC6)" || fail "on-disk record holder does not match the winning process: $(cat "$TMPDIR_EVAL/status-race.json")"
|
|
428
|
+
|
|
429
|
+
echo ""
|
|
430
|
+
if [[ "$errors" -eq 0 ]]; then
|
|
431
|
+
echo "test_ensure_session_ownership_guard: all checks passed."
|
|
432
|
+
else
|
|
433
|
+
echo "test_ensure_session_ownership_guard: $errors check(s) failed."
|
|
434
|
+
fi
|
|
435
|
+
exit "$errors"
|
|
@@ -21,9 +21,9 @@ json_query() {
|
|
|
21
21
|
node -e 'const fs=require("fs"); let cur=JSON.parse(fs.readFileSync(process.argv[1],"utf8")); for (const part of process.argv[2].split(".")) cur=Array.isArray(cur) ? cur[Number(part)] : cur[part]; console.log(cur);' "$1" "$2"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
[[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.scanned")" == "
|
|
24
|
+
[[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.scanned")" == "15" ]] && pass "audit scans all fixture groups" || fail "audit scans all fixture groups"
|
|
25
25
|
[[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.retire_candidates")" == "0" ]] && pass "audit finds no unowned retire candidates" || fail "audit finds no unowned retire candidates"
|
|
26
|
-
[[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.kept")" == "
|
|
26
|
+
[[ "$(json_query "$TMPDIR_EVAL/audit.json" "totals.kept")" == "15" ]] && pass "audit keeps all owned fixture groups" || fail "audit keeps all owned fixture groups"
|
|
27
27
|
|
|
28
28
|
node - "$TMPDIR_EVAL/audit.json" <<'NODE'
|
|
29
29
|
const fs = require("node:fs");
|
|
@@ -829,6 +829,13 @@ mkdir -p "$ISO_DIR/repo/.kontourai/flow-agents/surftest"
|
|
|
829
829
|
mkdir -p "$ISO_DIR/lib"
|
|
830
830
|
cp "$GATE" "$ISO_DIR/stop-goal-fit.js"
|
|
831
831
|
cp "$ROOT/scripts/hooks/lib/local-artifact-paths.js" "$ISO_DIR/lib/"
|
|
832
|
+
# #291: stop-goal-fit.js now also requires scripts/hooks/lib/actor-identity.js and
|
|
833
|
+
# scripts/hooks/lib/current-pointer.js (the per-actor current.json compat-shim read helper)
|
|
834
|
+
# -- both must be mirrored into this isolated copy too, or the isolated gate crashes on
|
|
835
|
+
# MODULE_NOT_FOUND before it ever reaches the surface-unavailable fail-closed path this
|
|
836
|
+
# section is testing.
|
|
837
|
+
cp "$ROOT/scripts/hooks/lib/actor-identity.js" "$ISO_DIR/lib/"
|
|
838
|
+
cp "$ROOT/scripts/hooks/lib/current-pointer.js" "$ISO_DIR/lib/"
|
|
832
839
|
printf '# Repo\n' > "$ISO_DIR/repo/AGENTS.md"
|
|
833
840
|
# Non-terminal session (execution phase, in_progress status)
|
|
834
841
|
printf '%s' '{"schema_version":"1.0","task_slug":"surftest","status":"in_progress","phase":"execution","updated_at":"2026-06-27T00:00:00Z","next_action":{"status":"in_progress","summary":"running"}}' \
|
|
@@ -875,6 +882,9 @@ mkdir -p "$ISO2_DIR/repo/.kontourai/flow-agents/lowtest"
|
|
|
875
882
|
mkdir -p "$ISO2_DIR/lib"
|
|
876
883
|
cp "$GATE" "$ISO2_DIR/stop-goal-fit.js"
|
|
877
884
|
cp "$ROOT/scripts/hooks/lib/local-artifact-paths.js" "$ISO2_DIR/lib/"
|
|
885
|
+
# #291: same rationale as ISO_DIR above -- mirror the two new scripts/hooks/lib dependencies.
|
|
886
|
+
cp "$ROOT/scripts/hooks/lib/actor-identity.js" "$ISO2_DIR/lib/"
|
|
887
|
+
cp "$ROOT/scripts/hooks/lib/current-pointer.js" "$ISO2_DIR/lib/"
|
|
878
888
|
printf '# Repo\n' > "$ISO2_DIR/repo/AGENTS.md"
|
|
879
889
|
printf '%s' '{"schema_version":"1.0","task_slug":"lowtest","status":"in_progress","phase":"execution","updated_at":"2026-06-27T00:00:00Z","next_action":{"status":"in_progress","summary":"running"}}' \
|
|
880
890
|
> "$ISO2_DIR/repo/.kontourai/flow-agents/lowtest/state.json"
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
# Proves that:
|
|
5
5
|
# 1. END-TO-END-RECORD-RELEASE: record-release auto-publishes trust.bundle.
|
|
6
6
|
# 2. SUBCOMMAND: publish-delivery subcommand copies bundle to delivery/.
|
|
7
|
-
# 3. RECONCILE-DIVERGENCE: delivery trust.bundle +
|
|
8
|
-
#
|
|
7
|
+
# 3. RECONCILE-DIVERGENCE: delivery trust.bundle (+ matching-sha checkpoint sibling, ADR
|
|
8
|
+
# 0022 addendum part 2 bundle-ownership binding) + CI fail -> exit 1.
|
|
9
|
+
# 4. RECONCILE-MATCHING: delivery trust.bundle (+ matching-sha checkpoint sibling) + CI
|
|
10
|
+
# pass -> exit 0.
|
|
9
11
|
# 5. FAIL-SOFT: no trust.bundle -> publishDelivery skips, record-release exits 0.
|
|
10
12
|
#
|
|
11
13
|
# Deterministic, no model spend, self-cleaning.
|
|
@@ -63,6 +65,19 @@ PY
|
|
|
63
65
|
node "$helper" "$dest" "$label" "$passing"
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
# write_checkpoint_to <delivery_dir> <sha>
|
|
69
|
+
# Writes a minimal, well-formed trust.checkpoint.json naming <sha> as commit_sha, so a
|
|
70
|
+
# bare fixture trust.bundle written directly into delivery/ (TEST 3/4 below -- these do
|
|
71
|
+
# NOT go through the real seal-checkpoint pipeline) still carries the commit-identity
|
|
72
|
+
# binding trust-reconcile.js's bundle-ownership staleness check now requires (ADR 0022
|
|
73
|
+
# addendum, part 2) for an auto-discovered bundle to be treated as owned by the change
|
|
74
|
+
# under test, not stale.
|
|
75
|
+
write_checkpoint_to() {
|
|
76
|
+
local delivery_dir="$1" sha="$2"
|
|
77
|
+
printf '{"schema_version":"1.0","slug":"publish-delivery-fixture","work_item":null,"status":"delivered","phase":"release","sealed_at":"2026-06-27T00:00:00Z","commit_sha":"%s","checkpoint":{"asOf":"2026-06-27T00:00:00.000Z","statusByClaimId":{}}}' \
|
|
78
|
+
"$sha" > "$delivery_dir/trust.checkpoint.json"
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
# Session setup helper
|
|
67
82
|
setup_session() {
|
|
68
83
|
local aroot="$1" slug="$2" bundle_src="$3"
|
|
@@ -181,8 +196,9 @@ mkdir -p "$REPO3/delivery"
|
|
|
181
196
|
# -> claimed cmd not in canonical set -> not-run divergence, AND canonical fails
|
|
182
197
|
DELIVERY3="$REPO3/delivery/trust.bundle"
|
|
183
198
|
write_bundle_to "$DELIVERY3" "node --version" "true"
|
|
199
|
+
write_checkpoint_to "$REPO3/delivery" "1111111111111111111111111111111111111111"
|
|
184
200
|
|
|
185
|
-
recon3_out=$(TRUST_RECONCILE_COMMANDS="false" \
|
|
201
|
+
recon3_out=$(TRUST_RECONCILE_SHA="1111111111111111111111111111111111111111" TRUST_RECONCILE_COMMANDS="false" \
|
|
186
202
|
node "$RECONCILE" --repo-root "$REPO3" 2>&1)
|
|
187
203
|
recon3_exit=$?
|
|
188
204
|
|
|
@@ -208,8 +224,9 @@ mkdir -p "$REPO4/delivery"
|
|
|
208
224
|
# Bundle claims "node --version" passed; canonical verify is ALSO "node --version" (passes)
|
|
209
225
|
DELIVERY4="$REPO4/delivery/trust.bundle"
|
|
210
226
|
write_bundle_to "$DELIVERY4" "node --version" "true"
|
|
227
|
+
write_checkpoint_to "$REPO4/delivery" "2222222222222222222222222222222222222222"
|
|
211
228
|
|
|
212
|
-
recon4_out=$(TRUST_RECONCILE_COMMANDS="node --version" \
|
|
229
|
+
recon4_out=$(TRUST_RECONCILE_SHA="2222222222222222222222222222222222222222" TRUST_RECONCILE_COMMANDS="node --version" \
|
|
213
230
|
node "$RECONCILE" --repo-root "$REPO4" 2>&1)
|
|
214
231
|
recon4_exit=$?
|
|
215
232
|
|