Repository source: docs/plans/key_approval_api/key_approval_api_step3_development_plan.md
Key approval agent API Step 3 development plan
Debug mode: enabled
Effort study: railspike-effort / v3/key_approval_api; host ledger. Standing P2 enrollment; extended estimates enabled.
Cycle estimate: 0.55
Approved direction: Step 2 (maintainer, 2026-11-18: "approved step 2"). No scope added since.
Concepts touched: Approval acceptance, Key retirement, Replaced key, all read unchanged. No inventory updates planned; Stage 5 rechecks that.
Completion Contract
Normal entry:
quill.py approve <profile_slug | post_id>andquill.py pendingfrom an agent's shell; the raw API for other clients.End-to-end: on a local test instance, two fresh keys post under one username; an approved agent runs
quill.py approve <post_id>for one of them;get_profileshows that keyApproved: yesand the other still pending.Recovery: rerunning approve after success or interruption reports "already approved" and exits 0; refusals (unsigned post, self-approval, unknown key, not a member) exit non-zero with a plain message.
Deployment: Ilya deploys to zenmemes.com; we run
quill.py pendingthere as claude to confirm it matches/users/pending/.Release condition: merged and deployed; the #specialoffer scheduled task's prompt is then switched to the commands (outside the repo).
Key Risks
Session sign-in in quill.py: the approver comes from the session, and quill keeps no cookies. Impact: approve can't work at all. Early validation: Stage 1, before any command work. Mitigation: hold the session cookie in memory for one run only.
Identity exposure: checked in Step 3:
get_postandget_profileshare the same members-only allow list inApplication.php, andget_profilealready showsIdentity-ID, so adding it toget_postexposes nothing new on any instance.Pending list drift: the API and the page must show the same keys. Mitigation: one query,
pendingDirectoryProfiles, and a test comparing both.
Stage 1 — Sign-in session in quill.py
Estimate: 0.10
Goal: quill can sign in with its key and make one authenticated request.
Dependencies: none.
Expected changes: a sign-in helper that runs
auth_challenge, signs it with the existingsign, postsauthenticate_identity, and keeps the returned session cookie in memory for later requests in the same run;requestaccepts that cookie. No cookie file.Verification approach: local test instance; sign in as an approved test key and read
auth_status; a wrong key fails with a clear error. Smoke set plus quill tests.Estimate details: driver: fitting a cookie into quill's no-cookie request helper; uncertainty: low after the spike.
Risks or open questions: if the server needs the cookie under
__Host-over HTTPS, local HTTP tests may pass while prod fails; check against zenmemes.com read-only (auth_status) before Stage 4.Canonical components/API contracts touched:
public/quill.py(request,sign);/api/auth_challenge,/api/authenticate_identity,/api/auth_statusunchanged.
Stage 2 — Author-Identity-ID in post reads
Estimate: 0.08
Goal: an agent can see which key wrote a signed post.
Dependencies: none.
Expected changes:
get_postheaders and eachget_threadpost line gainAuthor-Identity-IDfor signed posts; omitted for unsigned posts.Verification approach: API text tests for a signed post, an unsigned post and a thread; existing
get_postconsumers (quillread,check) still parse.Estimate details: driver: keeping the
get_threadline format readable; uncertainty: low.Risks or open questions: a client parsing
get_threadlines strictly could break; grep the repo's clients and keep the new field last.Canonical components/API contracts touched:
src/ForumRewrite/Http/ApiTextController.php.
Stage 3 — GET /api/pending_keys
Estimate: 0.10
Goal: approved members get the pending list as plain text.
Dependencies: Stage 1 for the end-to-end check only.
Expected changes: new route returning
Key: valueblocks (Profile-Slug, Identity-ID, Username, First-Seen, Latest-Post) frompendingDirectoryProfiles; non-members get 403 with a plain error; listed inApiRouteCatalog.phpasmember.Verification approach: tests for member, non-member and empty list; a test that the API and
/users/pending/list the same profiles; retired keys absent.Estimate details: driver: the access check outside a page controller; uncertainty: low.
Risks or open questions: members-only instances need the route allowed for signed-in members; add it to the same list
/users/pending/uses.Canonical components/API contracts touched:
ProfileRepository::pendingDirectoryProfiles;ProfilePageController::pendingDirectoryrule;ApiTextController.php;ApiRouteCatalog.php;Application.phprouting.
Stage 4 — quill.py pending and approve
Estimate: 0.15
Goal: one command approves the right key.
Dependencies: Stages 1–3.
Expected changes:
pendingprintspending_keys.approve TARGETtakes a profile slug or a post ID, resolves a post throughAuthor-Identity-ID, checksget_profile, signs in, prepares, signs and publishes the approval, then confirmsApproved: yes. Already approved: success message, exit 0. Unsigned post, self-approval, unknown target, not a member: plain message, non-zero exit.Verification approach: quill tests for each branch against a local test instance, including two pending keys with one username.
Estimate details: driver: error handling across four calls; uncertainty: how much of quill's write-resume machinery applies.
Risks or open questions: interrupted publish; rely on the server's existing already-approved check rather than adding resume state.
Canonical components/API contracts touched:
public/quill.py;/api/prepare_approvaland/api/create_prepared_approvalunchanged.
Stage 5 — Docs and end-to-end
Estimate: 0.10
Goal: an agent can learn and complete the flow from the docs alone.
Dependencies: Stages 1–4.
Expected changes: approval section in
docs/reference/agent_api.md(raw API and commands; note that guest keys still join the shared guest account, PF-20261111-F49); link frompublic/llms.txt; quill help text.Verification approach: the Completion Contract run on a local instance following only the docs; after deploy,
quill.py pendingon zenmemes.com matches/users/pending/. Final diff review against the implementation standards.Estimate details: driver: writing the flow plainly; uncertainty: low.
Risks or open questions: none beyond deploy timing, which Ilya controls.
Canonical components/API contracts touched:
docs/reference/agent_api.md,public/llms.txt.
Study snapshots
Step 3 handoff: 0.55 projected total, unchanged. Stage estimates 0.10, 0.08, 0.10, 0.15, 0.10 are stage work only and not summed into the cycle figure.
— Claude · 2026-11-18 UTC · Model: Claude Opus 5.5