Key approval agent API Step 4 implementation summary

Feature plan: Step 1 · Step 2 · Step 3 · Step 4

Debug mode: enabled

Effort study: railspike-effort / v3/key_approval_api; host ledger. Standing P2 enrollment; extended estimates enabled.

Cycle estimate: 0.55

Step 4 entry: Step 3 projection of 0.55 reaffirmed, unchanged. Stage estimates below are copied from Step 3 (original rater Claude, 2026-11-18 UTC), not re-rated.

Branch: feat/key-approval-api. Planning commit: 520141a.

Stage 1 - Sign-in session in quill.py

Original estimate: 0.10 Retrospective stage work: 0.10

  • Changes:

    • request takes an optional cookie ('name=value'), sends it as a Cookie header, and returns every Set-Cookie value under set-cookies. Still no curl cookie jar.

    • sign_in(site, key, timeout) signs the auth_challenge string in a temporary folder with the existing sign, posts authenticate_identity, and returns the __Host-v3_session or v3_session cookie for this run only.

    • saved_key(args, site) returns the key the client already posts with (state directory or --signing-key) and never generates one, since only an approved key can approve.

  • Verification:

    • python3 tests/quill_client_test.py: 38 passed, including 5 new SignInTest cases (session cookie picked among several, cookie sent only when given, server error named, missing cookie is an error, no key generation).

    • Read-only check against zenmemes.com as claude: sign-in returned __Host-v3_session; auth_status answered authenticated with the cookie and unauthenticated without. This settles the Step 3 HTTPS cookie-name question.

    • ./v3 test --smoke QuillClientTest: 492 passed. Smoke set alone earlier: 478 passed. Full suite not run.

  • Notes:

    • Reuse: request, sign, identity, state_directory, load_meta from public/quill.py; server routes unchanged.

  • Estimate details: original scope as Step 3; unchanged; the spike risk resolved on first try.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5

Stage 2 - Author-Identity-ID in post reads

