Skip to content

The agent that grows with you

test: require complete shared gateway acceptance receipt coverage

Tekniumd853d14574c5
diff --git a/evals/shared_gateway/README.md b/evals/shared_gateway/README.md
new file mode 100644
index 00000000000..ad12b61a4cc
--- /dev/null
+++ b/evals/shared_gateway/README.md
@@ -0,0 +1,13 @@
+# Shared gateway acceptance coverage
+
+`cases.json` preserves all 47 named scenarios from sections 7.1–7.4 of the unified gateway plan. These are requirements, not recorded passes. Native deployment/topology and performance requirements in section 7.5 remain additional gates; this manifest does not claim to enumerate their combinations.
+
+The implemented checker rejects missing/extra/duplicate scenarios, non-passing outcomes, missing assertions/evidence, wrong OS/SHA, non-production dispatch, and leaked owned processes. It checks evidence availability, not whether a trace proves its claimed observation. Human/independent trace review remains mandatory. A loopback model is not live-provider evidence.
+
+Run against a real driver's report:
+
+ python3 evals/shared_gateway/verify_receipt.py receipt.json --expected-sha FULL_TESTED_SHA --expected-os linux
+
+Evidence paths are relative to the receipt directory. Supply a full report with schema=1, source_sha, native_os, fixture_home_isolated=true, production_dispatch=true, model_boundary (loopback or live-provider), remaining_owned_processes=[], and cases. Each case contains name, status, positive integer assertions, and nonempty evidence_paths pointing to nonempty files.
+
+The unified `run.py` driver is not implemented yet. Existing private native and subprocess probes have different receipt formats; do not rename them or manufacture a full report to obtain a pass. Test fixtures in `test_shared_gateway_harness.py` exercise the checker only and are not acceptance evidence.
diff --git a/evals/shared_gateway/cases.json b/evals/shared_gateway/cases.json
new file mode 100644
index 00000000000..41af5845761
--- /dev/null
+++ b/evals/shared_gateway/cases.json
@@ -0,0 +1,240 @@
+{
+ "schema": 1,
+ "cases": [
+ {
+ "name": "concurrent-cold-start",
+ "stimulus": "Desktop + classic + Ink + two serve launches hit one empty profile together",
+ "required_observation": "One runtime epoch/owner, one scheduler, one adapter connection per credential; every successful client attaches to that owner."
+ },
+ {
+ "name": "service-existing",
+ "stimulus": "Installed running service",
+ "required_observation": "No spawn/install/restart; existing authenticated owner returned."
+ },
+ {
+ "name": "service-stopped",
+ "stimulus": "Installed stopped service",
+ "required_observation": "Correct backend starts it; real API readiness verified."
+ },
+ {
+ "name": "service-uncertain",
+ "stimulus": "Delayed/retrying/inaccessible/masked service",
+ "required_observation": "No unmanaged rival; typed state/deadline."
+ },
+ {
+ "name": "no-service",
+ "stimulus": "User declined installation",
+ "required_observation": "Unmanaged owner starts; no service files/tasks/linger changes."
+ },
+ {
+ "name": "no-platforms",
+ "stimulus": "CLI-only install, no bots",
+ "required_observation": "Interactive chat and configured cron work; no messaging dependency prompt."
+ },
+ {
+ "name": "stale-metadata",
+ "stimulus": "Dead PID, reused PID, old port, malicious/unsafe pointer",
+ "required_observation": "No false attachment or destructive cleanup of an unrelated process."
+ },
+ {
+ "name": "multiplex-race",
+ "stimulus": "Root multiplexer and secondary launch race",
+ "required_observation": "Each home has one legitimate owner; loser attaches or reports explicit conflict."
+ },
+ {
+ "name": "profile-revocation",
+ "stimulus": "Remove/exclude a secondary while clients/workers exist",
+ "required_observation": "Admission revoked in that profile, scoped work drains, no default-profile fallback."
+ },
+ {
+ "name": "explicit-stop",
+ "stimulus": "Stop gateway with attached clients",
+ "required_observation": "Drain/stop; clients do not auto-respawn until deliberate fresh launch."
+ },
+ {
+ "name": "update-pause",
+ "stimulus": "Pause while a new client launches",
+ "required_observation": "No auto-start storm, stale code dispatch, or second writer."
+ },
+ {
+ "name": "two-surfaces-one-session",
+ "stimulus": "Same session in Desktop + gateway bot + CLI + Ink",
+ "required_observation": "Same live handle/agent, ordered turns, no exclusive viewer refusal."
+ },
+ {
+ "name": "independent-session-concurrency",
+ "stimulus": "Two unrelated sessions run",
+ "required_observation": "Concurrent progress; no global turn lock."
+ },
+ {
+ "name": "duplicate-submit",
+ "stimulus": "Retry after losing real accepted ACK",
+ "required_observation": "One admission and execution; identical receipt."
+ },
+ {
+ "name": "conflicting-submit",
+ "stimulus": "Reuse ID with changed text/target/media/intent",
+ "required_observation": "Conflict; no mutation."
+ },
+ {
+ "name": "prepared-before-send-crash",
+ "stimulus": "Immediate real Electron termination after journal ACK, before send",
+ "required_observation": "Native journal survives; exact target/ID/text recovered."
+ },
+ {
+ "name": "owner-crash-queued",
+ "stimulus": "Kill owner after queue ACK",
+ "required_observation": "Never-started inputs recover FIFO."
+ },
+ {
+ "name": "owner-crash-started",
+ "stimulus": "Kill after started marker/tool effect",
+ "required_observation": "State unknown; no automatic repeat; later queued work governed explicitly by recovery policy."
+ },
+ {
+ "name": "disk-failure",
+ "stimulus": "Full disk/SQLite contention during accept",
+ "required_observation": "No accepted ACK, prepared input retained, eventual retry safe."
+ },
+ {
+ "name": "compression-lineage",
+ "stimulus": "Compression rotates while input queued",
+ "required_observation": "Canonical successor receives it; forks/rewinds do not steal it."
+ },
+ {
+ "name": "stale-finally",
+ "stimulus": "Old worker completes after stop/reset/new generation",
+ "required_observation": "Old cleanup cannot clear/persist into successor execution."
+ },
+ {
+ "name": "revision-conflict",
+ "stimulus": "Two viewers edit/rewind/delete with same revision",
+ "required_observation": "One winner or explicit busy conflict; no silent overwrite."
+ },
+ {
+ "name": "route-binding",
+ "stimulus": "`/new` in one of two routes/views",
+ "required_observation": "Only invoking binding changes; original shared history remains."
+ },
+ {
+ "name": "readonly-client",
+ "stimulus": "Observe/list/export/search",
+ "required_observation": "No migration/repair/write from client processes."
+ },
+ {
+ "name": "shared-approval",
+ "stimulus": "Two authorized clients answer one prompt",
+ "required_observation": "One resolution/effect; other answer settled/stale."
+ },
+ {
+ "name": "unauthorized-control",
+ "stimulus": "Read-only/wrong-profile/forged internal/wrong-generation response",
+ "required_observation": "Rejected with no state change."
+ },
+ {
+ "name": "approval-client-loss",
+ "stimulus": "Originating viewer disconnects",
+ "required_observation": "Other authorized client can answer; no automatic denial."
+ },
+ {
+ "name": "native-card-decline",
+ "stimulus": "Connector refuses approval card",
+ "required_observation": "Existing decline behavior; no plaintext leak/fallback."
+ },
+ {
+ "name": "secret-response",
+ "stimulus": "Secret/sudo answer",
+ "required_observation": "Only assigned execution receives it; replay/transcript/logs contain no answer."
+ },
+ {
+ "name": "backpressure",
+ "stimulus": "Fill one real OS send buffer",
+ "required_observation": "Healthy viewer and emitter finish; bounded writer resources."
+ },
+ {
+ "name": "reconnect-snapshot",
+ "stimulus": "Evict replay buffer/restart owner during stream",
+ "required_observation": "Atomic snapshot/watermark merge; no lost/duplicated completed message."
+ },
+ {
+ "name": "delayed-refresh",
+ "stimulus": "Deliver old REST snapshot after new completion",
+ "required_observation": "New state not rolled back; row IDs/admission identity win."
+ },
+ {
+ "name": "native-final-stream",
+ "stimulus": "Messaging native stream with interim/media/final",
+ "required_observation": "One correct final artifact, prefix-stable draft, edit reconciliation."
+ },
+ {
+ "name": "view-is-not-delivery",
+ "stimulus": "Open chat on another UI/route",
+ "required_observation": "Viewing does not duplicate/redirect external messages."
+ },
+ {
+ "name": "cron-desktop-open",
+ "stimulus": "Cron delivers while bot chat open in Desktop",
+ "required_observation": "Delivery succeeds; both surfaces remain usable; no target transcript pollution."
+ },
+ {
+ "name": "cron-worker-restart",
+ "stimulus": "Gateway restart during external cron execution",
+ "required_observation": "Existing worker survives, adopts, persists once, result delivered according to policy."
+ },
+ {
+ "name": "worker-lost-ack",
+ "stimulus": "Drop committed persistence ACK",
+ "required_observation": "Sequenced retry returns same mutation result, no duplicate row/usage."
+ },
+ {
+ "name": "worker-revoked",
+ "stimulus": "Old/mismatched execution capability",
+ "required_observation": "Cannot write another session/profile or manufacture approval."
+ },
+ {
+ "name": "worker-outbox-full",
+ "stimulus": "Authority unavailable until spool bound",
+ "required_observation": "Visible safe pause/failure; no direct SQLite fallback or silent discard."
+ },
+ {
+ "name": "child-attach",
+ "stimulus": "Open a live delegated child on Desktop/CLI",
+ "required_observation": "Same child owner; no new agent; completion reaches parent once per configured delivery semantics."
+ },
+ {
+ "name": "completion-busy",
+ "stimulus": "Child/terminal/heartbeat result while parent busy",
+ "required_observation": "Existing noninterrupting queue and suppression policy preserved."
+ },
+ {
+ "name": "api-delivery-only",
+ "stimulus": "API session receives async completion",
+ "required_observation": "No newly autonomous model turn by accident."
+ },
+ {
+ "name": "kanban-session",
+ "stimulus": "Dispatcher starts scoped worktree worker",
+ "required_observation": "Board/profile/cwd/claim preserved, shared session observable."
+ },
+ {
+ "name": "profile-secrets",
+ "stimulus": "Concurrent default and secondary with distinct harmless secrets",
+ "required_observation": "Each execution reads its own secret; transport auth uses transport-owning profile."
+ },
+ {
+ "name": "cache-policy",
+ "stimulus": "Attach/submit from different surfaces",
+ "required_observation": "Existing prompt/tools bytes stable; no new toolset because a viewer arrived."
+ },
+ {
+ "name": "launch-options",
+ "stimulus": "Opposing model/cwd/YOLO/safe-mode/toolset settings",
+ "required_observation": "No cross-session process-environment leak."
+ },
+ {
+ "name": "cron-policy-parity",
+ "stimulus": "Memory, scripts, no-agent, context_from, delivery retries",
+ "required_observation": "Matches observed baseline, not stale documentation."
+ }
+ ]
+}
diff --git a/evals/shared_gateway/verify_receipt.py b/evals/shared_gateway/verify_receipt.py
new file mode 100644
index 00000000000..1b3ef8ad659
--- /dev/null
+++ b/evals/shared_gateway/verify_receipt.py
@@ -0,0 +1,63 @@
+"""Check measured shared-gateway receipts against the full required case set.
+
+This validates coverage and evidence availability, not the truth of observations.
+Native topology and trace review remain separate acceptance requirements.
+"""
+import argparse
+import json
+from pathlib import Path
+
+
+def require(condition, message):
+ if not condition:
+ raise ValueError(message)
+
+
+def verify(receipt, manifest, *, evidence_root, expected_sha, expected_os):
+ require(receipt.get('schema') == 1 and manifest.get('schema') == 1, 'unsupported schema')
+ require(receipt.get('source_sha') == expected_sha, 'stale source SHA')
+ require(receipt.get('native_os') == expected_os, 'wrong native OS')
+ require(receipt.get('fixture_home_isolated') is True, 'fixture home not isolated')
+ require(receipt.get('production_dispatch') is True, 'production dispatch not exercised')
+ require(receipt.get('model_boundary') in ('loopback', 'live-provider'), 'unknown model boundary')
+ require(receipt.get('remaining_owned_processes') == [], 'fixture leaked processes')
+ required = [case['name'] for case in manifest['cases']]
+ observed = receipt.get('cases', [])
+ names = [case['name'] for case in observed]
+ require(required and len(required) == len(set(required)), 'empty or duplicate manifest')
+ require(len(names) == len(set(names)), 'duplicate scenario receipts')
+ require(set(names) == set(required),
+ f'case mismatch: missing={sorted(set(required) - set(names))}, extra={sorted(set(names) - set(required))}')
+ root = Path(evidence_root).resolve()
+ for case in observed:
+ name = case['name']
+ require(case.get('status') == 'passed', f'{name}: not passed')
+ assertions = case.get('assertions')
+ require(type(assertions) is int and assertions > 0, f'{name}: no assertions')
+ paths = case.get('evidence_paths')
+ require(isinstance(paths, list) and paths, f'{name}: no evidence')
+ for relative in paths:
+ path = (root / relative).resolve()
+ require(path.is_relative_to(root) and path.is_file() and path.stat().st_size > 0,
+ f'{name}: missing, empty or external evidence: {relative}')
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('receipt', type=Path)
+ parser.add_argument('--manifest', type=Path, default=Path(__file__).with_name('cases.json'))
+ parser.add_argument('--expected-sha', required=True)
+ parser.add_argument('--expected-os', choices=('linux', 'macos', 'windows'), required=True)
+ args = parser.parse_args()
+ try:
+ verify(json.loads(args.receipt.read_text(encoding='utf-8')),
+ json.loads(args.manifest.read_text(encoding='utf-8')),
+ evidence_root=args.receipt.parent, expected_sha=args.expected_sha,
+ expected_os=args.expected_os)
+ except (ValueError, KeyError, TypeError, OSError) as exc:
+ parser.exit(1, f'FAIL: {exc}\n')
+ print('PASS: shared gateway receipt coverage (native topology/trace review still required)')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/gateway/test_shared_gateway_harness.py b/tests/gateway/test_shared_gateway_harness.py
new file mode 100644
index 00000000000..cd7ad281783
--- /dev/null
+++ b/tests/gateway/test_shared_gateway_harness.py
@@ -0,0 +1,58 @@
+"""Acceptance reports must cover the required manifest, not only successes."""
+import importlib.util
+from pathlib import Path
+
+import pytest
+
+
+def verifier():
+ path = Path(__file__).resolve().parents[2] / 'evals/shared_gateway/verify_receipt.py'
+ assert path.is_file(), 'shared gateway acceptance verifier missing'
+ spec = importlib.util.spec_from_file_location('shared_gateway_verifier', path)
+ assert spec is not None and spec.loader is not None
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module.verify
+
+
+def fixture(tmp_path):
+ evidence = tmp_path / 'observed.log'
+ evidence.write_text('fixture evidence; not a production acceptance receipt')
+ manifest = {'schema': 1, 'cases': [{'name': 'one'}, {'name': 'two'}]}
+ report = {'schema': 1, 'source_sha': 'a' * 40, 'native_os': 'linux',
+ 'fixture_home_isolated': True, 'production_dispatch': True,
+ 'model_boundary': 'loopback', 'remaining_owned_processes': [],
+ 'cases': [{'name': name, 'status': 'passed', 'assertions': 1,
+ 'evidence_paths': ['observed.log']} for name in ('one', 'two')]}
+ return manifest, report
+
+
+def test_complete_receipt_requires_exact_manifest_and_existing_evidence(tmp_path):
+ verify = verifier()
+ manifest, report = fixture(tmp_path)
+ verify(report, manifest, evidence_root=tmp_path, expected_sha='a' * 40, expected_os='linux')
+ (tmp_path / 'observed.log').unlink()
+ with pytest.raises(ValueError, match='evidence'):
+ verify(report, manifest, evidence_root=tmp_path, expected_sha='a' * 40, expected_os='linux')
+
+
[email protected]('fault', ['missing', 'duplicate', 'extra', 'skipped', 'zero',
+ 'stale', 'wrong-os', 'leaked', 'no-dispatch', 'no-evidence'])
+def test_incomplete_receipts_cannot_pass(tmp_path, fault):
+ verify = verifier()
+ manifest, report = fixture(tmp_path)
+ mutations = {
+ 'missing': lambda: report['cases'].pop(),
+ 'duplicate': lambda: report['cases'].append(report['cases'][0].copy()),
+ 'extra': lambda: report['cases'][0].update(name='unrequired'),
+ 'skipped': lambda: report['cases'][0].update(status='skipped'),
+ 'zero': lambda: report['cases'][0].update(assertions=0),
+ 'stale': lambda: report.update(source_sha='b' * 40),
+ 'wrong-os': lambda: report.update(native_os='windows'),
+ 'leaked': lambda: report.update(remaining_owned_processes=[123]),
+ 'no-dispatch': lambda: report.update(production_dispatch=False),
+ 'no-evidence': lambda: report['cases'][0].update(evidence_paths=[]),
+ }
+ mutations[fault]()
+ with pytest.raises(ValueError):
+ verify(report, manifest, evidence_root=tmp_path, expected_sha='a' * 40, expected_os='linux')