test(issue-5): phase 1 delegation characterization suite

The three lib.sh delegation helpers (delegate_submit_job,
delegate_publish_event, start_watchdog) had zero direct test coverage, so a
"full suite green" gate would have been vacuous for the Phase 1 extraction.
Add the regression oracle before the move:

- C-01..C-09 golden tests for the shell helpers: the non-fatal contract (empty
  job id, missing script, non-zero interpreter exit), exact argv forwarding,
  stdout-is-the-job-id-alone, and the daemon's PID/dedup/log-path behaviour.
  All are parametrized over MAM_DELEGATION_PY so the legacy and python bodies
  must agree.
- CLI contract snapshots taken from the argparse parsers rather than --help
  text, so wording stays free to change but option names, choices and defaults
  do not.
- Auto-completion invariant guards for the three surfaces that decide job
  status: EVENT_TO_STATUS, the wrapper's exit-code mapping, and reconcile.sh's
  terminal mutation literals.
- conftest: PV-2/PV-3 session guards asserting that every non-delegation
  lib_py.* module resolves to the real skills tree and that no temp-tree
  sys.path entry contributes a lib_py package. MAM_ENV_FILE is pointed at an
  absent file inside the sandbox so delegation code can never inject the real
  .mam.env into a test process.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrDNJkHmm18uu7n7JwV5Qd
This commit is contained in:
GodopuandClaude Opus 5 committed 2026-09-06 15:33:37 +09:00
1 parent fc0bd96d8a
commit 265a1f6c3d
7 files changed
+531

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Stub interpreter used by the Phase 1 characterization tests.
# Records argv (one invocation per line) and replays a configured stdout/exit code.
if [ -n "${STUB_ARGV_LOG:-}" ]; then
printf '%s\n' "$*" >> "$STUB_ARGV_LOG"
fi
if [ -n "${STUB_STDOUT:-}" ]; then
printf '%s\n' "$STUB_STDOUT"
fi
exit "${STUB_EXIT:-0}"
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Stub monitor used by the Phase 1 watchdog characterization tests.
# Sleeps so the spawned PID stays observable; never touches the registry.
echo "fake reconcile started: $*"
sleep 60
+18
View File
@@ -0,0 +1,18 @@
usage: job_subscriber.py [-h] (--job JOB | --wait-any) [--timeout TIMEOUT]
[--idle-timeout IDLE_TIMEOUT] [--expect-retention]
[--registry-dir REGISTRY_DIR] [-v]
Subscribe to Job events on MQTT
optional arguments:
-h, --help show this help message and exit
--job JOB job id to watch
--wait-any watch every pending/running job in the registry
--timeout TIMEOUT wall-clock budget in seconds (default: job.timeout_sec
or 3600)
--idle-timeout IDLE_TIMEOUT
max seconds with no new event (default:
job.idle_timeout_sec or 120)
--expect-retention warn if no retained terminal event arrives promptly
--registry-dir REGISTRY_DIR
-v, --verbose
+22
View File
@@ -0,0 +1,22 @@
usage: publish_event.py [-h] (--job JOB | --pick-pending)
[--agent-session AGENT_SESSION]
[--event {started,permission_required,progress,completed,error,cancelled}]
[--detail DETAIL] [--data DATA] [--retained]
[--registry-dir REGISTRY_DIR] [--attempts ATTEMPTS]
[-v]
Publish a Job event to MQTT
optional arguments:
-h, --help show this help message and exit
--job JOB job id to publish for
--pick-pending auto-select a pending job for --agent-session
--agent-session AGENT_SESSION
session label used with --pick-pending
--event {started,permission_required,progress,completed,error,cancelled}
--detail DETAIL
--data DATA optional JSON object string
--retained force retain=True (auto for completed/error)
--registry-dir REGISTRY_DIR
--attempts ATTEMPTS
-v, --verbose
+22
View File
@@ -0,0 +1,22 @@
usage: registry.py [-h] [--registry-dir REGISTRY_DIR]
{register,list,get,status,update,get-feedback,pick,logs}
...
multi-agent-mux-delegate-job registry CLI
positional arguments:
{register,list,get,status,update,get-feedback,pick,logs}
register create a pending job; prints the job id
list list jobs (optionally by status)
get print one job record as JSON
status set a job status
update update a job record
get-feedback get the last feedback detail (completed/error) for a
job
pick claim a pending job for a session; prints id
logs show the persistent audit log for a job, or --list
every logged job
optional arguments:
-h, --help show this help message and exit
--registry-dir REGISTRY_DIR