Original estimate: 0.08 Retrospective stage work: 0.08

  • Changes:

    • get_post adds Author-Identity-ID: openpgp:<fpr> after Author: when the post names an identity and has a signature file. Unsigned posts that name an identity (for example Quill's unsigned trouble reports) show no line, since the identity there is only a claim.

    • Scope narrowed from Step 3: get_thread post lines are [post_id] body with no author field at all, so adding the identity there would have meant a new per-line field inside body text and a format change for line parsers. Agents call get_post for the one post they're judging, which is what quill.py approve does in Stage 4. Recorded here rather than silently dropped.

  • Verification:

    • AgentApiWorkedExampleTest extended: every signed post from the file publishers (Python, PHP, Perl; existing and generated keys) shows its own Author-Identity-ID; an unsigned reply naming that identity shows none.

    • ./v3 test --smoke AgentApiWorkedExampleTest: 479 passed. The get_post 404 warning in the output is a deliberate missing-post check in SingleRequestHttpTest, present before this change. Full suite not run.

  • Notes:

    • Reuse: fetchPost already selects author_identity_id, and withPostSourceMetadata sets source_signature_path; no query change.

  • Estimate details: original scope included get_thread; the narrower scope did not change the rating.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5

Stage 3 - GET /api/pending_keys

Original estimate: 0.10 Retrospective stage work: 0.10

  • Changes:

    • ApiTextController::pendingKeys returns Pending-Count: N, then one Key: value block per waiting key: Profile-Slug, Identity-ID, Username (fallback label when unnamed), Posts, Latest-Activity-At, Latest-Post-ID. No-store headers.

    • It reads ProfileRepository::pendingDirectoryProfiles, the page's own query, which now also selects identity_id. Retired keys stay out, as on the page.

    • Access: an approved, signed-in session; otherwise 403 with a plain error. Stricter than the page, which also accepts the unauthenticated identity-hint cookie; the API's reader is a script about to sign approvals, so it gets the session check (authenticatedViewerProfile, passed into the controller). Approved members already pass the members-only gate for every path, so no allow-list change was needed there.

    • Route added to Application.php routing and isApplicationRoute, and to ApiRouteCatalog as member.

  • Verification:

    • New QuillClientTest::testPendingKeysNeedsAnApprovedSessionAndMatchesThePendingPage on a real local server: an approved approver key and two pending keys sharing the username shared-agent. Without a session: 403. With a session from Quill's sign_in: Pending-Count: 2, both pending keys listed with the right slug, identity, username and latest post, the approver absent, and /users/pending/ listing exactly the same keys.

    • ApiRouteCatalogTest: 3 passed (catalog matches router paths).

    • ./v3 test --smoke with those: 479 passed. Full suite not run.

  • Notes:

    • The shared fixture (approvalFixture) is reused by Stage 4.

  • Estimate details: original scope as Step 3; unchanged.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5

Stage 4 - quill.py pending and approve

Original estimate: 0.15 Retrospective stage work: 0.15

  • Changes:

    • quill.py pending: signs in with the client's saved key (or --signing-key), refuses an unapproved key, prints /api/pending_keys.

    • quill.py approve TARGET: TARGET is a profile slug, an identity ID or a post ID. A post resolves through Author-Identity-ID; an unsigned post is refused and the message points to PF-20261111-F49. Then: get_profile (unknown key refused; already approved prints Status: already approved, exit 0), self-approval refused, sign in, refuse an unapproved approver, prepare_approval, check that the prepared record names this key as author and the requested key as target (the same check the browser makes), sign the exact record, create_prepared_approval, and confirm Approved: yes. No confirmation prompt, as Step 2 decided; the server's review label is printed instead.

    • api passes an optional session cookie through to request.

    • QUILL_VERSION bumped to 2026-11-18, so agents running the older copy get the server's update notice.

  • Verification:

    • New QuillClientTest::testApproveByPostPicksTheRightKeyAmongSharedNames on a real local server, with two pending keys under the username shared-agent: a pending key can't list or approve; the approver lists both; approving by post ID approves that key and leaves the other pending; rerun reports already approved (exit 0); self-approval, an unknown slug, a missing post and an unsigned post naming a key are each refused with exit 2 and a plain message, and nothing gets approved; approving by slug works; the list ends empty.

    • ./v3 test --smoke QuillClientTest: 494 passed, every Quill integration test included. python3 tests/quill_client_test.py: 38 passed. Full suite not run.

  • Notes:

    • Interrupted publish: no resume state was added. A rerun goes through the server's own already-approved check, which the test covers.

    • Reuse: read_post, sign, api, identity/saved_key, state_directory; server approval routes unchanged.

  • Estimate details: original scope as Step 3; unchanged.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5

Stage 5 - Docs and end-to-end

Original estimate: 0.10 Retrospective stage work: 0.10

  • Changes:

    • docs/reference/agent_api.md: new "Approving keys" section with the Quill commands, the same six steps over the raw API, and the guest-account limit (PF-20261111-F49).

    • llms.txt (LlmsTxtRenderer): new "Approving keys" section linking to it; the old line "Members-only authentication/session automation is not provided by Quill" now says Quill signs in only for pending and approve.

    • Quill's pending and approve help text (Stage 4).

  • Verification:

    • End-to-end: the Stage 4 test runs exactly the documented commands against a real local instance (two keys sharing one username, approve by post ID, rerun, refusals, approve by slug, empty list). It passed.

    • ./v3 test --smoke QuillClientTest AgentApiWorkedExampleTest ApiRouteCatalogTest LlmsTxtRendererTest: 509 passed, 0 failed. python3 tests/quill_client_test.py: 38 passed. Full suite not run; the maintainer runs it.

    • git diff --check against origin/main: clean.

    • Final diff review against the implementation standards: 14 files. Reuse holds (one pending query; existing approval routes and signing). No new dependency, record format or flag. The only server read change besides the new route is one extra selected column in pendingDirectoryProfiles.

    • Concepts: Approval acceptance, Key retirement and Replaced key read unchanged; no inventory update needed.

    • Pending: after deploy, quill.py pending on zenmemes.com compared with /users/pending/. zenmemes.com doesn't have the route until Ilya deploys.

  • Notes:

    • After merge and deploy, the #specialoffer scheduled task's prompt should switch to quill.py approve <post_id>; that prompt lives outside the repo.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5

Cycle retrospective

  • Projected total: 0.55 (Step 3, reaffirmed at Step 4 entry).

  • Retrospective scope assessment: 0.50. Delivered scope was slightly smaller than planned (get_thread unchanged), and the sign-in risk resolved on the first try against production.

  • Planned stages: 5; completed: 5, each with its own commit.

  • Omissions: Author-Identity-ID on get_thread lines (format reason in Stage 2); post-deploy check pending.

  • Maintainer comfortable-fit judgment: pending.

  • Ledger: v3/key_approval_api.

— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5