Repository navigation
Make AI work again on hosted Void Cloud: publish AI logging policy to KV - #814
Brooooooklyn wants to merge 7 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25db0c80ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Since 1.8.0 the proxy asked the API for each project's AI logging policy on every AI call, and the API refused unless PLATFORM_AUTH_DATABASE_UNCACHED was set. Hosted Void Cloud never sets it, so every hosted AI call failed with 503 ai_logging_policy_unavailable. Now the API and the installer write the policy to ROUTING KV key `ai-logging:<projectId>`, and the proxy reads it from there. Shared (`@void/platform/ai-logging`) - Key names, value and metadata shape, parsers, resolver and the 30 s read cache time, used by the API, the installer and the proxy. Proxy - Reads the key (cacheTtl 30) in /ai/run, /ai/provider and /ai/toMarkdown, after body validation. Missing key: inherit (no logging option, as in 1.7.0). off / metadata / full: the 1.8.0 gateway mapping. KV error: 503 ai_logging_policy_unavailable. Bad value: 503 ai_logging_policy_invalid. Caller-supplied logging keys are still stripped. - Adds a manual live-check script for the two Cloudflare behaviours the mapping depends on. API - publishProjectAiLogging locks the project row, reads every input through a write statement (cached Hyperdrive reads never feed a publish), and writes KV before the lock is released. - The operator POST orders the write by direction: a tighten writes in the same transaction; a loosen or inherit commits first and publishes in a second locked step. Errors: ai_logging_publish_failed / _pending. - Plan defaults in platform_settings 'plans:ai-logging', published in pages of 100. A user plan change publishes one page per call; transfer, create and delete keep the key in step. - Readback returns saved, plan, effective, source, published and a state: applied, pending, pending_plan_publish, drift or unknown. - An hourly sweep repairs drifted keys within a 400 KV operation budget. - The internal route 1.8.x proxies call is kept and answers from KV. Installer and CLI - Every install, upgrade and repair copies each project's setting from Postgres to KV, before and after the Worker upload, under the same row locks as the API. - `void platform project ai-logging` and `project show` print the source, effective mode and state; plan files accept `aiLogging`. Docs - CLI reference, admin guides, upgrade note, design doc 0094, operations notes for the hosted rollout. Refs #793. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25db0c8 to
b917a38
Compare
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://ai-logging-proxy-kv-void-cloud.voidzero-docs.workers.dev (commit a34adb6)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
The PR's tests checked many rules at several layers. Each rule is now tested where it lives (shared parser, API state and plan-edit units, CLI output, proxy mapping), and higher layers check only the wiring once. - Shared helpers for the API integration tests (operator calls, KV cleanup, failing or recording KV writes, the no-cacheable-read check) replace up to seven copies of each. - Removed integration tests that repeat unit-tested rules: plan edit rules, readback state variants, publish order rows, the key name, and the CLI JSON, help and plan-file mode checks that the generic tests and shared parser cover. - Merged tests that ran the same path: ownership transfer, project create, the 1.8.x route, the default-plan lookup, the sweep's drift and plan-page cases, the 429 retries. - Proxy tables keep one case per behaviour; the e2e test keeps the CLI -> API -> KV -> proxy path and drops output checks unit tested elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kept route is still exercised by operator-tenants and platform-access-protection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live checks A and B stay in design doc 0094 as manual checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb29702b3c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Removing a plan while its AI logging publish was unfinished kept the removed plan ID in the merged run. Its accounts had moved to the replacement, so later pages found nothing and reported the publish complete, leaving the rest of those projects on their old setting until the hourly sweep. This happened when both plans share a default, since the removal then changes no account's mode. The fold now maps the removed plan to its replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b5c2b8612
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…lish A running plan publish that covered unknown plans lost the accounts on a plan ID once that ID was added to the catalog: they no longer count as unknown, and the add changes no mode when the new plan copies the default. Later pages reported completion while those projects kept their old setting until the hourly sweep. The fold now adds plans new to the catalog when the unfinished run covered unknown plans, next to mapping a removed plan to its replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 1.8.0 the proxy asked the API for each project's AI logging policy
on every AI call, and the API refused unless PLATFORM_AUTH_DATABASE_UNCACHED
was set. Hosted Void Cloud never sets it, so every hosted AI call failed
with 503 ai_logging_policy_unavailable.
Now the API and the installer write the policy to ROUTING KV key
ai-logging:<projectId>, and the proxy reads it from there.How AI logging works
The setting. Each project gets one AI Gateway logging mode:
inheritoffmetadatafullWhich mode wins: the project's own setting, then its plan's default, then the gateway. An account on a plan that isn't in the catalog uses the default plan's setting.
Data flow
The proxy no longer calls the API. That call was the 503 that broke AI on hosted Void Cloud.
Who writes the key
full→off): one transaction, rolled back if KV fails. Looser change orinherit: saved first, then published.plans synccontinues, and the CLI keeps syncing until done.Timing
KV reads are cached for 30 s at each Cloudflare location, so a change can take a short while to reach every location. After a change, the CLI prints "expected by HH:MM:SS (normally within 2 minutes)".
Readback
void platform project showandproject ai-loggingreport a state:When something fails, the proxy refuses instead of guessing
503 ai_logging_policy_unavailable, withRetry-After503 ai_logging_policy_invalid(the value itself is never logged)ai_logging_publish_failed(nothing changed) orai_logging_publish_pending(saved, KV catches up)Older proxies
Proxies still on 1.8.x keep calling
GET /internal/ai-logging/:id. That route still exists and now answers from the same KV key, so they work during the upgrade.Changes
Shared (
@void/platform/ai-logging)read cache time, used by the API, the installer and the proxy.
Proxy
after body validation. Missing key: inherit (no logging option, as in
1.7.0). off / metadata / full: the 1.8.0 gateway mapping. KV error:
503 ai_logging_policy_unavailable. Bad value: 503
ai_logging_policy_invalid. Caller-supplied logging keys are still
stripped.
API
a write statement (cached Hyperdrive reads never feed a publish), and
writes KV before the lock is released.
same transaction; a loosen or inherit commits first and publishes in a
second locked step. Errors: ai_logging_publish_failed / _pending.
pages of 100. A user plan change publishes one page per call; transfer,
create and delete keep the key in step.
change: a removed plan's scope moves to its replacement, and a run that
covered unknown plans also covers plans added to the catalog.
applied, pending, pending_plan_publish, drift or unknown.
Installer and CLI
Postgres to KV, before and after the Worker upload, under the same row
locks as the API.
void platform project ai-loggingandproject showprint the source,effective mode and state; plan files accept
aiLogging.Docs
notes for the hosted rollout.
Refs #793.
Replaces the stack #814–#817 (now one PR, so the proxy switch and the KV writers land together).
Verification
vp test run) before the test cleanup: 804 files, 17,022 tests passed, 35 skipped. After it:vp run check,vp lint, the touched test files, and CI.VOID_TEST_DATABASE_URL) run in CI.packages/md/test/integration/theme-layout.test.tsalso fails onmain(from fix(md): render task lists and support right-to-left pages #811); fixed in fix(md): keep the heading anchor clear of the heading text in every font #819. Merge fix(md): keep the heading anchor clear of the heading text in every font #819 first, then update this branch frommain.🤖 Generated with Claude Code