Skip to content

test(reports): pin the shared JSON envelope on all three binaries - #18

Merged
JeffreyJYZ merged 1 commit into
mainfrom
test/envelope-contract
Nov 13, 2026
Merged

JeffreyJYZ merged 1 commit into
mainfrom
test/envelope-contract

Conversation

@jyzbot

@jyzbot jyzbot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR #17 merged first (8527474), so the envelope fixes are on main. This adds the missing enforcement: parity was pinned by prose and a /tmp script, not by a test.

The contract

REPORT_*_KEYS in cmduse/src/report_render.rs:

pub const REPORT_DAILY_KEYS:   [&str; 4] = ["days", "scope", "source", "total"];
pub const REPORT_HOURLY_KEYS:  [&str; 4] = ["hours", "scope", "source", "total"];
pub const REPORT_MODEL_KEYS:  [&str; 5] = ["models", "scope", "since", "sinceMs", "source"];
pub const REPORT_SESSION_KEYS: [&str; 4] = ["projects", "scope", "sessions", "source"];

Each binary now has report_json_envelopes_are_the_shared_contract, asserting its own emitters against those constants:

  • cmduse: table, hourly_table, model_table, project_table
  • ocuse: bucket_text (day + hour), model_report, session_text
  • arkuse: same three builders

Mutation check (the test proves it bites)

Dropping projects from REPORT_SESSION_KEYS:

thread 'render_tests::report_json_envelopes_are_the_shared_contract' panicked:
  left:  ["projects", "scope", "sessions", "source"]
  right: ["scope", "sessions", "source"]
thread 'ocuse::render::tests::report_json_envelopes_are_the_shared_contract' panicked

Restored → 3 passed; 207 filtered out.

Gates

cargo test -p cmd-usage                    210 passed, 0 failed  (+3)
cargo clippy --all-targets -D warnings     clean
cargo fmt --all -- --check                 clean

The constants are #[cfg(test)] on purpose: production code must not read the contract back and agree with itself.

Binaries built from merged main, all four reports

### daily    days,scope,source,total                    cmduse / ocuse / arkuse
### hourly   hours,scope,source,total                   cmduse / ocuse / arkuse
### model    models,scope,since,sinceMs,source          cmduse / ocuse / arkuse
### session  projects,scope,sessions,source             cmduse / ocuse / arkuse

The parity work in #17 was enforced by prose and an ad-hoc script. REPORT_*_KEYS
in report_render.rs is now the single contract, and each binary asserts its own
emitter against it (daily, hourly, model, session), so a key dropped from either
side fails all three tests.

Mutation-checked: shrinking REPORT_SESSION_KEYS to drop 'projects' fails the
cmduse and ocuse tests with the exact left/right key sets, and the suite returns
green when restored.

Test-only constants, so production code cannot read the contract back and agree
with itself.
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cmdcode-tools-site Ready Ready Preview Nov 13, 2026 4:01am UTC

@JeffreyJYZ
JeffreyJYZ merged commit a96d4d4 into main Nov 13, 2026
10 checks passed
@JeffreyJYZ
JeffreyJYZ deleted the test/envelope-contract branch November 13, 2026 04:02

This branch was successfully deployed

1 active deployment
Preview — 74c04ad0 Deployed Nov 13, 2026 by vercel[bot]
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.

2 participants