feat(extensions): native Babysitter turn handler
Summary
Adds the native Babysitter package the #550 handoff calls for, at extensions/babysitter. It is a schema-2 extension on software-factory whose 11 GitHub handlers each turn Cloud's normalized delivery descriptor into one cloud:babysitter-turn call:
f.capabilities.cloud.babysitterTurn.queue({ delivery: { deliveryId, provider: 'github', eventType, pullRequest: { owner, repository, number } } })
- It sends no findings, prose, head SHA, label, session, lineage, relay agent, config, merge flag, or route. Cloud's capability adapter holds the verified authority, rereads the live PR (open, exact
babysitlabel, head), and resolves the bound Codex session. - The only accepted result is
{ receiptId, status: 'queued' | 'duplicate' }, which completes the run assuccess. Rejections (policy refusals, in-doubt transport) fail the run once, with no retry or fallback. Any other receipt shape fails the run. - Input must be the exact descriptor. A raw webhook, unknown fields, a non-GitHub source, a malformed delivery ID, repo, PR number or head, or an
eventTypethat doesn't match the handler's own subscription is refused before any call. - The default body (direct run) declines and never queues.
- Manifest permissions are exactly what the #550 exporter requires:
github,codex, no MCP, writescloud:babysitter-turn,extends.handlers: true, no hooks. It holds no GitHub write authority. - This is not the legacy
examples/babysitter(Claude review lenses, GitHub comments, merge-gate hook).
The contract was agreed over Agent Relay with babysitter-session-lineage-proposal, who owns Cloud core, Relay native-turn and RelayHistory receipts. They corrected two points, both applied: omit findings, and use the receipt queued|duplicate, with Cloud deduping by lineage plus live head so deliveryId is provenance only.
What this does NOT do
- Does not weaken #549. Hosted dispatch still refuses the handler with
plugin_unsupportedbefore either body runs. That is pinned by a test that goes through the real install, compose and execute path. - Cannot execute yet. The SDK
Ctxhas nocapabilities, so the handler fails closed withdoes not provide the cloud:babysitter-turn write. Execution needs gate 8 / #442 isolation plus the Cloud capability adapter. - Not publishable as is.
compatis^2.0.26. The published@relayflows/surface@2.0.25registry cannot routepull_request.labeled,.unlabeledor.ready_for_review(install refuses withplugin_event_unroutable). A surface release must come first. - No merge, npm publish, catalog enablement, or production change. Export follows
docs/BABYSITTER-CATALOG-HANDOFF.mdwith path#extensions/babysitter, from the merged commit only. Rollout is not complete.
Evidence (files in evidence/babysitter-native-handler/)
typecheck.txt:npm run typecheckandnpm run typecheck:tests, bothExit: 0.tests.txt: new suiteTests 31 passed (31). Neighbouring suites (catalog export, compose, plugin-extension, authored-flow incl. the #549 tests, preflight):Tests 219 passed (219).mutation.txt: two mutations, each reverted, failing, restored byte-for-byte (sha256 matches), and passing again:- Removing the event/subscription binding makes
refuses an event for another subscriptionfail. - Removing the capability guard makes the 3
fails closed on …tests fail. Without the guard the run still fails, just as a raw TypeError; the guard pins a clear refusal.
- Removing the event/subscription binding makes
full-suite.txt: local fullnpm testhas 51 failures in 23 files, none in the new suite. 17 of those files also fail atorigin/main607ac671 with this change stashed (38 failures). The 6 files that failed only in the full run pass in isolation on this branch (40/40). Causes are load and timing (5s timeouts, relayflowd lease expiry, ENOTEMPTY cleanup). CI is the authority.
The test suite uses the local surface, as CI does (npm install ./packages/surface --prefix packages/sdk --no-save --ignore-scripts).
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
New extension defines the Cloud turn boundary and strict input validation, but execution stays refused until gate 8 and the Cloud adapter ship; mis-validation could block turns once enabled.
Overview
Introduces the native Babysitter schema-2 flow extension at extensions/babysitter for Software Factory: eleven GitHub subscriptions each validate Cloud’s normalized delivery descriptor and issue a single cloud:babysitter-turn queue call with a minimal PR envelope (no head, session, findings, or GitHub writes). turn.ts fail-closes on schema drift, wrong subscription, or bad receipts; babysitter.flow.ts requires a runtime capabilities.cloud.babysitterTurn port and completes only on queued/duplicate receipts.
Does not turn on production behavior: hosted dispatch still hits plugin_unsupported (#549), today’s SDK has no capability field, and compat pins surface/sdk ^2.0.26 for labeled / unlabeled / ready_for_review routing. Direct runs decline without queuing.
Adds a 31-test SDK suite (compose, #549 refusal, #550 catalog export bytes, validation, capability guard) plus handoff doc updates and local evidence (typecheck, mutation checks, full-suite notes).
Reviewed by Cursor Bugbot for commit dcdc6bd2b5954745e66967c53656bb94cb4e7f3f. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Adds the native Babysitter extension at extensions/babysitter, replacing the handoff in #550: a schema-2 extension on software-factory whose 11 GitHub handlers each turn Cloud's normalized delivery descriptor into one cloud:babysitter-turn queue call. The handler sends no findings, head, label, session, lineage, or config; Cloud rechecks the live PR and bound session.
- Only
{ receiptId, status: 'queued' | 'duplicate' }receipts complete the run; rejections and malformed input (raw webhook, unknown fields, wrong subscription, bad delivery ID/PR) fail once with no retry. - A direct run declines and never queues; permissions match exactly what the #550 exporter requires.
- Not executable yet: hosted dispatch still refuses with
plugin_unsupported, the SDKCtxhas nocapabilities, andcompatneeds a surface release after 2.0.25 to routelabeled,unlabeled, andready_for_review. - Not the legacy
examples/babysitter; this holds no GitHub write authority. - Adds 31 tests and evidence of typecheck, mutations, and suite runs.