@juspay/neurolink 12.25.3 → 12.25.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/dist/browser/neurolink.min.js +323 -323
- package/dist/context/nativeGenerateGuard.d.ts +22 -0
- package/dist/context/nativeGenerateGuard.js +22 -0
- package/dist/core/modules/ToolsManager.js +13 -1
- package/dist/providers/anthropic/client.js +17 -1
- package/dist/proxy/codexFallback.js +16 -2
- package/dist/proxy/codexUsage.js +8 -0
- package/dist/proxy/proxyAnalysis.js +21 -3
- package/dist/proxy/proxyTracer.js +17 -4
- package/dist/proxy/requestLogger.js +15 -1
- package/dist/server/routes/claudeProxyRoutes.js +24 -4
- package/dist/server/routes/codexProxyRoutes.js +17 -2
- package/dist/types/codex.d.ts +2 -0
- package/dist/types/generate.d.ts +7 -1
- package/dist/types/proxy.d.ts +50 -0
- package/docs-site/static/search-index.json +44 -0
- package/package.json +2 -1
|
@@ -10623,6 +10623,34 @@
|
|
|
10623
10623
|
{"objectID":"a0fed319482e5c2a71f37c96ebffc2b6eb1fb886e67f53c5c498d376684b57d3","title":"Task 6: Land it properly","url":"/docs/superpowers/plans/2026-09-20-codex-fallback-compaction#task-6-land-it-properly","content":"[ ] Push only after explicit approval.\n[ ] Open the PR against ; include the F-table above as the rationale.\n[ ] Rebase-and-merge ().\n[ ] After semantic-release publishes, let auto-update converge the host, then delete the\n staged package directory and re-verify and the policy.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy history truncation — corrected implementation plan","lvl2":"Task 6: Land it properly","lvl3":""}},
|
|
10624
10624
|
{"objectID":"d7557da2eba5876d0f111c14641ebea00873bff13e0dc9eec2622921899e67c7","title":"Task 7: Measure the saving rather than assert it","url":"/docs/superpowers/plans/2026-09-20-codex-fallback-compaction#task-7-measure-the-saving-rather-than-assert-it","content":"[ ] Capture per model for a fixed window before the change —\n dollars, not token counts, since the three token streams bill at different rates.\n[ ] Capture the same window after, and report the delta per model, noting the\n cache-miss cost from C4 as a debit against the input-token saving.\n[ ] A saving that does not show up in did not happen.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy history truncation — corrected implementation plan","lvl2":"Task 7: Measure the saving rather than assert it","lvl3":""}},
|
|
10625
10625
|
{"objectID":"76c8e20d3ec9fd2cdf81377b97e93445e7503aa311909e6f7df89969b718c38b","title":"What is explicitly out of scope","url":"/docs/superpowers/plans/2026-09-20-codex-fallback-compaction#what-is-explicitly-out-of-scope","content":"Any summarising/semantic compaction inside the proxy (adds a model call to the requests\n this exists to make cheaper).\nEnabling truncation on .\nGemini's shape — not a configured fallback.\nRaising Vertex to 1M. That needs plumbed through\n plus proof the account is entitled; it is a separate change.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy history truncation — corrected implementation plan","lvl2":"What is explicitly out of scope","lvl3":""}},
|
|
10626
|
+
{"objectID":"bfb8304feba1d66943d4d08f66e99bb754908276a24a2414afa96bcb1d987318","title":"Proxy Account Routing Policies Implementation Plan","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies","content":"Proxy Account Routing Policies Implementation Plan\n\nFor agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox () syntax for tracking.\n\nGoal: Let an operator configure how the Claude proxy orders usable Anthropic OAuth accounts — headroom-first ranking, prefer-primary, session affinity, and spill-under-load — while the default configuration stays byte-for-byte identical to today's comparator.\n\nArchitecture: Extract the existing account comparator into a new pure module () with zero behaviour change (PR1), then build the four policy features on top of that extraction as additive, individually-gated logic wired through the existing quota-ordering call chain in (PR2). A second new pure module () tracks session→account bindings in a process-local, LRU-capped map. Every policy value rides the existing hot-reloadable runtime config snapshot; nothing adds a new config-loading mechanism.\n\nTech Stack: TypeScript (strict), Node.js, test runner, Hono-style route handlers, existing snapshot/reload machinery, workspaces.\n\nSpec: \n\nGrounding: This plan's line citations are verified against at (full sha ). Execution must start by rebasing the branch onto the current tip and re-verifying every citation by name/content search (, anchor-text lookup) — never by assuming the offsets below still hold arithmetically. moves; the anchors (function names, unique literals, doc-comment text) do not.\n\nGlobal Constraints\nDefault behaviour must stay byte-for-byte identical after both PRs merge (spec Goal).\nignores all five policy keys (spec Configuration).\ndisables quota-based ranking as today; and still apply (spec Configuration).\n: \\| , default (spec Configuration table).\n: boolean, default (spec Configuration table).\n: boolean, default (spec Configuration table).\n: integer, 60000–86400000, default (spec Configuration table).\n: integer, 0–100, default (off) (spec Configuration table).\nAll five keys accept kebab-case or camelCase, are validated at load, and hot-reload with the runtime config snapshot; an invalid value rejects the whole load and the last known-good snapshot stays active (spec Configuration intro).\nSession id comes from the existing path, not a new identity source (spec Component 2).\nOnly Anthropic accounts are ever bound; a Codex or Vertex fallback response never rebinds a session; spill counts only Anthropic accounts (spec Edge cases).\nTypes: aliases only (never ), domain prefix, barrel-only imports from , no type re-exports outside (CLAUDE.md rules 2, 7–13; spec Component 4).\nTests are end-to-end only, except the documented determinism exception in , which the new hooks extend and nothing wider (CLAUDE.md rule 15; spec Testing).\nAssertion messages never quote payloads — mismatches are described, not dumped (CLAUDE.md \"Keep payloads out of assertion messages\"; spec Testing).\nDelivery is exactly two PRs; juspay/neurolink's requires one commit per PR (spec Delivery).\nmust report the active policy and the number of bound sessions (spec Observability).\n's schema version stays ; new fields are additive only (spec Observability).\n\nReview Focus\nQuota routing disabled, policies still on. with or must still bind/prefer — a naive implementation that only wires policies inside the quota-ordered branch would silently drop this. Covered by Task 14's dedicated non-quota-ordered precedence step and its test.\nIdle-TTL boundary. An operator setting expects the binding to survive exactly up to that many milliseconds and expire the instant it's exceeded, not one request early or late. Covered by Task 10's exact-boundary test ( stays bound; expires).\nSpill onto a capacity-saturated account. An operator running both and expects a request spilled onto an account that is also at its admission cap to fall through the existing attempt loop to the next account, not hang or throw. Covered by Task 19's spill-plus-capacity-gate precedence test.\nConcurrent requests in one just-starting session. The spec's \"burst of new sessions\" case (14 concurrent sessions landing on one account) implies two parallel first-requests for the same new session id can race to bind different accounts before either completes. Covered by Task 19's parallel-unbound-requests test asserting the binding is whatever the first successful response lands on, and a second still-in-flight request is not corrupted by it.\nRanking/affinity/spill throwing mid-request. An operator who mistypes a hot-reloaded value that still passes soft validation (e.g. an object where a string was expected, coerced through at a call boundary) expects the request to still succeed via the pre-policy order, not 500. Covered by Task 14's try/catch fallback and Task 19's thrown-error test asserting and a successful response.\n\nFile Structure\n\nNew files:\n— pure. , , , , .\n— pure, process-local state. , , , .\n\nModified files:\n— comparator extraction, admi","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"","lvl3":""}},
|
|
10627
|
+
{"objectID":"e3588f80c4269eae1fef7ec99ec9fbe82ea72315cdf8507b8f6619404afe20c5","title":"Proxy Account Routing Policies Implementation Plan","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#proxy-account-routing-policies-implementation-plan","content":"For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox () syntax for tracking.\n\nGoal: Let an operator configure how the Claude proxy orders usable Anthropic OAuth accounts — headroom-first ranking, prefer-primary, session affinity, and spill-under-load — while the default configuration stays byte-for-byte identical to today's comparator.\n\nArchitecture: Extract the existing account comparator into a new pure module () with zero behaviour change (PR1), then build the four policy features on top of that extraction as additive, individually-gated logic wired through the existing quota-ordering call chain in (PR2). A second new pure module () tracks session→account bindings in a process-local, LRU-capped map. Every policy value rides the existing hot-reloadable runtime config snapshot; nothing adds a new config-loading mechanism.\n\nTech Stack: TypeScript (strict), Node.js, test runner, Hono-style route handlers, existing snapshot/reload machinery, workspaces.\n\nSpec: \n\nGrounding: This plan's line citations are verified against at (full sha ). Execution must start by rebasing the branch onto the current tip and re-verifying every citation by name/content search (, anchor-text lookup) — never by assuming the offsets below still hold arithmetically. moves; the anchors (function names, unique literals, doc-comment text) do not.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Proxy Account Routing Policies Implementation Plan","lvl3":""}},
|
|
10628
|
+
{"objectID":"7addb5544c52a4278bcd2dd19cb3b01ca2fa52b1a6a26f7ff8507ab9259204f4","title":"Global Constraints","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#global-constraints","content":"Default behaviour must stay byte-for-byte identical after both PRs merge (spec Goal).\nignores all five policy keys (spec Configuration).\ndisables quota-based ranking as today; and still apply (spec Configuration).\n: \\| , default (spec Configuration table).\n: boolean, default (spec Configuration table).\n: boolean, default (spec Configuration table).\n: integer, 60000–86400000, default (spec Configuration table).\n: integer, 0–100, default (off) (spec Configuration table).\nAll five keys accept kebab-case or camelCase, are validated at load, and hot-reload with the runtime config snapshot; an invalid value rejects the whole load and the last known-good snapshot stays active (spec Configuration intro).\nSession id comes from the existing path, not a new identity source (spec Component 2).\nOnly Anthropic accounts are ever bound; a Codex or Vertex fallback response never rebinds a session; spill counts only Anthropic accounts (spec Edge cases).\nTypes: aliases only (never ), domain prefix, barrel-only imports from , no type re-exports outside (CLAUDE.md rules 2, 7–13; spec Component 4).\nTests are end-to-end only, except the documented determinism exception in , which the new hooks extend and nothing wider (CLAUDE.md rule 15; spec Testing).\nAssertion messages never quote payloads — mismatches are described, not dumped (CLAUDE.md \"Keep payloads out of assertion messages\"; spec Testing).\nDelivery is exactly two PRs; juspay/neurolink's requires one commit per PR (spec Delivery).\nmust report the active policy and the number of bound sessions (spec Observability).\n's schema version stays ; new fields are additive only (spec Observability).","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Global Constraints","lvl3":""}},
|
|
10629
|
+
{"objectID":"75e967e3877e1ec1b6ab4fbad257d2bb3c37c71b9c4d4fd3bdaf66f8ab65e6da","title":"Review Focus","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#review-focus","content":"Quota routing disabled, policies still on. with or must still bind/prefer — a naive implementation that only wires policies inside the quota-ordered branch would silently drop this. Covered by Task 14's dedicated non-quota-ordered precedence step and its test.\nIdle-TTL boundary. An operator setting expects the binding to survive exactly up to that many milliseconds and expire the instant it's exceeded, not one request early or late. Covered by Task 10's exact-boundary test ( stays bound; expires).\nSpill onto a capacity-saturated account. An operator running both and expects a request spilled onto an account that is also at its admission cap to fall through the existing attempt loop to the next account, not hang or throw. Covered by Task 19's spill-plus-capacity-gate precedence test.\nConcurrent requests in one just-starting session. The spec's \"burst of new sessions\" case (14 concurrent sessions landing on one account) implies two parallel first-requests for the same new session id can race to bind different accounts before either completes. Covered by Task 19's parallel-unbound-requests test asserting the binding is whatever the first successful response lands on, and a second still-in-flight request is not corrupted by it.\nRanking/affinity/spill throwing mid-request. An operator who mistypes a hot-reloaded value that still passes soft validation (e.g. an object where a string was expected, coerced through at a call boundary) expects the request to still succeed via the pre-policy order, not 500. Covered by Task 14's try/catch fallback and Task 19's thrown-error test asserting and a successful response.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Review Focus","lvl3":""}},
|
|
10630
|
+
{"objectID":"b907c7a9cf507a7ac2ab082863656ba2b86da4ee69acabe7ab4528dcd51a27cc","title":"File Structure","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#file-structure","content":"New files:\n— pure. , , , , .\n— pure, process-local state. , , , .\n\nModified files:\n— comparator extraction, admission-lease redesign, rewrite, session binding, additions.\n— hard validation + soft parsing for the five new keys.\n— snapshot fields, fingerprint, hot-reload affinity-store clearing.\n— five new values.\n— new policy/affinity/spill types, and / extensions.\n— five new optional fields.\n— policy + bound-session-count fields.\n— new deterministic + integration + CLI tests, one new header sentence.\n— five new keys, correction.\n\nNot part of the repo: the DuckDB default-equivalence replay script (Task 5) is written to the session scratchpad directory, run locally, and its result is pasted into PR1's description. It is never committed.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"File Structure","lvl3":""}},
|
|
10631
|
+
{"objectID":"2d2b9e51c75ba989bba4ba1ada56a7059cbceba41a1e1a923f7f1a4c41b6dca8","title":"Task 1: Extract compareExpiryFirst and a narrow rankAccounts into accountRanking.ts","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-1-extract-compareexpiryfirst-and-a-narrow-rankaccounts-into-accountrankingts","content":"Files:\nCreate: \nTest: \n\nInterfaces:\nConsumes: , , (all from , already defined).\nProduces: ; . Task 2 and Task 11 both build on these exact names.\n[ ] Step 1: Write the failing test for moved verbatim\n\nAdd near the top of , after the existing imports:\n\nAdd a new test function (near , following its structure):\n\nAdd a helper above it (mirrors 's override-defaults pattern at ):\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL (or a module-not-found error) because does not exist yet.\n[ ] Step 3: Create with the moved comparator and narrow \n[ ] Step 4: Run test to verify it passes\n\nRun: \nExpected: the new test passes; note the suite as a whole still calls the old in-file at this point (removed in Task 2), so both coexist until then.\n[ ] Step 5: Commit\n\nThis is the first task of PR1, so it creates the branch and the PR's single commit (every later PR1 task amends it).","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 1: Extract compareExpiryFirst and a narrow rankAccounts into accountRanking.ts","lvl3":""}},
|
|
10632
|
+
{"objectID":"d0e04f8d6163562249e2ec29d3c64fa45bbf912ce1b5cd2437786607831ac41c","title":"Task 2: Wire orderAccountsByQuotaWithMetrics as a thin wrapper; delete the old local comparator","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-2-wire-orderaccountsbyquotawithmetrics-as-a-thin-wrapper-delete-the-old-local-comparator","content":"Files:\nModify: (delete , rewrite ), ('s branch)\nTest: (existing and quota-routing suites, unmodified)\n\nInterfaces:\nConsumes: , from Task 1.\nProduces: keeps its exact existing signature and return shape — Task 12 (PR2) is the only place that changes it.\n[ ] Step 1: Add the import\n\nAt the top of , alongside the other imports (e.g. next to ):\n[ ] Step 2: Delete (lines 2138-2209) and rewrite \n\nReplace the old function body:\n\n (lines 2242-2282, delegating through the wrapper) is untouched — it already calls .\n[ ] Step 3: Update 's branch to use the imported comparator\n\nIn (), the mode/selection block currently calls the now-deleted local function:\n\nChange to :\n[ ] Step 4: Run the existing route-order tests to confirm zero behaviour change\n\nRun: \nExpected: PASS, including the pre-existing () and (), neither of which was modified. Their continued passing is the evidence the extraction changed nothing observable.\n[ ] Step 5: Type-check\n\nRun: \nExpected: PASS — no remaining reference to anywhere in the file ( returns nothing).\n[ ] Step 6: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 2: Wire orderAccountsByQuotaWithMetrics as a thin wrapper; delete the old local comparator","lvl3":""}},
|
|
10633
|
+
{"objectID":"a5eeaa993537e5633141ea98561c6623404266eae9850285aefab3f54db782b0","title":"Task 3: Redesign account admission to count in-flight leases uniformly; add getAccountInflight","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-3-redesign-account-admission-to-count-in-flight-leases-uniformly-add-getaccountinflight","content":"Files:\nModify: (admission lease subsystem), ()\nTest: \n\nInterfaces:\nConsumes: , (existing types, ).\nProduces: , exposed on . Task 14 (PR2) calls this directly (it's a route-local function, not exported from the module) to build the spill in-flight map.\n[ ] Step 1: Write the failing test for unlimited-account in-flight counting\n\nAdd to :\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — is not a function yet.\n[ ] Step 3: Redesign , add , delete \n\n () has exactly two usages in the file — its own declaration and one inside — so removing it is self-contained. Replace:\n\nwith:\n\nand replace :\n\n's existing guard already makes idempotent, so the double-release case in the test needs no additional code — it's covered by unchanged logic (). already reaps the map entry once returns to with no waiters, so correctly falls back to for an account with no state entry at all.\n[ ] Step 4: Add to \n\nIn the object literal (), add a line near the other admission hooks:\n[ ] Step 5: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 6: Run the existing capacity-limited admission tests to confirm no regression\n\nRun: \nExpected: any pre-existing admission tests still PASS — the capped branch's logic () is byte-identical to before, only reordered after the state lookup.\n[ ] Step 7: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 3: Redesign account admission to count in-flight leases uniformly; add getAccountInflight","lvl3":""}},
|
|
10634
|
+
{"objectID":"b8a3db54883f06cbb662928458cbfd5acd3935259890c53789aca42a5728e382","title":"Task 4: Deterministic parity fixture proving the extraction is behaviour-preserving","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-4-deterministic-parity-fixture-proving-the-extraction-is-behaviour-preserving","content":"Files:\nTest: \n\nInterfaces:\nConsumes: , (direct import, Task 1); , , (existing route hooks).\nProduces: nothing new — this task is tests only.\n[ ] Step 1: Write a synthetic multi-account fixture covering every tie-break branch\n\nAdd to :\n\nThis cross-checks the pure module against the still-live route surface: the direct side's fabricated metrics and the wrapper's quota-derived metrics are built to agree on every branch that decides these six accounts' order, including the scoped-saturation branch via a real matched window — the parity claim is exactly \"these two entry points onto the same comparator produce the same order.\"\n[ ] Step 2: Register the new tests\n\nIn the array (), add:\n[ ] Step 3: Run the full suite\n\nRun: \nExpected: PASS — all three new tests green, no existing test broken.\n[ ] Step 4: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 4: Deterministic parity fixture proving the extraction is behaviour-preserving","lvl3":""}},
|
|
10635
|
+
{"objectID":"4f91df67cc04e28388d3e33b00db11ef150f5cdb751971325e6dc2eaeb9dad8b","title":"Task 5: Local DuckDB default-equivalence replay (scratch-only, not committed)","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-5-local-duckdb-default-equivalence-replay-scratch-only-not-committed","content":"Files:\nCreate (scratchpad only, never under the repo's git tree): \n\nInterfaces:\nConsumes: the frozen telemetry DuckDB snapshot referenced by the standing rule (everything under is read-only; never write the DuckDB file). The exact table/column names live in that snapshot's own / and must be read at execution time — they are outside this repository's version control, so this task cannot hardcode them the way every other task grounds in checked-in source.\nConsumes: / semantics (Task 1) — the script re-implements the same comparator in Python rather than shelling out to , so its correctness is checked against the TypeScript unit tests in Task 4, not the other way around.\nProduces: a printed pass/fail count plus a short prose summary, pasted into PR1's description. No repo file changes.\n[ ] Step 1: Read the snapshot's own schema guide before writing any query\n\nLocate the frozen lake directory (per the standing rule, under ) and read its / to find: the decisions table name, the per-decision candidate rows table (or nested column), and which column holds the recorded post-sort rank vs. the pre-sort quota metrics used for that decision. Do not proceed to Step 2 until these are identified.\n[ ] Step 2: Confirm the read-only-open constraint before touching the file\n\n`python","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 5: Local DuckDB default-equivalence replay (scratch-only, not committed)","lvl3":""}},
|
|
10636
|
+
{"objectID":"42a189b85f2e983af4844853b3a3b8c876e3073daba853149d9a0f9af8f1b15f","title":"connection is a bug even if nothing is ever written through it.","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#connection-is-a-bug-even-if-nothing-is-ever-written-through-it","content":"con = duckdb.connect(database=\".duckdb\", read_only=True)\npython\ndef compareexpiryfirst(a, b, primary_key):\n \"\"\"Ported 1:1 from accountRanking.ts's compareExpiryFirst. Returns a\n negative number when should sort before .\"\"\"\n if a[\"usable\"] != b[\"usable\"]:\n return -1 if a[\"usable\"] else 1\n if not a[\"usable\"] and not b[\"usable\"]:\n au = a[\"cooling_until\"] or float(\"inf\")\n bu = b[\"cooling_until\"] or float(\"inf\")\n return 0 if au == bu else au - bu\n if a[\"quotaevidencerank\"] != b[\"quotaevidencerank\"]:\n return a[\"quotaevidencerank\"] - b[\"quotaevidencerank\"]\n if a[\"saturated\"] != b[\"saturated\"]:\n return 1 if a[\"saturated\"] else -1\n if a[\"scopedsaturated\"] != b[\"scopedsaturated\"]:\n return 1 if a[\"scoped_saturated\"] else -1\n if a[\"saturated\"] and b[\"saturated\"]:\n if a[\"sessionresetbucket\"] != b[\"sessionresetbucket\"]:\n return a[\"sessionresetbucket\"] - b[\"sessionresetbucket\"]\n if a[\"weeklyreset\"] != b[\"weeklyreset\"]:\n return a[\"weeklyreset\"] - b[\"weeklyreset\"]\n else:\n if a[\"weeklyreset\"] != b[\"weeklyreset\"]:\n return a[\"weeklyreset\"] - b[\"weeklyreset\"]\n if a[\"sessionresetbucket\"] != b[\"sessionresetbucket\"]:\n return a[\"sessionresetbucket\"] - b[\"sessionresetbucket\"]\n if (\n a[\"scoped_used\"] is not None\n and b[\"scoped_used\"] is not None\n and a[\"scopedusedforsort\"] != b[\"scopedusedforsort\"]\n ):\n return b[\"scopedusedforsort\"] - a[\"scopedusedforsort\"]\n if a[\"weeklyusedforsort\"] != b[\"weeklyusedforsort\"]:\n return b[\"weeklyusedforsort\"] - a[\"weeklyusedforsort\"]\n if primarykey and (a[\"key\"] == primarykey) != (b[\"key\"] == primary_key):\n return -1 if a[\"key\"] == primary_key else 1\n return 0\n\ndef replaydecision(rowcandidates, primarykey, recordedorder):\n canonical = sorted(rowcandidates, key=lambda c: c[\"accountlabel\"])\n replayed = sorted(\n canonical,\n key=functools.cmpt","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"connection is a bug even if nothing is ever written through it.","lvl3":""}},
|
|
10637
|
+
{"objectID":"0c15899cab994ccb6131607437aab9d8e1ab9f225941035d644c60b94988ecbb","title":"Task 6: Quality gates and finalize the PR1 commit","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-6-quality-gates-and-finalize-the-pr1-commit","content":"Files: none (verification only)\n[ ] Step 1: Type check\n\nRun: \nExpected: PASS.\n[ ] Step 2: Lint\n\nRun: \nExpected: PASS — no , , or violations from the new (it has no local type aliases and is imported directly under the already-allowed determinism exception, so no change is needed).\n[ ] Step 3: Full test suite\n\nRun: \nExpected: PASS.\n[ ] Step 4: Build\n\nRun: \nExpected: PASS.\n[ ] Step 5: Finalize the commit message and open the PR\n\nDo not push and do not open the PR yet unless explicitly asked — leave the branch ready. Report the exact replay result and task count (6 tasks) back to whoever requested this plan.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 6: Quality gates and finalize the PR1 commit","lvl3":""}},
|
|
10638
|
+
{"objectID":"829a18b8838103b9ca7fdef1c4d5bd9759d740dc459e178de922f36ed197a501","title":"Task 7: Types — policy, affinity, and spill evidence","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-7-types-policy-affinity-and-spill-evidence","content":"Files:\nModify: (near /, ), (), ()\n\nInterfaces:\nProduces: , , , , (all in , barrel-exported). Every later task imports these from (or from routes).\n[ ] Step 1: Add the new policy/evidence types to \n\nInsert immediately after (after the closing at what is currently line 702):\n[ ] Step 2: Extend with the three new optional fields\n\nChange (currently ending at ):\n[ ] Step 3: Extend in with the five new optional fields\n\nAfter (currently the last field before the closing at line 1243-1244):\n[ ] Step 4: Append the five new routing reasons\n\nIn , change:\n[ ] Step 5: Type check\n\nRun: \nExpected: PASS — these are purely additive/optional fields, so nothing downstream breaks yet.\n[ ] Step 6: Commit\n\nThis is the first task of PR2, so it creates the branch and PR2's single commit.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 7: Types — policy, affinity, and spill evidence","lvl3":""}},
|
|
10639
|
+
{"objectID":"0276e100978c10e2b11a3bcd37b90f967171b6fa2eed30a30a3561771c9a5d89","title":"Task 8: Config parsing and validation for the five new keys","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-8-config-parsing-and-validation-for-the-five-new-keys","content":"Files:\nModify: (hard validation near , soft parsing near )\nTest: \n\nInterfaces:\nConsumes: / pattern from as a naming precedent only — the two new numeric keys get their own local bounds, not these.\nProduces: rejects invalid values with a pushed error string; returns a with the five new fields populated when valid, warned-and-omitted when not.\n[ ] Step 1: Write the failing test for hard validation rejecting an invalid \n\nAdd to :\n\nNote: is currently module-local (not exported). This step also requires exporting it — see Step 3.\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — the three new validation/parsing branches don't exist yet, and isn't exported.\n[ ] Step 3: Export and add the two local bound constants\n\nNear the top of , alongside the existing / import:\n\nChange to .\n[ ] Step 4: Add hard validation\n\nInside 's block, immediately after the existing check (ending just before the closing that was at ):\n[ ] Step 5: Add soft parsing\n\nInside , immediately after the existing block (the function's last block before ):\n[ ] Step 6: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 7: Register the new tests\n[ ] Step 8: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 8: Config parsing and validation for the five new keys","lvl3":""}},
|
|
10640
|
+
{"objectID":"dd22edf9e975d78239d03aef4eb5ee10f61ef6be9b07587b8d70d664ad8ba6c7","title":"Task 9: Runtime config snapshot carries the five policy values","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-9-runtime-config-snapshot-carries-the-five-policy-values","content":"Files:\nModify: (), ()\n\nInterfaces:\nConsumes: 's output (Task 8) via the existing variable already in scope in .\nProduces: (which extends ) now carries , , , , . Task 14/15/18 all read these off the snapshot.\n[ ] Step 1: Extend \n\nIn , change:\n[ ] Step 2: Resolve the five values in , following the existing precedent exactly\n\nIn , immediately after :\n\nNo environment-variable layer and no dedicated resolver function — this mirrors 's simple inline nullish-coalescing rather than /'s pattern, because none of the five keys has (or the spec asks for) an env-var override.\n[ ] Step 3: Add the five values to the fingerprint and the returned snapshot\n[ ] Step 4: Type check\n\nRun: \nExpected: FAIL at this point — the POST /v1/messages route's inline fallback-snapshot literal () and / do not yet supply these fields. This is expected; Task 15 completes the threading. Confirm the errors are exactly the two call sites named here ( to locate the fallback literal) and nowhere else.\n[ ] Step 5: Commit (amend)\n\n(The type-check failure from Step 4 is carried forward intentionally; Task 15 clears it. Do not run / as gates again until Task 15 is done — is used here only to confirm the two known call sites, not as a pass/fail gate for this task.)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 9: Runtime config snapshot carries the five policy values","lvl3":""}},
|
|
10641
|
+
{"objectID":"efb83ff09d62d10c1c1b9afb67769b19bd4b043702f6517e33bfeab37b3637a0","title":"Task 10: sessionAffinity.ts — the session→account binding store","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-10-sessionaffinityts-the-sessionaccount-binding-store","content":"Files:\nCreate: \nTest: \n\nInterfaces:\nProduces: , , , , and a namespace object bundling all four. Task 14 (ranking call sites) and Task 16 (binding on success) both import this.\nDesign decision: the spec's is written with two parameters, but is hot-reloadable per-request config, not a fixed module constant, so it is threaded as an explicit third parameter here — the module has no other way to know the currently configured TTL. never refreshes a binding's position or ; only does, since the spec's \"idle TTL counts from the session's last served request\" ties freshness to being served, not merely checked.\nDesign decision: the per-record shape () is an inline object type on the 's generic parameter, not a named alias, so it does not trigger CLAUDE.md rule 2's \"all type definitions go in \" for a private, single-use implementation detail with no external consumer.\n[ ] Step 1: Write the failing tests for bind/get, idle expiry, eviction, and clear\n\nAdd to :\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — does not exist.\n[ ] Step 3: Write the module\n[ ] Step 4: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 5: Register the new tests\n[ ] Step 6: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 10: sessionAffinity.ts — the session→account binding store","lvl3":""}},
|
|
10642
|
+
{"objectID":"fcfb234c614ebfe696518e8c8ed6c664fccc283a966bed092fc4846951dcbf60","title":"Task 11: accountRanking.ts PR2 extension — compareHeadroomFirst, precedence, spill","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-11-accountrankingts-pr2-extension-compareheadroomfirst-precedence-spill","content":"Files:\nModify: \nTest: \n\nInterfaces:\nProduces: ; ; ; extended .\nConsumes: (Task 7).\n[ ] Step 1: Write the failing test for 's headroom rung\n\nAdd to :\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — is not exported yet.\n[ ] Step 3: Add \n\nAppend to :\n[ ] Step 4: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 5: Write the failing test for 's precedence\n[ ] Step 6: Run test to verify it fails\n\nRun: \nExpected: FAIL — is not exported yet.\n[ ] Step 7: Add \n[ ] Step 8: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 9: Write the failing test for extended \n[ ] Step 10: Run test to verify it fails\n\nRun: \nExpected: FAIL — doesn't yet accept //.\n[ ] Step 11: Extend \n\nReplace the Task 1 version:\n[ ] Step 12: Run test to verify it passes\n\nRun: \nExpected: PASS, and re-run Task 4's to confirm the default-args behaviour is still identical.\n[ ] Step 13: Write the failing test for \n[ ] Step 14: Run test to verify it fails\n\nRun: \nExpected: FAIL — is not exported yet.\n[ ] Step 15: Add \n[ ] Step 16: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 17: Add a seeded randomized transitivity check\n[ ] Step 18: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 19: Register every new test from this task\n[ ] Step 20: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 11: accountRanking.ts PR2 extension — compareHeadroomFirst, precedence, spill","lvl3":""}},
|
|
10643
|
+
{"objectID":"459ec51703ed8e203d88167801ea903261c07d76d78a0ed74063ef7e9ee7606c","title":"Task 12: orderAccountsByQuotaWithMetrics policy extension and buildRoutingDecision's policySelectionReason","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-12-orderaccountsbyquotawithmetrics-policy-extension-and-buildroutingdecisions-policyselectionreason","content":"Files:\nModify: (), (), ()\n\nInterfaces:\nConsumes: 's extended signature (Task 11).\nProduces: returns ; accepts , , , .\n[ ] Step 1: Write the failing test for 's override\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — doesn't accept a argument yet.\n[ ] Step 3: Extend \n\n (the label-only wrapper) is untouched — it only ever reads off the return value, which keeps working.\n[ ] Step 4: Extend \n\nAdd three new optional fields to its type and use them in the branch and the return object:\n\nIn the mode/selectionReason block:\n\nIn the returned object, append after :\n\nOmitting /// reproduces PR1's exact output — this preserves every existing call site (including Task 6's replay assumptions) without modification.\n[ ] Step 5: Extend \n[ ] Step 6: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 7: Re-run the Task 2 route-order tests to confirm no regression\n\nRun: \nExpected: PASS — and never pass a argument, so they exercise the exact PR1 path.\n[ ] Step 8: Register the new test\n[ ] Step 9: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 12: orderAccountsByQuotaWithMetrics policy extension and buildRoutingDecision's policySelectionReason","lvl3":""}},
|
|
10644
|
+
{"objectID":"b161eed43a95b3a9bb82970cc23098beb4c6b99f70fb03d2797a8a8a711a86a8","title":"Task 13: Thread the Claude Code session id through loadClaudeProxyAccounts","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-13-thread-the-claude-code-session-id-through-loadclaudeproxyaccounts","content":"Files:\nModify: (signature), (tail), ( destructure)\nModify: ()\n\nInterfaces:\nProduces: . Task 14 consumes it as 's argument.\n[ ] Step 1: Write the failing test asserting is threaded through\n\n(Rather than exercising the full route — which needs a live account pool and is covered end-to-end by Task 19 — this task's own test only pins the plumbing hook that Task 19 depends on. Add the hook in Step 4.)\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL.\n[ ] Step 3: Move earlier and add to the returned context\n\nIn (currently ending at ), the call:\n\ncurrently runs after has already been called (). Move the extraction up so is available before that call. Replace the whole tail:\n\n(, , , , are added to 's own /destructure in Task 15, alongside 's rewrite in Task 14 — this step only moves the extraction and adds the plumbing that depends on it existing.)\n[ ] Step 4: Extend and add the pinning test hook\n\nIn :\n\nIn :\n[ ] Step 5: Add to 's destructure\n[ ] Step 6: Run test to verify it passes\n\nRun: \nExpected: PASS for the new hook test; expect to still fail until Task 14/15 supply //etc. to and 's own args — that's expected and cleared by Task 15.\n[ ] Step 7: Register the new test\n[ ] Step 8: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 13: Thread the Claude Code session id through loadClaudeProxyAccounts","lvl3":""}},
|
|
10645
|
+
{"objectID":"e56e61ee45c533757ab1712724f47f87a6c187f8556331227e846f7fd211d6e1","title":"Task 14: Rewrite selectClaudeProxyAccountOrder to apply the full precedence chain","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-14-rewrite-selectclaudeproxyaccountorder-to-apply-the-full-precedence-chain","content":"Files:\nModify: \n\nInterfaces:\nConsumes: , , (extended, Task 12), (Task 10), (Task 3).\nProduces: 's new signature, consumed by Task 15's threading through /.\n[ ] Step 1: Write the failing test for the \"quota routing off, affinity still applies\" case (Review Focus item 1)\n\nThis requires a new — added in Step 4, since itself is route-local.\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL.\n[ ] Step 3: Write the failing test for \"thrown spill on the quota-off path restores the base order\" (Review Focus item 1)\n\nThe non-quota-ordered branch's catch must not leave a partial policy reorder\nin place. Bind session affinity so genuinely\nreorders (), then force\n to throw regardless of that reason — its own guard normally\nskips /, so a deterministic test-only\nhook (, added in Step 5) is the only way to reach\nthe throwing branch on this reason. The assertion is that the pre-policy\norder is served, not the partial reorder:\n\nThis requires — added in Step 7,\nalongside 's declaration in Step 5 and its check\ninside in Step 6.\n[ ] Step 4: Run test to verify it fails\n\nRun: \nExpected: FAIL (the hook doesn't exist yet, and even once it does, the\npre-fix catch block doesn't restore ).\n[ ] Step 5: Add the once-per-worker failure-mode logger and the test-only spill-throw hook\n\nNear 's current location:\n[ ] Step 6: Rewrite \n[ ] Step 7: Add the test-only wrapper hooks\n\nIn :\n[ ] Step 8: Run tests to verify they pass\n\nRun: \nExpected: PASS (both and\n).\n[ ] Step 9: Register the new tests\n[ ] Step 10: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 14: Rewrite selectClaudeProxyAccountOrder to apply the full precedence chain","lvl3":""}},
|
|
10646
|
+
{"objectID":"a9d029337d9908f4581ab3395356e2dc614e59aba997203fb88725a6522b70a9","title":"Task 15: Thread the five policy values through the call chain to /v1/messages","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-15-thread-the-five-policy-values-through-the-call-chain-to-v1messages","content":"Files:\nModify: ( args), ( args + call site), ( fallback literal), (call into )\n\nInterfaces:\nConsumes: 's five new fields (Task 9).\nProduces: every function in the chain now accepts and forwards , , , , .\n[ ] Step 1: Extend 's args and destructure\n\n(the unchanged token-store/cooldown/account-assembly body follows, ending at the Task 13 tail which now passes into .)\n[ ] Step 2: Extend 's args, destructure, and its call into \n[ ] Step 3: Extend the POST /v1/messages route's fallback snapshot literal and call site\n\nIn the inline fallback used when is absent ():\n\nAnd the call into ():\n[ ] Step 4: Type check\n\nRun: \nExpected: PASS — this clears the Task 9 Step 4 failure.\n[ ] Step 5: Run the full proxy test suite\n\nRun: \nExpected: PASS.\n[ ] Step 6: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 15: Thread the five policy values through the call chain to /v1/messages","lvl3":""}},
|
|
10647
|
+
{"objectID":"6f1d084d9a6a60141a153bcc1bdbe70aa5866d1b9f505e5d990ce43a4605089d","title":"Task 16: Bind the session to the account that served the successful response","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-16-bind-the-session-to-the-account-that-served-the-successful-response","content":"Files:\nModify: \n\nInterfaces:\nConsumes: (Task 10), / (Task 15's threading), (already in scope as the loop's current account).\n[ ] Step 1: Write the failing test for bind-on-success\n\n(This task's real coverage is the end-to-end CLI test in Task 19, which drives an actual response through the loop; this unit-level check exists only to keep the task independently testable per the plan's \"each task ends with an independently testable deliverable\" rule.)\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: this specific test passes trivially since it only calls directly (already built in Task 10) — run it to confirm the harness wiring, then proceed to the real implementation step, which Task 19 will exercise end-to-end.\n[ ] Step 3: Insert the binding call\n\nIn 's attempt loop (), between the existing lines:\n\nAdd the import at the top of the file, alongside the Task 12 import:\n[ ] Step 4: Run the full proxy suite\n\nRun: \nExpected: PASS.\n[ ] Step 5: Register the new test\n[ ] Step 6: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 16: Bind the session to the account that served the successful response","lvl3":""}},
|
|
10648
|
+
{"objectID":"84479bdab31b76239dda2e69752f138e1abb963e59b4888a4735c8e0b091b3f0","title":"Task 17: Clear the affinity store when session affinity is disabled by a hot reload","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-17-clear-the-affinity-store-when-session-affinity-is-disabled-by-a-hot-reload","content":"Files:\nModify: (near the registration)\n\nInterfaces:\nConsumes: , (existing), (Task 10).\n[ ] Step 1: Write the failing test for the disable-transition clearing the store\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: this test exercises only local logic and will pass immediately — it documents the transition rule that Step 3 wires into the real listener. Proceed to Step 3 regardless, since the real assertion is the CLI-level behavior in Task 19.\n[ ] Step 3: Wire the transition check into the reload listener\n\nIn , near the top of the function containing (module scope, alongside other state for that function):\n\nInside the existing callback, immediately after :\n\nAdd the import at the top of :\n\n(verify the exact relative path against this file's existing imports before committing — to is two levels up then into ).\n[ ] Step 4: Run the local transition test\n\nRun: \nExpected: PASS.\n[ ] Step 5: Type check\n\nRun: \nExpected: PASS.\n[ ] Step 6: Register the new test\n[ ] Step 7: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 17: Clear the affinity store when session affinity is disabled by a hot reload","lvl3":""}},
|
|
10649
|
+
{"objectID":"9eb8a351f562b3838424cf2e5d95246326c4b11ca49eab941b373c8ea82a9d5e","title":"Task 18: /status reports the active policy and bound-session count","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-18-status-reports-the-active-policy-and-bound-session-count","content":"Files:\nModify: (the JSON response)\n\nInterfaces:\nConsumes: (already resolved in 's handler via ), (Task 10).\n[ ] Step 1: Write the failing CLI test asserting exposes and \n\n(/// are the existing CLI-suite helpers already used by this file's other tests — reuse them rather than reimplementing process management.)\n[ ] Step 2: Run test to verify it fails\n\nRun: \nExpected: FAIL — doesn't return / yet.\n[ ] Step 3: Add the fields to 's response\n\nIn , the inside the handler (), add two fields as siblings of :\n\n here is the same already resolved earlier in the handler () and used for ; unlike 's fallback, these five fields default straight to the spec's own defaults when there is no runtime config snapshot at all, since (the static CLI-start options) never carried per-request routing policy values.\n[ ] Step 4: Run test to verify it passes\n\nRun: \nExpected: PASS.\n[ ] Step 5: Type check\n\nRun: \nExpected: PASS.\n[ ] Step 6: Register the new test\n[ ] Step 7: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 18: /status reports the active policy and bound-session count","lvl3":""}},
|
|
10650
|
+
{"objectID":"5bc19c1af17e5546677a9acc2c27c0e5a9bcb3e7b5305d579b1026f740333134","title":"Task 19: Precedence, concurrency, and failure-mode integration tests; hot-reload and invalid-value CLI tests","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-19-precedence-concurrency-and-failure-mode-integration-tests-hot-reload-and-invalid-value-cli-tests","content":"Files:\nModify: \n\nInterfaces:\nConsumes: (Task 14), / (Task 3), (Task 10), the existing CLI-suite proxy-process helpers.\n[ ] Step 1: Write the transient-cooldown-then-recovery precedence test (spec Testing: \"a transient cooldown on A keeps the session on B afterwards\")\n[ ] Step 2: Write the spill-plus-capacity-gate test (Review Focus item 3)\n[ ] Step 3: Write the parallel-unbound-requests test (Review Focus item 4)\n[ ] Step 4: Write the thrown-policy-error fallback test\n[ ] Step 5: Write the CLI end-to-end tests — invalid value rejected, hot-reload works\n\n( follows this suite's existing pattern for exercising the CLI's SIGHUP/file-watch reload path — reuse whichever of the two the file's other hot-reload tests already use, rather than adding a third mechanism.)\n[ ] Step 6: Run all new tests to verify they fail first, then pass after nothing further is needed\n\nRun: \nExpected: every test in this task passes immediately, since Tasks 1–18 already implement everything they exercise — this task is pure test coverage closing the Review Focus gaps, with no new production code.\n[ ] Step 7: Register all six tests\n[ ] Step 8: Add the suite-header sentence documenting the new hooks' determinism exception\n\nNear the end of the existing determinism-exception docstring at the top of (lines 1-51):\n[ ] Step 9: Commit (amend)","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 19: Precedence, concurrency, and failure-mode integration tests; hot-reload and invalid-value CLI tests","lvl3":""}},
|
|
10651
|
+
{"objectID":"e908f8259c78b49fb4a676e949f548e53913625d4407d7475f2af9880b12a0d8","title":"Task 20: Documentation and PR2 finalization","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#task-20-documentation-and-pr2-finalization","content":"Files:\nModify: \n[ ] Step 1: Add the five new keys to the config reference\n\nAdd a new subsection (matching the doc's existing per-key table format) documenting , , , , — values, defaults, and meaning exactly as in the spec's Configuration table (reproduced in this plan's Global Constraints section), plus the and interaction notes.\n[ ] Step 2: Correct the description\n\nFind the existing text describing as \"tried first under fill-first\" (or equivalent phrasing) and correct it: with quota routing, the primary account is the final tiebreaker in the ranking order, not tried first, unless is explicitly set — matching the spec's Documentation section and the 0-decisions-decided-by- telemetry finding.\n[ ] Step 3: Correct every matching inline source comment\n\nThe stale claim is not confined to — widen the sweep to all of :\n\nThis turns up two comments repeating the stale unqualified claim, and five unrelated ones that describe different subsystems and must be left untouched:\n— 's doc comment (already read in Task 7). Current text:\n \n Correct to:\n— the primary-account parsing comment. Current text:\n \n Correct to:\nLeave unchanged — each describes a different, still-accurate subsystem: (peer priority), (wire-id model matching), (retry avoidance), (pool headroom snapshot), and (provider auto-select fallback chain), ( priority ordering).\n\nRe-run the same after editing: it must show the two corrected comments' new wording and the five unrelated matches, unchanged.\n[ ] Step 4: Full quality gates\n\nRun in order:\n\nExpected: all PASS.\n[ ] Step 5: Finalize the PR2 commit message\n\nDo not push and do not open the PR yet unless explicitly asked.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Task 20: Documentation and PR2 finalization","lvl3":""}},
|
|
10652
|
+
{"objectID":"1a9d42a54aa7d44c1981e097a8119a8a02dc29b4b7a6b28b33679ed1265beaa1","title":"Self-Review","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#self-review","content":"Spec coverage: every spec section maps to a task — Goal/default-unchanged (Global Constraints + Tasks 2, 12 preserving PR1 exactly), Evidence (informs Task 20's docs and PR2's commit message, no separate task needed), Configuration (Tasks 7, 8, 9), Rankings (Task 11), Precedence (Tasks 11, 14), Components 1-4 (Tasks 1/11 = accountRanking.ts, Task 10 = sessionAffinity.ts, Task 3 = in-flight counting, Task 7 = types/config), Request flow steps 1-8 (Tasks 13, 14, 16), Edge cases (Task 19's precedence tests + Task 14's / gating), Failure mode (Task 14's try/catch + Task 19's thrown-error test), Observability (Tasks 7, 12, 14, 18), Testing (Tasks 4, 10, 11, 19), Rollout (no code — the suggested config is an operator action, not a deliverable), Delivery (two PRs as structured), Documentation (Task 20), Out of scope (no task touches per-model policies, weighted scoring, cross-restart persistence, account reserve, or cooldown/rate-limit/state-persistence changes — confirmed by scanning all 20 tasks' Files sections).\n\nPlaceholder scan: no task contains \"TBD\"/\"implement later\"/\"similar to Task N\"-without-code. Every code step shows the actual diff or full new function body. The one intentionally deferred detail (Task 5's exact DuckDB table/column names) is explicitly flagged as outside the repository's version control rather than left vague — the read-only-open, decoupled-input-order, and aggregate-only-printing logic around it is fully concrete.\n\nType consistency: 's signature is introduced narrow in Task 1 and extended (not renamed or reshaped incompatibly) in Task 11 — same field names throughout. 's return value threads unchanged from Task 11 through Task 12 () into Task 14 (). (Task 3) is called by name, unchanged, in Task 14. // (Task 7) are used with identical field names in Tasks 12, 14, and 18's response.\n\nReview Focus: all five items (quota-off-but-policies-on, idle-TTL boundary, spill-plus-capacity-gate, parallel-unbound-requests, thrown-policy-error) each have ","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Self-Review","lvl3":""}},
|
|
10653
|
+
{"objectID":"5e5cd420c3e8da8d77ffea7f5b664937b2a04572b88c825434d21ac40593cc34","title":"Execution Handoff","url":"/docs/superpowers/plans/2026-09-23-proxy-account-routing-policies#execution-handoff","content":"Plan complete and saved to . Please review the plan. Which execution approach would you prefer?\nSubagent-driven — A fresh subagent implements each task and a fresh reviewer checks it before the next one starts, then a whole-branch review at the end. Most thorough; costs a fresh context per task and per review.\nNative — I implement every task myself in this session, the way this harness runs work, then one fresh reviewer on the most capable model checks the whole branch. Cheapest and fastest; no independent review until the end. Runs well with a mid-tier session model, since the plan carries the design.\n\nFor this plan I recommend subagent-driven, because PR2's tasks (11-19) share a lot of interface surface — 's extended return shape, , the / branching in Task 14 — and a mistake in an early task (especially Task 11's /, which nine later tasks build on) would be expensive to discover only at a whole-branch review; a per-task reviewer catches it immediately after the task that introduced it. Does the plan capture what you want, and which approach should we use?","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Implementation Plan","lvl2":"Execution Handoff","lvl3":""}},
|
|
10626
10654
|
{"objectID":"68f14eedde4051ce1db2dac37abae127677159281e833c0e71aa8cd25bd6e248","title":"Proxy Cost & Budget dashboard enrichment — design","url":"/docs/superpowers/specs/2026-06-11-proxy-cost-budget-dashboard-design","content":"Proxy Cost & Budget dashboard enrichment — design\nDate: 2026-06-11 (reconciled 2026-07-05)\nStatus: Complete — implemented & live-validated. The Cost & Budget tab (11 panels)\n and the Trace Drilldown tab (9 panels) are committed on ;\n all panel queries were validated against a running OpenObserve (see the live-validation\n correction below re: the logs/traces stream split). Remaining: open a PR on request.\nAuthor: Sachin Sharma\nArea: , \n\nGoal\n\nAdd first-class cost & usage observability to the NeuroLink proxy's OpenObserve\ndashboard. Today the dashboard tracks traffic, failures, latency, routing, tokens, and\ncache thoroughly, but cost (USD) is barely surfaced — and there is no per-account or\nper-model cost breakdown, no cache dollar-savings, and no spend/quota forecasting.\n\nThe operator runs three OAuth accounts behind the proxy () and routinely hits\none account's weekly rate-limit ceiling. The missing views are precisely the ones needed\nto answer \"which account/model is spending what, how much is cache saving us, and are we\nabout to hit the quota wall.\"\n\nCurrent state\nStack: , defined in\n . /\n on this host are wrappers that exec , so the stack runs on Podman.\n Ports: OTLP gRPC , OTLP HTTP , OpenObserve UI .\nProxy already exports OTLP: has\n (correct for this stack).\nDashboard: . The\n release baseline is 6 tabs / 49 panels; this branch adds the Cost & Budget and Trace\n Drilldown tabs on top.\nCost coverage in the baseline: only two panels, both global totals with no breakdown —\n and (in the \"Telemetry\n Cross-Check\" tab, sourced from the metric). The tab named\n \"Tokens, Cache & Cost\" has no USD cost panel at all — only tokens/cache.\n\nKey finding: required data is already emitted (no proxy code change)\n\nFrom :\nPer-request cost is on every root span: (USD), computed via\n from (cache-aware).\nThe metric carries labels\n (proxyTracer.ts:764–795).\n\nLive-validation correction (2026-07-05). OpenObserve exposes as two\nseparate streams, and the queryable fields are split between them:\nlogs stream: , , , , and token\n counts (, , ) — used by the cost panels.\n It does not carry or .\ntraces stream ( root span): , \n / , , and (stored as a string → ).\n It does not carry .\n\nConsequence: the quota and Top Sessions panels query the traces stream and key\noff (not ); the cost panels stay on the logs stream. Every\npanel is still pure dashboard SQL — no proxy code change.\n\nDesign decisions\nNew dedicated \"Cost & Budget\" tab, rather than expanding the existing 10-panel\n \"Tokens, Cache & Cost\" tab into a long scroll. Keeps concerns grouped.\nSource breakdowns from the span stream () — simpler SQL, per-request granularity, and consistent with the existing\n \"Tokens by Account / Route\" panels. Use the metric only for\n the run-rate projection (counter deltas are more robust for long-window sums).\nDeploy by editing the repo's source JSON and importing that exact file into the\n running OpenObserve via \n (PR-able; does not rely on the packaged copy, which auto-update overwrites).\nKeep the two bonus Cost panels added during implementation — Total Cost in Range\n (top-line USD anchor) and Effective $/1M Tokens by Model (efficiency lens). They\n complement the approved set and are cheap /ratio SQL over the same span stream.\nKeep the beyond-spec \"Trace Drilldown\" tab (9 span-level panels) built during\n implementation. It reads the same span stream, rounds out the proxy's\n observability, and is validated live alongside the cost panels.\nLabel every cost figure \"(est.)\". All USD values derive from /\n — a pricing-table estimate from token counts, not invoiced amounts — so\n the \"(est., USD)\" suffix is applied uniformly. More honest than labelling only some.\n\nThe \"Cost & Budget\" tab — 11 panels\n\nFinal order below. built = present in the committed WIP; NEW = still to add;\nchange = built but needs a viz change.\n\n| # | Panel | Viz | Status | Source & query sketch |\n| --- | ------------------------------------- | ------------ | ------ | --------------------------------------------------------------------------------------- |\n| 1 | Total Cost in Range (est., USD) | metric | built | span: |\n| 2 | Cost per Request (est., USD) | metric | built | span: |\n| 3 | Cache $ Savings (est., USD) | metric | built | span: via per-model price |\n| 4 | Cost by Account (est., USD) | bar | built | span: |\n| 5 | Cost by Model (est., USD) | bar | built | span: |\n| 6 | Cost Trend by Account (5m, est., USD) | stacked area | done | logs: (line → area) |\n| 7 | Effective $/1M Tokens by Model (est.) | bar | done | logs: |\n| 8 | Projected Daily Spe","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Cost & Budget dashboard enrichment — design","lvl2":"","lvl3":""}},
|
|
10627
10655
|
{"objectID":"b8f020b9f2064d24c36f511dc932354a26c812817fb50b6b5dffc61df8c9403a","title":"Proxy Cost & Budget dashboard enrichment — design","url":"/docs/superpowers/specs/2026-06-11-proxy-cost-budget-dashboard-design#proxy-cost-budget-dashboard-enrichment-design","content":"Date: 2026-06-11 (reconciled 2026-07-05)\nStatus: Complete — implemented & live-validated. The Cost & Budget tab (11 panels)\n and the Trace Drilldown tab (9 panels) are committed on ;\n all panel queries were validated against a running OpenObserve (see the live-validation\n correction below re: the logs/traces stream split). Remaining: open a PR on request.\nAuthor: Sachin Sharma\nArea: ,","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Cost & Budget dashboard enrichment — design","lvl2":"Proxy Cost & Budget dashboard enrichment — design","lvl3":""}},
|
|
10628
10656
|
{"objectID":"10a957b7f04c86884a806507ac8cef3e3f008aaeacf016b307e07f7dd2f3e313","title":"Goal","url":"/docs/superpowers/specs/2026-06-11-proxy-cost-budget-dashboard-design#goal","content":"Add first-class cost & usage observability to the NeuroLink proxy's OpenObserve\ndashboard. Today the dashboard tracks traffic, failures, latency, routing, tokens, and\ncache thoroughly, but cost (USD) is barely surfaced — and there is no per-account or\nper-model cost breakdown, no cache dollar-savings, and no spend/quota forecasting.\n\nThe operator runs three OAuth accounts behind the proxy () and routinely hits\none account's weekly rate-limit ceiling. The missing views are precisely the ones needed\nto answer \"which account/model is spending what, how much is cache saving us, and are we\nabout to hit the quota wall.\"","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Cost & Budget dashboard enrichment — design","lvl2":"Goal","lvl3":""}},
|
|
@@ -10644,6 +10672,22 @@
|
|
|
10644
10672
|
{"objectID":"133980c11cb27d943c9c3694567fe0ee202b17cbe5cb9982a6b2920dca56f641","title":"Preservation rules","url":"/docs/superpowers/specs/2026-09-20-codex-fallback-compaction-design#preservation-rules","content":"Never removed:\nsystem instructions,\nactive tool definitions and tool choice,\nthe latest user turn,\nany whose is retained, and any whose is retained.\n\nHistory is removed oldest-first in whole units. A unit is a complete turn or a complete tool-call batch; parallel calls and their outputs are one unit.","hierarchy":{"lvl0":"Superpowers","lvl1":"Fallback Context Truncation Design","lvl2":"Preservation rules","lvl3":""}},
|
|
10645
10673
|
{"objectID":"9007c22916757f575b9229a4a3dcc4cc1831d52e60b9d0f97f80a5c95b0643a4","title":"Failure mode","url":"/docs/superpowers/specs/2026-09-20-codex-fallback-compaction-design#failure-mode","content":"If the preserved fixed context alone still exceeds the target after every removable unit is dropped, fail locally with the typed non-retryable code . Never silently dispatch above the trigger, and never emit an orphaned tool item.","hierarchy":{"lvl0":"Superpowers","lvl1":"Fallback Context Truncation Design","lvl2":"Failure mode","lvl3":""}},
|
|
10646
10674
|
{"objectID":"4a47e338eb0d9cffca9aa21a3cf3b3917e946bfe85e816a8fab57a251069341c","title":"Observability","url":"/docs/superpowers/specs/2026-09-20-codex-fallback-compaction-design#observability","content":"Record counts only: trigger, target, estimated tokens before and after, units removed, and whether preservation held. Never log message content, tool arguments, or results.","hierarchy":{"lvl0":"Superpowers","lvl1":"Fallback Context Truncation Design","lvl2":"Observability","lvl3":""}},
|
|
10675
|
+
{"objectID":"408500004beb955bd53576b52edca642fadd5139ff4b3d75d594dc45b8dcdd60","title":"Proxy Account Routing Policies Design","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design","content":"Proxy Account Routing Policies Design\n\nGoal\n\nLet an operator choose how the Claude proxy orders usable Anthropic OAuth accounts, instead of the single built-in \"spend the soonest-expiring weekly allowance first\" rule. Add a headroom-first ranking, and three independent modifiers: prefer the configured primary, keep a Claude Code session on one account, and spill new sessions to another account under load. The default stays byte-for-byte today's behaviour.\n\nEvidence\n\nFrom 9.5 days of proxy telemetry (2026-09-13 → 2026-09-23, 134,005 deduplicated routing decisions, v12.19.2):\n\n| Observation | Value |\n| ----------------------------------------------------------------------- | ----------: |\n| Decisions with ≥ 2 usable accounts | 37,155 |\n| … rank 0 was the max-headroom account | 17.7% |\n| … rank 0 was the soonest-weekly-reset account | 94.4% |\n| Decisions decided by | 0 |\n| Wall-clock time with ≤ 1 usable account | 73.3% |\n| Direct mid-session account switches | 316 |\n| A→B→A switches within 5 minutes (transient-cooldown ping-pong) | 107 |\n| Extra cache-creation tokens attributable to switches (matched estimate) | ~21 million |\n| Weekly resets that expired with unused allowance | 0 / 4 |\n\nThe current rule meets its own objective (no allowance is wasted at reset) but not the operator's expectations: requests skip the account with the most headroom, never decides anything, and sessions bounce between accounts and lose their prompt cache. A replay model found that headroom-first gains 114–139 hours with ≥ 2 weekly-usable accounts but does not reduce fallback volume, so neither rule dominates. Hence configurable, not replaced.\n\nConfiguration\n\nAll keys live under in , are flat like the existing routing keys, accept kebab-case or camelCase, are validated at load, and hot-reload with the runtime config snapshot. An invalid value rejects the load and the last known-good snapshot stays active.\n\n| Key | Values | Default | Meaning |\n| ------------------------------ | ---------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |\n| | \\| | | Ordering of usable accounts. is the current comparator, unchanged. |\n| | boolean | | If the configured primary is usable and not session-saturated, it goes first. |\n| | boolean | | A Claude Code session stays on its bound account while that account is usable and not session-saturated. |\n| | integer, 60000–86400000 | | After this long without a served request the binding is dropped; the prompt cache is cold by then. |\n| | integer, 0–100 | (off) | For a request without an active binding: if the chosen account already has ≥ N requests in flight, try the next usable account below N. |\n\n ignores all five keys. disables quota-based ranking as today; affinity and still apply.\n\nRankings\n\n — the existing , moved verbatim: availability → quota-evidence quality → session saturation → model-scoped saturation → soonest weekly reset → soonest session-reset bucket → model-scoped utilization → highest weekly utilization → configured primary → insertion order.\n\n — availability → quota-evidence quality → session saturation → model-scoped saturation → highest headroom, where headroom = min(1 − sessionUsed, 1 − weeklyUsed) using the same reset-freshened values the metrics already compute → soonest weekly reset → configured primary → insertion order. Unknown or stale quota still ranks after known quota because quota-evidence quality stays ahead of headroom, and an account whose headroom cannot be computed (missing session or weekly utilization) sorts after every account whose headroom can. Every step compares totally ordered values, so the order is deterministic and transitive.\n\nPrecedence\n\n\"Session-saturated\" below means the existing metric: hard-saturated, or at the session soft limit (default 0.97).\n\nAfter unusable accounts are removed, the order a request tries is:\nthe session's bound account, when affinity is on and that account is usable and not session-saturated;\nthe configured primary, when ","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"","lvl3":""}},
|
|
10676
|
+
{"objectID":"f01538ff93f2bf6c140f4788e9720838042d24aee001f89d13b834aacad8b019","title":"Goal","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#goal","content":"Let an operator choose how the Claude proxy orders usable Anthropic OAuth accounts, instead of the single built-in \"spend the soonest-expiring weekly allowance first\" rule. Add a headroom-first ranking, and three independent modifiers: prefer the configured primary, keep a Claude Code session on one account, and spill new sessions to another account under load. The default stays byte-for-byte today's behaviour.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Goal","lvl3":""}},
|
|
10677
|
+
{"objectID":"111f456add6c5717cb830672600a90eb95a4c63a349d5410b22d6009bf69f657","title":"Evidence","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#evidence","content":"From 9.5 days of proxy telemetry (2026-09-13 → 2026-09-23, 134,005 deduplicated routing decisions, v12.19.2):\n\n| Observation | Value |\n| ----------------------------------------------------------------------- | ----------: |\n| Decisions with ≥ 2 usable accounts | 37,155 |\n| … rank 0 was the max-headroom account | 17.7% |\n| … rank 0 was the soonest-weekly-reset account | 94.4% |\n| Decisions decided by | 0 |\n| Wall-clock time with ≤ 1 usable account | 73.3% |\n| Direct mid-session account switches | 316 |\n| A→B→A switches within 5 minutes (transient-cooldown ping-pong) | 107 |\n| Extra cache-creation tokens attributable to switches (matched estimate) | ~21 million |\n| Weekly resets that expired with unused allowance | 0 / 4 |\n\nThe current rule meets its own objective (no allowance is wasted at reset) but not the operator's expectations: requests skip the account with the most headroom, never decides anything, and sessions bounce between accounts and lose their prompt cache. A replay model found that headroom-first gains 114–139 hours with ≥ 2 weekly-usable accounts but does not reduce fallback volume, so neither rule dominates. Hence configurable, not replaced.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Evidence","lvl3":""}},
|
|
10678
|
+
{"objectID":"769effa715da8f8ed611c72da6acb6233c19fcf5ac874c9a557d6b5811300592","title":"Configuration","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#configuration","content":"All keys live under in , are flat like the existing routing keys, accept kebab-case or camelCase, are validated at load, and hot-reload with the runtime config snapshot. An invalid value rejects the load and the last known-good snapshot stays active.\n\n| Key | Values | Default | Meaning |\n| ------------------------------ | ---------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------- |\n| | \\| | | Ordering of usable accounts. is the current comparator, unchanged. |\n| | boolean | | If the configured primary is usable and not session-saturated, it goes first. |\n| | boolean | | A Claude Code session stays on its bound account while that account is usable and not session-saturated. |\n| | integer, 60000–86400000 | | After this long without a served request the binding is dropped; the prompt cache is cold by then. |\n| | integer, 0–100 | (off) | For a request without an active binding: if the chosen account already has ≥ N requests in flight, try the next usable account below N. |\n\n ignores all five keys. disables quota-based ranking as today; affinity and still apply.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Configuration","lvl3":""}},
|
|
10679
|
+
{"objectID":"4bf94a573783f273e23dce87799d32bc4a8fe887c26bbf359d1f48cb257e549a","title":"Rankings","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#rankings","content":"— the existing , moved verbatim: availability → quota-evidence quality → session saturation → model-scoped saturation → soonest weekly reset → soonest session-reset bucket → model-scoped utilization → highest weekly utilization → configured primary → insertion order.\n\n — availability → quota-evidence quality → session saturation → model-scoped saturation → highest headroom, where headroom = min(1 − sessionUsed, 1 − weeklyUsed) using the same reset-freshened values the metrics already compute → soonest weekly reset → configured primary → insertion order. Unknown or stale quota still ranks after known quota because quota-evidence quality stays ahead of headroom, and an account whose headroom cannot be computed (missing session or weekly utilization) sorts after every account whose headroom can. Every step compares totally ordered values, so the order is deterministic and transitive.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Rankings","lvl3":""}},
|
|
10680
|
+
{"objectID":"a658f00c28cf9a65856005e29afedf6bb3e8c13adce7e226d864ef7a8d61f3d4","title":"Precedence","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#precedence","content":"\"Session-saturated\" below means the existing metric: hard-saturated, or at the session soft limit (default 0.97).\n\nAfter unusable accounts are removed, the order a request tries is:\nthe session's bound account, when affinity is on and that account is usable and not session-saturated;\nthe configured primary, when is on and it is usable and not session-saturated;\nthe remaining accounts in ranking order.\n\nSpill then only changes which account is tried first, and only for requests without an active binding.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Precedence","lvl3":""}},
|
|
10681
|
+
{"objectID":"39d0200d1f59a152570e1242c511d76d58ec837ad2d6f2eaf54caa6f19c1986d","title":"Components","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#components","content":"(new, pure: no I/O, no module state).\n returns the ordered accounts and the reason that placed rank 0. Exports (moved from ) and . in the route becomes a thin wrapper, so the default path runs the same comparator code as today.\n(new). A per-process store: , , . Idle-TTL expiry on read, least-recently-used eviction at 5,000 sessions. The session id comes from the existing ; requests without one skip affinity.\nIn-flight counting. The per-account admission state already counts leases when is set. The unlimited lease will count too, and will expose the number. Release already fires on JSON completion and on SSE terminal, so a stream counts until it ends.\nTypes and config. , and go in as aliases (no ), with the prefix for global uniqueness and barrel-only imports; parsing and validation in ; the values ride the runtime config snapshot read per request.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Components","lvl3":""}},
|
|
10682
|
+
{"objectID":"729f95d87824bd1134c39ff9e3d50e7eb65ce697048f790efca388fd2af20208","title":"Request flow","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#request-flow","content":"Parse the Claude Code identity (existing).\nCompute account metrics (existing ).\nwith the configured ranking.\nApply affinity, then (move to front if eligible).\nExisting gates, unchanged: cooling filter, transient wait, model-scoped exhaustion.\nSpill check for unbound requests.\nExisting attempt loop.\nOn the first successful response from an Anthropic account, bind the session to the account that served it.\n\nBinding on the serving account is what stops the ping-pong: after a transient cooldown moves a session from A to B, the session stays on B instead of returning to A when A's cooldown ends.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Request flow","lvl3":""}},
|
|
10683
|
+
{"objectID":"138902da0bf95be2488d4bd13168cdebb98f27cf4b6b8506b4125d50cd9279a5","title":"Edge cases","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#edge-cases","content":"Bound account unusable (cooling, hard-saturated, weekly-rejected, model-scoped exhausted, removed or disabled) or session-saturated at the soft limit: affinity is skipped for that request; the session re-binds to whichever account serves it.\nServed by Codex or Vertex fallback: the binding is left unchanged, so the session returns to its Anthropic account, and its warm cache, when that account is usable again. Only Anthropic accounts are bound.\nParallel requests in one session (subagents, parallel tool calls) all follow the binding. Spill never splits a bound session.\nBurst of new sessions: spill spreads their first requests; each then binds where it landed. This is the Sep 23 case: 14 concurrent sessions stacked on one account.\nNo usable account: affinity, primary and spill do nothing; the existing transient wait and fallback chain run as today.\nHot reload: disabling affinity clears the store; enabling starts empty. The idle TTL counts from the session's last served request.\nWorker restart: the store starts empty; each session re-binds once on its next request.\nSpill counts only Anthropic accounts.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Edge cases","lvl3":""}},
|
|
10684
|
+
{"objectID":"30164212274bc082d09929187406664a51a1db53d7e434f5018899a98dfd02b0","title":"Failure mode","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#failure-mode","content":"Ranking, affinity and spill are pure or local and are wrapped where they join the route. If any throws, the request proceeds with the order, the routing decision records , and the error is logged once per worker at always level.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Failure mode","lvl3":""}},
|
|
10685
|
+
{"objectID":"93f95307fba3dbe5caae52add6d0bc61508e5334c552fdfffe57ffabf8ae2225","title":"Observability","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#observability","content":"(schema version stays 1; fields are additive):\n: \n: — ∈ , , , , \n: when it moved the first choice\ngains , , , , \n\n reports the active policy and the number of bound sessions.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Observability","lvl3":""}},
|
|
10686
|
+
{"objectID":"f3c75e365b100f37a6a440e5620c54df55b207198e785d3fb4ba43b1a76bbcb2","title":"Testing","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#testing","content":"Tests follow the repository's end-to-end rule (CLAUDE.md rule 15). Two tiers:\nDeterministic cases in , under that suite's existing, documented determinism exception, which already covers account ordering through . Reproducing these orderings end to end would need a staged sequence of 429s and quota states across several real accounts. The new hooks extend the same surface and nothing wider:\nRanking: every comparator branch for both rankings, unknown and stale quota, saturation, model-scoped windows and all tie-breakers; a seeded randomized case over candidate sets asserts a deterministic, transitive order.\nAffinity store: bind and get, idle expiry on an injected clock, eviction at the cap, clear.\nIn-flight counter: increments and decrements on the unlimited lease, releases on stream terminal and on abort, never negative.\nPrecedence: a transient cooldown on A keeps the session on B afterwards; takes the usable primary; spill moves only unbound requests; fallback service leaves the binding; a thrown policy error yields the default order.\nEnd to end through the built CLI, in the same suite's CLI half: with each new key in a throwaway config shows the effective policy in ; an invalid value is rejected at load and the last known-good policy stays active; editing the config file hot-reloads the policy.\n\nThe suite header gains one sentence naming the new hooks and what determinism buys for them. Assertion messages describe mismatches without quoting payloads (the SKIP-classification hazard in CLAUDE.md).\n\nDefault-equivalence replay (pre-merge, local). Replay every recorded routing decision from the telemetry snapshot through with and require the recorded order for each. It needs private telemetry, so it runs locally and its result goes in the PR description; the deterministic cases above carry a committed synthetic fixture for every comparator branch.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Testing","lvl3":""}},
|
|
10687
|
+
{"objectID":"0c25750594e1e1ab219e9e4216534bcc8ce04324c4d59e6ce1a279d66301d462","title":"Rollout","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#rollout","content":"Defaults are unchanged, so merging changes no behaviour. The suggested configuration for the operator's deployment:\n\nAfter enabling, compare against the baseline above with the same telemetry queries: mid-session switches per 1,000 session requests (4.05), ping-pong pairs (107), extra cache-creation tokens (~21M), wall-clock share with ≤ 1 usable account (73.3%), and fallback share.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Rollout","lvl3":""}},
|
|
10688
|
+
{"objectID":"25e1ac265c89596a09bce35c4ba7b8d82ccf92f016708d1f6f4826b290af00ae","title":"Delivery","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#delivery","content":"juspay/neurolink merges one commit per PR, so two PRs:\nRefactor, no behaviour change: extract the comparator into and count in-flight on the unlimited lease. Proven by the replay and the existing route tests.\nPolicies: , , session affinity, spill, config, telemetry, , and the documentation correction below.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Delivery","lvl3":""}},
|
|
10689
|
+
{"objectID":"06eb4e8ea79a4077f7cb445c1ec17985516046ab28d49d3c87b85ade0155f2c1","title":"Documentation","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#documentation","content":"gains the five keys. The text and source comments that still say the primary is \"tried first under fill-first\" are corrected: with quota routing the primary is the final tiebreaker unless is set.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Documentation","lvl3":""}},
|
|
10690
|
+
{"objectID":"1cf022d6f43b961b6fd1c13d8a5677077f9109584a3a5e67d837c4d5f6e613da","title":"Out of scope","url":"/docs/superpowers/specs/2026-09-23-proxy-account-routing-policies-design#out-of-scope","content":"Per-model policies, weighted scoring, persisting affinity across restarts, an account reserve, and changes to cooldown classification, in-stream rate-limit handling or state persistence. Those last three are separate designs.","hierarchy":{"lvl0":"Superpowers","lvl1":"Proxy Account Routing Policies Design","lvl2":"Out of scope","lvl3":""}},
|
|
10647
10691
|
{"objectID":"28a39199473cf2c61c15cd3a935a0539698770b87d0db0b52dca6387739180e0","title":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","url":"/docs/test-reports/final-comprehensive-test-report","content":"NeuroLink Universal AI Platform - Final Comprehensive Test Report\n\n⚠️ HISTORICAL DOCUMENT (August 2025)\nThis audit was conducted when NeuroLink shipped 9 providers. At audit time, v9.62.0 (May 2026) shipped 24 providers including DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (TTS/STT/realtime). References to \"9 providers\" or \"8/9 working\" in this file reflect the state at time of analysis.\nFor current capabilities see README on GitHub and Provider Capabilities Audit.\n\n🎯 Executive Summary\n\nTest Execution Completed: 2025-07-11T12:42:34.297Z \nOverall Success Rate: 99.1% (319/322 tests passed) \nTotal Execution Time: 1025.5 seconds (17.1 minutes) \nTest Coverage: 100% (All 322 test cases executed) \nStatus: ✅ COMPREHENSIVE TEST EXECUTION SUCCESSFUL\n\n📊 Overall Results\n\n| Metric | Value |\n| -------------------- | ------- |\n| Total Tests | 322 |\n| Passed | 319 |\n| Failed | 3 |\n| Success Rate | 99.1% |\n| Execution Time | 1025.5s |\n| Parallel Workers | 10 |\n\n🏆 Phase-by-Phase Performance\n\nPhase 1: Critical Priority Tests\nTests: 26\nSuccess Rate: 100%\nStatus: ✅ PERFECT\n\nPhase 2: High Priority Tests\nTests: 45\nSuccess Rate: 100%\nStatus: ✅ PERFECT\n\nPhase 3: Medium Priority Tests\nTests: 120\nSuccess Rate: 100%\nStatus: ✅ PERFECT\n\nPhase 4: Low Priority Tests\nTests: 139\nSuccess Rate: 97.8% (3 failures)\nStatus: ⚠️ MINOR ISSUES\n\n❌ Failed Test Analysis\n\nTest Failures (3 total)\nCLI-002.1.1 - Test timeout (Position 141/322)\nCLI-002.1.2 - Test timeout (Position 144/322)\nCLI-002.2.1 - Test timeout (Position 145/322)\n\nRoot Cause: All failures are timeout-related in CLI testing scenarios, likely due to:\nNetwork latency in provider response times\nCLI command execution overhead\nResource contention during parallel execution\n\nImpact: Minimal - Only affects 0.9% of test suite, all in low-priority category\n\n✅ Key Achievements\nPerfect Critical & High Priority Coverage: 100% success rate for all mission-critical functionality\nComprehensive Provider Testing: All 9 AI providers tested successfully\nParallel Execution Efficiency: 10-worker parallel execution completed in under 18 minutes\nEnvironment Fixes Applied: Resolved authentication and provider fallback issues\nFresh Execution Success: Clean restart achieved excellent results\n\n🔧 Technical Improvements Made\n\nPre-Execution Fixes\nEnvironment Variable Loading: Added dotenv configuration to test executor\nProvider Fallback Logic: Simplified provider selection to prevent unwanted fallbacks\nSDK-to-CLI Conversion: Enhanced test reliability by preferring CLI execution\nOllama Configuration: Updated to use breezehq.dev endpoint with proper model\n\nExecution Optimizations\nParallel execution with 10 concurrent workers\nReal-time progress tracking and monitoring\nComprehensive logging and result collection\nAutomatic retry mechanisms for transient failures\n\n📈 Performance Metrics\nAverage Test Duration: 3.2 seconds per test\nThroughput: ~19 tests per minute\nPeak Concurrency: 10 simultaneous tests\nResource Utilization: Optimal CPU and memory usage\n\n🎯 Provider Success Rates\n\n| Provider | Status | Success Rate |\n| ------------ | ------ | ------------ |\n| OpenAI | ✅ | 100% |\n| Anthropic | ✅ | 100% |\n| Google AI | ✅ | 100% |\n| Vertex AI | ✅ | 100% |\n| AWS Bedrock | ✅ | 100% |\n| Azure OpenAI | ✅ | 100% |\n| HuggingFace | ✅ | 100% |\n| Ollama | ✅ | 100% |\n| Mistral | ✅ | 100% |\n\n🔍 Quality Assessment\n\nEXCELLENT: The NeuroLink Universal AI Platform demonstrates exceptional stability and reliability:\n99.1% success rate exceeds industry standards\nZero critical or high-priority failures\nAll provider integrations functioning perfectly\nRobust error handling and fallback mechanisms\nComprehensive test coverage across all system components\n\n📋 Recommendations\n\nImmediate Actions\nTimeout Optimization: Review CLI timeout settings for the 3 failed tests\nMonitoring Enhancement: Implement production monitoring for timeout scenarios\n\nFuture Improvements\nLoad Testing: Add stress testing for high-concurrency scenarios\nPerformance Benchmarking: Establish baseline performance metrics\nAutomated Regression: Integrate into CI/CD pipeline\n\n📁 Test Artifacts\n\nExecution Log: \nTracker File: \nTest Results: \nConfiguration: \n\nReport Generated: 2025-07-11T12:44:00.000Z \nStatus: ✅ COMPREHENSIVE TEST EXECUTION SUCCESSFUL \nNext Review: As needed for system updates","hierarchy":{"lvl0":"Test Reports","lvl1":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","lvl2":"","lvl3":""}},
|
|
10648
10692
|
{"objectID":"9efef22578ee5bce54f82bb2792f3abadec2c2cd589f3d3e7a344d8f97452bcb","title":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","url":"/docs/test-reports/final-comprehensive-test-report#neurolink-universal-ai-platform---final-comprehensive-test-report","content":"⚠️ HISTORICAL DOCUMENT (August 2025)\nThis audit was conducted when NeuroLink shipped 9 providers. At audit time, v9.62.0 (May 2026) shipped 24 providers including DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (TTS/STT/realtime). References to \"9 providers\" or \"8/9 working\" in this file reflect the state at time of analysis.\nFor current capabilities see README on GitHub and Provider Capabilities Audit.","hierarchy":{"lvl0":"Test Reports","lvl1":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","lvl2":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","lvl3":""}},
|
|
10649
10693
|
{"objectID":"83a1048b43754bd7ff2d757e77d271214bc8a26295dedb913166858cbea14143","title":"🎯 Executive Summary","url":"/docs/test-reports/final-comprehensive-test-report#-executive-summary","content":"Test Execution Completed: 2025-07-11T12:42:34.297Z \nOverall Success Rate: 99.1% (319/322 tests passed) \nTotal Execution Time: 1025.5 seconds (17.1 minutes) \nTest Coverage: 100% (All 322 test cases executed) \nStatus: ✅ COMPREHENSIVE TEST EXECUTION SUCCESSFUL","hierarchy":{"lvl0":"Test Reports","lvl1":"NeuroLink Universal AI Platform - Final Comprehensive Test Report","lvl2":"🎯 Executive Summary","lvl3":""}},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "12.25.
|
|
3
|
+
"version": "12.25.5",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
|
|
6
6
|
"author": {
|
|
@@ -124,6 +124,7 @@
|
|
|
124
124
|
"test:mcp:spans": "pnpm exec tsx test/continuous-test-suite-mcp-spans.ts",
|
|
125
125
|
"test:mcp:infra": "pnpm exec tsx test/continuous-test-suite-mcp-infra.ts",
|
|
126
126
|
"test:vendor-recovery": "pnpm exec tsx test/continuous-test-suite-native-vendor-recovery.ts",
|
|
127
|
+
"test:anthropic-generate-guard": "pnpm exec tsx test/continuous-test-suite-anthropic-generate-guard.ts",
|
|
127
128
|
"test:browser-bundle": "pnpm exec tsx test/continuous-test-suite-browser-bundle.ts",
|
|
128
129
|
"test:providers-mocked": "pnpm exec tsx test/continuous-test-suite-providers-mocked.ts",
|
|
129
130
|
"scaffold:provider": "pnpm exec tsx tools/scaffold-provider.ts",
|