refactor(db,api): collapse usage policy to a single source of truth#39
Conversation
mvpUsagePolicy in @agent-paste/contracts is now the only definition of the MVP usage policy. packages/db/src/policy.ts re-exports it as USAGE_POLICY and derives DEFAULT_UPLOAD_SESSION_TTL_MS and MAX_ARTIFACT_BYTES from its fields, so RepositoryCore.getWhoami and every db consumer pick up canonical values. apps/api drops its local usagePolicy literal and reads mvpUsagePolicy for /v1/usage-policy, the denylist TTL, and the upload TTL default. This removes the stale workspace_burst_cap_per_minute of 600 that /v1/whoami served while /v1/usage-policy served the canonical 300 (ADR 0038). A regression test asserts both endpoints return the canonical policy and match each other. @agent-paste/db gains a workspace:* dependency on @agent-paste/contracts; no cycle results because contracts is a leaf. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
WalkthroughThis PR consolidates scattered usage policy definitions into a single canonical source. The change establishes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
|
agent-paste PR preview is ready. API: https://agent-paste-api-pr-39.isaac-a46.workers.dev |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
agent-paste PR preview resources were cleaned up. The pr-preview-${context.issue.number} environment is left in place; remove it from the GitHub UI if desired. |
Summary
The MVP usage policy (artifact/file caps, TTLs, rate limits, burst cap) was defined in three places that had drifted.
packages/dbserved a staleworkspace_burst_cap_per_minuteof 600 on/v1/whoamiwhileapps/apiserved the canonical 300 on/v1/usage-policy. This collapses the policy to one source of truth:mvpUsagePolicyin@agent-paste/contracts(per ADR 0038).packages/db/src/policy.tsstops defining policy values inline. It re-exportsmvpUsagePolicyasUSAGE_POLICY(name preserved for existing consumers and thepackages/dbre-exports) and derivesDEFAULT_UPLOAD_SESSION_TTL_MSandMAX_ARTIFACT_BYTESfrom its fields. Values and types are unchanged.apps/api/src/index.tsdeletes its localusagePolicyliteral and readsmvpUsagePolicyfor the/v1/usage-policyresponse, the denylist expiration TTL, and the upload TTL default.@agent-paste/dbgains aworkspace:*dependency on@agent-paste/contracts. No dependency cycle:@agent-paste/contractsis a leaf (deps arezodand@asteasolutions/zod-to-openapi).RepositoryCore.getWhoamiand/v1/usage-policynow serve the identical canonical policy./v1/whoamiburst cap goes 600 to 300.Canonical burst cap of 300 confirmed against ADR 0038 (Zod contracts are the source of truth) and ADR 0066 (which narrows the MVP usage policy and reaffirms ADR 0038); the value lives in the canonical
mvpUsagePolicyboth ADRs point to.Note on stacking
Based on
worktree-agent-aab8c64f64ee8da40(PR #38), which is not yet merged. Do not retarget tomainuntil #38 merges.Test plan
apps/api/src/local-mvp.test.tsthat wires the realLocalRepositorythrough the worker and asserts/v1/whoamiand/v1/usage-policyboth returnmvpUsagePolicyand match each other. Verified it fails whenpackages/dbis forced to diverge (whoami 600 vs usage-policy 300) and passes after the fix.pnpm verifygreen: 62 successful / 62 total Turbo tasks;apps/apisuite is 38 tests across 4 files.@agent-paste/contractsdoes not depend on@agent-paste/db(acyclic).🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests