Stage 5a: Provisioner — deterministic + patterns (v0 critical path)#44
Merged
hanwencheng merged 3 commits intomainfrom Apr 16, 2026
Merged
Stage 5a: Provisioner — deterministic + patterns (v0 critical path)#44hanwencheng merged 3 commits intomainfrom
hanwencheng merged 3 commits intomainfrom
Conversation
…crate (types + mutex concurrency + subprocess IPC)
b929532 to
38c41be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ships Stage 5a of agentkeys: the provisioner's deterministic + patterns tier (v0 critical path).
agentkeys.provision(service)can now sign up for OpenRouter via a local Playwright script, verify the obtained key against the live API, and store it through the backend. Per the 2026-04-16 CEO review (SELECTIVE EXPANSION), Stage 5b (agentic fallback + audit + script-gen skill) and Stage 6 (npm packaging) are explicitly deferred to v0.1..omc/prd.jsonprogress.txt)harness/stage-5a-done.shexits 0 with "STAGE 5a PASSED"mainclean —crates/agentkeys-core/src/session_store.rsis not part of this PR (no delta from main)What shipped
Rust (4 crates)
agentkeys-types::ProvisionEvent+TripwireKind+ProvisionErrorCode— shared schema for Rust↔TS IPC (tagged unions, snake_case)agentkeys-provisioner(new crate):ProvisionerRAII mutex withPROVISION_IN_PROGRESSsentinel,spawn_and_collectsubprocess driver with line-delimited JSON IPC + 120s timeout + malformed-line abort,run_provisionorchestrator (verify→store gate),mask_keyhelper, structured metrics emitteragentkeys-mcp::agentkeys.provisiontool registered with{service, force?}schema, structured error code mappingagentkeys-cli::provision <service> [--force]subcommand with masked-key stdout + CLAUDE.md-format error outputTypeScript workspace (new:
provisioner-scripts/)src/types.ts— exact mirror of Rust ProvisionEvent (typed boundary, no opaque parsing)src/lib/email.ts— Gmail plus-addressing IMAP via imapflow + structured timeoutsrc/lib/verify.ts— per-service verification (openrouter →GET /api/v1/models, Bearer auth); returnsphantom/endpoint_down/rate_limiteddistinctionssrc/patterns/signup_email_otp.ts— reusable pattern, zero service-specific strings (grep-enforced)src/scrapers/openrouter.ts— composes the pattern + calls verify before emitting Successtests/fixtures/openrouter/— HAR-equivalent hermetic fixtures served viapage.route()+route.fulfill()tests/scrapers/openrouter.phantom.test.ts— chaos test proving the verification gate catches ask-or-v1-FAKEdecoy keyHarness
harness/stage-5a-done.sh— 4-gate verifier (cargo tests, npm tests, grep guard against service strings inpatterns/, isolated phantom chaos)harness/features.json+harness/progress.jsonupdatedDesign artifacts (earlier turns this session)
docs/spec/plans/development-stages.mdrestructured: Stage 5 → 5a/5b split, Stage 6 deferred, eng-review + design-review decisions locked as implementation notesTODOS.mdadded (Twitter deferred, Phase C scraper target list)~/.claude/skills/agentkeys-record-scraper/SKILL.md(global, not in this PR) — dev-time tool for adding future scrapersArchitectural constraints enforced
ProvisionEventenum + TS discriminated union share the exact same JSON shapegrep -iE "openrouter\|brave\|jina\|groq\|anthropic\|gemini" provisioner-scripts/src/patterns/returns empty)verify()before emitting Success; phantom chaos test proves the gatesignup_email_otpfrom the inline OpenRouter scraperStage 5b follow-ups (architect review, non-blocking)
Logged in
progress.txtfor Stage 5b:re_verify_existingis a placeholder returningtrue— real re-verification neededProvisionEvent::Progressevents to stderr in real time (single-shot today)code: "store_failed"— should be a dedicatedProvisionErrorCode::VerificationFailedvariant.harOptimality suggestions also captured for Stage 5b: streaming orchestrator API, consolidate service-dispatch, NoopBackend extraction, exhaustive
event_to_errormatch.Scope explicitly NOT in this PR
/agentkeys-record-scraperskill after this merges (perTODOS.mdPhase C list). Twitter deferred to TODOs, Instagram dropped.Test plan
bash harness/stage-5a-done.shexits 0cargo test -p agentkeys-types -p agentkeys-provisioner -p agentkeys-mcp -p agentkeys-clipasses (67 tests)npm install --prefix provisioner-scripts && npm test --prefix provisioner-scriptspasses (15 tests)grep -iE "openrouter|brave|jina|groq|anthropic|gemini|twitter|instagram" provisioner-scripts/src/patterns/returns emptycd provisioner-scripts && npx vitest run tests/scrapers/openrouter.phantom.test.tsTODOS.mdReviews already run (2026-04-16)
/plan-ceo-review— SELECTIVE EXPANSION, 7 proposals, 5 accepted, 1 deferred, 1 rejected; 1 critical gap caught (silent-corrupt-credential → mandatory verification fix) — CEO plan at~/.gstack/projects/litentry-agentKeys/ceo-plans/2026-04-16-stage-5-hybrid-agentic.md/plan-eng-review— 3 P1 decisions locked (IPC schema, concurrency, MCP scope), 5 implementation notes baked into plan, 11 additional tests added to story tables — test plan at~/.gstack/projects/litentry-agentKeys/*eng-review-test-plan*.md/plan-design-review— 4 UX decisions locked (masked-key output, stderr progress, atty TTY detection, duplicate-provision verify-and-report); score 5→9/10🤖 Generated with Claude Code