Skip to content

feat(OMN-10299): add cost.by_repo.v1 topic to TOPICS constant - #34

Merged
jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10299-add-cost-by-repo-topic
Apr 29, 2026
Merged

jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10299-add-cost-by-repo-topic

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds costByRepo: 'onex.snapshot.projection.cost.by_repo.v1' to the TOPICS constant in shared/types/topics.ts and ships a companion test file.

Ticket: OMN-10299

Changes

  • shared/types/topics.ts: new costByRepo key at the end of TOPICS
  • shared/types/topics.test.ts: 4 tests — value assertion, TopicSymbol union membership (compile-time), uniqueness invariant, naming convention

Upstream blocker — repo_name column gap

The repo_name column does NOT exist in llm_cost_aggregates.

Migration omnibase_infra/docker/migrations/forward/031_create_llm_call_metrics_and_cost_aggregates.sql:142 defines only a generic aggregation_key VARCHAR(512) column. Until upstream resolves this, consumers will see the topic registered with no data.

Two options for omnibase_infra:

(a) Add a new migration (032+) with an explicit repo_name VARCHAR column to llm_cost_aggregates.

(b) Document and standardize an aggregation_key encoding scheme (e.g. repo:<name>) and emit/query rows using that encoding.

A follow-up ticket in omnibase_infra should be created to track this decision. This PR registers the topic as a leading contract; the manifest entry (OMN-10302) also blocks on that upstream decision.

dod_evidence

  • shared/types/topics.ts contains costByRepo key: grep -c 'costByRepo' shared/types/topics.ts → 1
  • Type test assigns TOPICS.costByRepo to TopicSymbol without error: npm run check exits 0
  • Tests pass: npm run test:run -- shared/types/topics.test.ts → 4/4 pass
  • Lint clean: npm run lint exits 0
  • Pre-commit all-files: all hooks pass

Summary by CodeRabbit

  • New Features

    • Introduced a new cost-by-repository reporting metric, enabling detailed cost tracking and comparative analysis across different repositories to support better resource management.
  • Tests

    • Added comprehensive test coverage for topic validation, including verification of naming conventions, uniqueness constraints, and compliance with system standards.

@jonahgabriel
jonahgabriel enabled auto-merge April 29, 2026 17:54
@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jonahgabriel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minute and 11 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e26736c-52c4-450c-9c0d-4802acc1603b

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8d29f and b37dd2c.

📒 Files selected for processing (2)
  • shared/types/topics.test.ts
  • shared/types/topics.ts
📝 Walkthrough

Walkthrough

A new topic constant costByRepo is added to the TOPICS object with the value 'onex.snapshot.projection.cost.by_repo.v1', and corresponding Vitest tests verify the constant's properties including value correctness, type inclusion, uniqueness, and naming conventions.

Changes

Cohort / File(s) Summary
Topic Constant Addition
shared/types/topics.ts
Added costByRepo property to TOPICS constant pointing to the projection topic 'onex.snapshot.projection.cost.by_repo.v1'; TopicSymbol type automatically expands to include the new topic.
Topic Tests
shared/types/topics.test.ts
Added Vitest suite with four assertions: verifying costByRepo value, confirming type union inclusion, validating uniqueness of all topic values, and ensuring all topics begin with 'onex.' prefix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A cost tracker hops into view,
Repository savings, shiny and new!
One-ex topics align with care,
Projection snapshots, constants to spare!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately reflects the main change: adding a new costByRepo topic to the TOPICS constant, with the specific topic identifier included for clarity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-10299-add-cost-by-repo-topic

Review rate limit: 0/5 reviews remaining, refill in 1 minute and 11 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonahgabriel
jonahgabriel force-pushed the jonah/omn-10299-add-cost-by-repo-topic branch from 7985b92 to 0d8d29f Compare April 29, 2026 18:04
@jonahgabriel
jonahgabriel added this pull request to the merge queue Apr 29, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
shared/types/topics.test.ts (1)

22-26: Strengthen the naming-convention assertion to match the documented prefix.

On Line 25, ^onex\. is broader than your documented convention and can pass invalid topic forms.

Proposed test tightening
-    for (const v of values) {
-      expect(v).toMatch(/^onex\./);
-    }
+    for (const v of values) {
+      expect(v).toMatch(/^onex\.snapshot\.projection\./);
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shared/types/topics.test.ts` around lines 22 - 26, The test asserting topic
naming should be tightened to the documented prefix: update the assertion in the
test that iterates over Object.values(TOPICS) (the "all TOPICS values follow the
onex.snapshot.projection prefix convention" test) to use a stricter regex that
matches the exact documented prefix (for example require
"onex.snapshot.projection." at the start) instead of the loose /^onex\./ pattern
so invalid topic forms are rejected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@shared/types/topics.ts`:
- Around line 33-34: TOPICS.costByRepo is defined but not exposed in
scripts/generate-registry.ts; open scripts/generate-registry.ts and add a
registry/component entry that references TOPICS.costByRepo (the same pattern
used for llmCost, delegationSummary, baselinesRoi, etc.), providing the required
manifest fields (id/name/topic/projection/handler as used by other entries) so
the costByRepo topic is surfaced in the generated registry; ensure the new entry
uses the TOPICS.costByRepo symbol and matches the existing component shape in
the file.

---

Nitpick comments:
In `@shared/types/topics.test.ts`:
- Around line 22-26: The test asserting topic naming should be tightened to the
documented prefix: update the assertion in the test that iterates over
Object.values(TOPICS) (the "all TOPICS values follow the
onex.snapshot.projection prefix convention" test) to use a stricter regex that
matches the exact documented prefix (for example require
"onex.snapshot.projection." at the start) instead of the loose /^onex\./ pattern
so invalid topic forms are rejected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6397670-5410-41fd-8430-caaf76f87860

📥 Commits

Reviewing files that changed from the base of the PR and between 21bb1a0 and 0d8d29f.

📒 Files selected for processing (2)
  • shared/types/topics.test.ts
  • shared/types/topics.ts

Comment thread shared/types/topics.ts Outdated
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Apr 29, 2026
@jonahgabriel
jonahgabriel force-pushed the jonah/omn-10299-add-cost-by-repo-topic branch from 0d8d29f to fcf2d78 Compare April 29, 2026 18:19
@jonahgabriel
jonahgabriel enabled auto-merge April 29, 2026 18:19
Adds costByRepo key to the TOPICS constant in shared/types/topics.ts and
ships a companion test file covering the value, TypeScript union membership,
uniqueness, and naming convention invariants.

Upstream-blocked: repo_name column absent from llm_cost_aggregates
(omnibase_infra migration 031:142 uses generic aggregation_key only).
Follow-up required in omnibase_infra before consumers can receive data.
@jonahgabriel
jonahgabriel force-pushed the jonah/omn-10299-add-cost-by-repo-topic branch from fcf2d78 to b37dd2c Compare April 29, 2026 18:23
@jonahgabriel
jonahgabriel added this pull request to the merge queue Apr 29, 2026
Merged via the queue into main with commit 1aa7128 Apr 29, 2026
24 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-10299-add-cost-by-repo-topic branch April 29, 2026 18:29
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.

1 participant