Skip to content

Scope quota windows by producer instance - #1583

Merged
jaywedgeworth22 merged 12 commits into
mainfrom
codex/codecaps-machine-provenance
Oct 6, 2026
Merged

jaywedgeworth22 merged 12 commits into
mainfrom
codex/codecaps-machine-provenance

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Scope quota windows by the optional producer instance ID so identical provider buckets or models reported by different machines remain separate.
  • Retain the newest reading independently for each producer/series combination.
  • Expose producerInstanceId and an optional human-readable machine label when supplied.
  • Preserve historical IDs and behavior for unattributed quota events while introducing collision-safe identifiers for producer-attributed windows.
  • Add regression coverage for multi-machine separation, newest-reading selection, identifier encoding, legacy ID collisions, and backward compatibility.
  • Record the work in the effort log. No ingestion or authentication behavior changes.

Open Review Findings

  • The effort-log entry still needs a link to the actual GitHub issue and must be mirrored in the external trading effort ledger.
  • A logical bucket can be returned twice when one collector supplies _producerInstanceId and another does not.
  • Producer-attributed window IDs can change between responses when an unrelated legacy bucket ID causes the collision fallback to be used.
  • The existing 400-row fetch budget is shared across machines and can omit windows for some producer instances.
  • skipModelTypes is aggregated across all machines, so a stale or exhausted Antigravity window on one machine can suppress that model fleet-wide.

Closes #1594

Copy link
Copy Markdown
Collaborator Author

@kody start-review

@kody-ai

This comment has been minimized.

Comment thread docs/EFFORT-LOG.md Outdated
Comment thread docs/EFFORT-LOG.md Outdated
Comment thread src/lib/quota-windows.ts
Comment thread src/lib/quota-windows.ts Outdated
Comment thread src/lib/quota-windows.ts
Comment thread src/lib/quota-windows.ts
kody-ai[bot]
kody-ai Bot previously requested changes Oct 4, 2026

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found critical issues please review the requested changes

jaywedgeworth22 pushed a commit that referenced this pull request Oct 4, 2026
@kody-ai

This comment has been minimized.

@kody-ai

This comment has been minimized.

@jaywedgeworth22
jaywedgeworth22 force-pushed the codex/codecaps-machine-provenance branch from 9cb9b19 to 777091b Compare October 5, 2026 02:22
@kody-ai

This comment has been minimized.

@kody-ai

This comment has been minimized.

@jaywedgeworth22

Copy link
Copy Markdown
Collaborator Author

@kody start-review

@kody-ai

This comment has been minimized.

@kody-ai

kody-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Use two literal spaces after the period in the PR description, or the required   form when the renderer would collapse the gap.

Kody rule violation: Use two spaces between sentences in every human-facing string and agent-written paragraph

@kody-ai

kody-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

kody code-review Business Logic medium

❌ Error processing validation

An error occurred while processing the system response. Please try again.

Details

  • Analyzer execution failed: Timeout after 120000ms in business-rules-analyzer-attempt-1

💡 This validation runs automatically only on the first review of a pull request. To run it again, comment @kody -v business-logic.

Comment thread docs/EFFORT-LOG.md Outdated
Comment thread docs/EFFORT-LOG.md Outdated
Comment thread src/app/api/quota-windows/route.ts Outdated
Comment thread src/lib/quota-windows.ts Outdated
Comment thread src/lib/quota-windows.ts Outdated
Load latest quota rows with a SQL window partition instead of take 2000.
Only drop unattributed windows when a fresher attributed reading exists
(provider-scoped). Enforce legacy/producer id collisions with suffix re-key.

Co-authored-by: Jay Wedgeworth <jaywedgeworth22@users.noreply.github.com>
@kody-ai

This comment has been minimized.

@kody-ai

kody-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Public API coverage gap: loadLatestQuotaWindowEvents has Vitest coverage, but src/index.ts does not re-export it and its test imports the implementation module directly. Re-export it from src/index.ts and have the test import it from that public surface so consumers and tests exercise the same API.

Kody rule violation: Every exported schema or utility ships with tests and must typecheck

@kody-ai

kody-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

kody code-review Kody Rules medium

Renderer-unsafe sentence spacing in the PR description prevents the required two-sentence spacing from surviving rendering. Separate the two sentences with the renderer-safe &nbsp; sequence.

Kody rule violation: Use two spaces between sentences in every human-facing string and agent-written paragraph

Keep this PR's machine-provenance effort-log row and take main's
2026-10-05 entries.  Auto-merged muse into the quota-windows provider
grouping test.
Bare catch {} swallowed $queryRaw errors and dropped to the 400-row
findMany with no log.  Capture the exception in Sentry (guarded so
observability never blocks the fallback) and console.error the same
failure.
@jaywedgeworth22
jaywedgeworth22 enabled auto-merge (squash) October 6, 2026 07:54
cursoragent and others added 2 commits October 6, 2026 07:55
Co-authored-by: Jay Wedgeworth <jaywedgeworth22@users.noreply.github.com>
Co-authored-by: Jay Wedgeworth <jaywedgeworth22@users.noreply.github.com>
@jaywedgeworth22
jaywedgeworth22 dismissed kody-ai[bot]’s stale review October 6, 2026 07:56

Superseded: code findings addressed in b51655d/a626679 (Kody verified on threads); effort-log AGENT-SYNC linkage in e42a408; worktree path deferred with documented rationale. CI green on tip e42a408.

@kody-ai

This comment has been minimized.

Comment thread docs/EFFORT-LOG.md
Comment thread docs/EFFORT-LOG.md
Comment thread docs/EFFORT-LOG.md
Loader returns quota events newest-first; reserving legacy ids in a
separate pass keeps attributed collision re-keys correct regardless of
input order.  Regression test now covers both orderings.

Co-authored-by: Jay Wedgeworth <jaywedgeworth22@users.noreply.github.com>
@kody-ai

kody-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Rate limit reached on the provider (openai_compatible). Try again in a few minutes.

openai_compatible · MiniMax-M3.1-Flash-Preview · HTTP 429 · generalist

Provider said: Token Plan rate limit reached: Upgrade your Token Plan or switch to pay-as-you-go API usage. (2062)

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@jaywedgeworth22
jaywedgeworth22 merged commit 29af702 into main Oct 6, 2026
10 of 11 checks passed
@jaywedgeworth22
jaywedgeworth22 deleted the codex/codecaps-machine-provenance branch October 6, 2026 08:05
},
}));

vi.mock("@sentry/nextjs", () => ({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Kody Rules critical

The vi.mock call for @sentry/nextjs adds Sentry to the test module graph, violating Rule 94’s requirement that Datadog remain the sole observability backend. Refactor the loader and test to use and mock the project’s Datadog-backed observability abstraction instead.

Also found in:

  • src/lib/quota-events-loader.ts:2-2
  • src/lib/quota-events-loader.ts:83-83

Kody rule violation: Never expose secrets or private infrastructure values; reuse existing fleet env vars

Prompt for LLM

File src/lib/__tests__/quota-events-loader.test.ts:

Line 18:

The `vi.mock` call for `@sentry/nextjs` adds Sentry to the test module graph, violating Rule 94’s requirement that Datadog remain the sole observability backend. Refactor the loader and test to use and mock the project’s Datadog-backed observability abstraction instead.

**Also found in:**
- `src/lib/quota-events-loader.ts:2-2`
- `src/lib/quota-events-loader.ts:83-83`

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Producer quota windows for subscription usage

2 participants