Skip to content

FLT-359: Forge hard-stop approvals (Twilio Verify Push). Build spec v1

Historical v1 scope below. FIX-ROUND-1.md supersedes its single- approver, display, verifier-boundary and gate requirements. The current operational contract is ENABLE-RUNBOOK.md: on-PC CLI results are advisory; only an independently enforced off-PC executor may authorize effects.

Status: write the code but don't turn it on (Andrew, 2026-10-30). The rules below are absolute: - Approvals:Enabled defaults to false. - No Twilio account exists. Make no live network calls and commit no secrets or keys. - Do NOT wire this into the live fleet. That covers ~/.claude/settings.json, the fleet-preflight install and any scheduled task. - Council evidence: C:\Users\fives\source\repos\_review-evidence\FLT-359\ and FLT-356. Jira: FLT-359.

Why

Today a hard stop (money, outward-facing actions, destructive operations, logins) goes ahead whenever "Andrew said yes" appears in chat, and any agent can write that line. This feature replaces the chat line with an approval Andrew signs on his phone: 1. Twilio Verify Push sends a challenge to the Forge mobile app. The app shows the exact action, and Andrew approves it with a biometric. 2. Twilio verifies the approval off the PC. 3. When an approval request arrives, Andrew also gets a Pavlok vibe and one email to a dedicated inbox.

Language and layout (C# first, .NET 10)

src/Forge.Approvals.Core/        domain, canonicalization, policy, interfaces (no I/O)
src/Forge.Approvals.Twilio/      ITwoFactorProvider via Twilio Verify v2 Challenges REST API (HttpClient, no SDK)
src/Forge.Approvals.Notify/      Pavlok + email notifiers, outbox
src/Forge.Approvals.Cli/         `forge-approve` CLI: request | status | verify | doctor
tests/Forge.Approvals.Tests/     xUnit, mocked HttpMessageHandler, no network
Directory.Build.props, Directory.Packages.props (central package mgmt), .editorconfig, nullable enabled, warnings as errors
The Android app (Twilio Verify Push SDK in the Forge mobile app) is out of scope for this slice. Write docs/MOBILE-APP.md describing the contract the app must meet.

Core model

  • HardStopAction:
  • ActionKind is a closed enum: Spend, OutwardMessage, PublishOrPush, Destructive, Login, Other.
  • Target: repo, host, path, recipient(s), amount plus currency, destination. Use only the fields that apply.
  • EffectBinding: what the action will actually do, e.g. commit SHA plus remote ref, the recipient list hash, the amount.
  • CommandSha256, Ticket, RequestedBy (seat or agent label), HumanSummary.
  • ApprovalRequest: Jti (a UUIDv7), Action, CreatedUtc, ExpiresUtc (default 10 min, at most 30 min), ActionHash.
  • ActionHash = SHA-256 over the RFC 8785 (JCS) canonical JSON of the action.
  • Implement JCS yourself, or use a vetted package. Commit known-answer vectors taken from the RFC 8785 appendix and comment each one with where it came from.
  • Reject duplicate keys. Normalize the strings that labels use to NFC, and reject any label that changes under normalization (lookalike defense).
  • ApprovalDecision, a closed set: Approved, Denied, Expired, Pending, Disabled, ProviderUnavailable, Invalid.

Policy (fail-closed when enabled; inert when disabled)

  • Disabled (the default): ApprovalGate.Evaluate returns Disabled. It makes no provider call and sends no notification. The CLI prints that approvals are disabled. Nothing in the existing fleet changes.
  • Enabled: proceed only if all of these hold:
  • the provider confirms Approved for this exact Jti;
  • the Twilio challenge's hidden details contain the same ActionHash;
  • the approval hasn't expired;
  • the Jti hasn't been consumed before.

Anything else (an exception, a timeout, an unknown status, a missing config value) means deny. - Replay store: an atomic one-time consume. Use FileMode.CreateNew with FileShare.None on <jti>.spent under a configurable directory. Write a test where 16 concurrent consumers race and exactly one wins. - Clock: reject when now < CreatedUtc - 2 min (clock skew). Record the last-seen time and reject anything that goes backwards.

Twilio provider (no live calls)

  • Use the Verify v2 REST API through HttpClient, typed and with an injected handler:
  • create the Service, Entity and Factor (the factor is registered from the phone app);
  • POST Services/{sid}/Entities/{identity}/Challenges with Details.Message = HumanSummary, Details.Fields = the action kind, target and ticket, and HiddenDetails = { actionHash, jti };
  • get the challenge status.
  • Credentials (Account SID, Auth Token or API Key) are read from configuration or environment only. If they're missing, return ProviderUnavailable. Never log secrets.
  • Contract tests:
  • Build the fixtures from Twilio's published example responses for the Challenge resource. Comment each fixture with its doc URL (https://www.twilio.com/docs/verify/api/challenge).
  • If you can't get the exact docs payload, mark the fixture // UNVERIFIED shape: re-capture from producer before enable. Don't invent fields silently.
  • Assert the negatives: an unknown status maps to Invalid, and a hidden-details hash mismatch means deny.
  • Pricing note for the docs: about $0.05 per verification. A per-country fee may apply; it needs a live check before enabling.

Notifications

  • Raise them only when enabled and an approval request is created.
  • PavlokNotifier: runs the pavlok CLI with vibe.
  • Run it hidden: CreateNoWindow=true, UseShellExecute=false. No console window may ever flash.
  • Respect the CLI's budget (exit code 3 means refused; log it and carry on).
  • It must be testable through an IProcessRunner abstraction.
  • EmailNotifier: an IEmailSender interface plus an SMTP or transactional-API implementation.
  • Exactly one recipient, from configuration (the dedicated inbox Andrew will create).
  • Subject: [Forge approval] <ActionKind> <short target>. Body: HumanSummary, the ticket, the expiry, and the pinned approval-origin text.
  • The body must say that approval happens only in the Forge app and that this email cannot approve anything.
  • Outbox: one notification per Jti, made idempotent with a marker file. Crash recovery must not send a duplicate.

CLI forge-approve

  • request --action-json <file>: prints the Jti and ActionHash. When disabled, prints disabled and exits 0.
  • status --jti <id>: prints the decision.
  • verify --jti <id> --action-json <file>: exits 0 only on Approved with a matching hash. When enabled, every other result exits non-zero. When disabled, exits 10 with "approvals disabled".
  • doctor: reports config completeness and enabled/disabled. It must never print a secret.

Tests and gates (must pass locally; paste the real output in the final report)

  • dotnet build -warnaserror and dotnet test.
  • Required negative tests:
  • disabled state: no calls and no notifications;
  • expired;
  • replay, including the 16-way race;
  • hash mismatch;
  • unknown status;
  • provider exception;
  • missing credentials;
  • clock rollback;
  • duplicate JSON key;
  • NFC lookalike label;
  • email sent at most once per Jti across a simulated crash.
  • Stryker.NET config with thresholds.break > 0 (target 60), with mutate globs relative to the project. Run it once and report the score. If Stryker isn't installed, say so plainly; don't fake it.
  • Run builds and tests detached or hidden. No visible console windows.

Deliverables

  • The code and tests above.
  • docs/ENABLE-RUNBOOK.md, Andrew's steps to turn it on:
  • Twilio sign-up and billing.
  • Verify Service.
  • Install the Forge mobile app and register a factor.
  • Create the dedicated inbox.
  • Fill in config.
  • Set Approvals:Enabled=true.
  • Wire it into fleet-preflight.

The runbook must state the security bounds: - Agents running as the same user can bypass preflight. Hard blocking only covers effects whose credentials live off-PC. - A forged email cannot approve anything. - docs/MOBILE-APP.md. - Commit on branch wt/WT-de9e/FLT-359, with small logical commits. Do not push.