test(B-0156): co-located tests for check-tick-history-shard-schema.ts (9 tests)#4047
Merged
Merged
Conversation
… (9 tests)
Addresses B-0156 acceptance criterion 2 ("each TS sibling has at least
one bun test covering its primary entry path") for the Phase 2 schema
port at tools/hygiene/check-tick-history-shard-schema.ts. The .sh
original was deleted in PR #1986; the .ts had no co-located test.
What
- Export scanOne and ScanResult from check-tick-history-shard-schema.ts
(minimal surface change — no behavior change).
- Add check-tick-history-shard-schema.test.ts with 9 cases:
- 3 acceptance paths (HHMMZ.md, HHMMZ-<hex>.md, HH:MM:SSZ col1)
- 6 violation paths (bad filename, col1 date/time mismatches,
insufficient pipes, empty file, col1 format error)
- Dynamic-import pattern so REPO_ROOT is set to a tmpdir before module
load, captures and restores the prior REPO_ROOT to keep env clean
across the broader bun test run.
Why
Per the B-0156 row, criterion 2 was unverified for the 3 hygiene .ts
ports (snapshot-github-settings, check-github-settings-drift,
check-tick-history-shard-schema). The check-tick-history schema port
is the smallest of the three (~5KB) and has the most testable surface
(per-shard validator with structured return). This is the bounded
B-0156 slice for this tick.
Checks
- bun test tools/hygiene/check-tick-history-shard-schema.test.ts: 9/9 pass
- bun test tools/hygiene/: 181/181 pass (no regression)
- bun tools/hygiene/check-tick-history-shard-schema.ts: production
CLI runs (existing pre-PR violations unchanged)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds co-located Bun tests for the tick-history shard schema checker and exports the validator seam needed by those tests.
Changes:
- Exports
ScanResultandscanOnefrom the shard schema checker. - Adds 9 Bun tests covering valid shards and common schema violations.
- Uses a temporary
REPO_ROOTfixture to avoid touching the real repository.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tools/hygiene/check-tick-history-shard-schema.ts |
Exposes the per-shard scanner and result type for testing. |
tools/hygiene/check-tick-history-shard-schema.test.ts |
Adds co-located tests for accepted and rejected shard schema cases. |
Comment on lines
+46
to
+47
| test("accepts HHMMZ-<hex>.md filename variant", () => { | ||
| const path = writeShard("2026/05/17/1234Z-abc123.md", SIX_COLS); |
Comment on lines
+12
to
+24
| let priorRepoRoot: string | undefined; | ||
|
|
||
| beforeAll(async () => { | ||
| TMPDIR = mkdtempSync(join(tmpdir(), "shard-schema-test-")); | ||
| priorRepoRoot = process.env["REPO_ROOT"]; | ||
| process.env["REPO_ROOT"] = TMPDIR; | ||
| const mod = await import("./check-tick-history-shard-schema"); | ||
| scanOne = mod.scanOne; | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| if (priorRepoRoot === undefined) delete process.env["REPO_ROOT"]; | ||
| else process.env["REPO_ROOT"] = priorRepoRoot; |
AceHack
added a commit
that referenced
this pull request
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Smallest bounded slice of B-0156 — addresses acceptance criterion 2 ("each
TS sibling has at least one bun test covering its primary entry path") for
the Phase 2 schema port at
tools/hygiene/check-tick-history-shard-schema.ts.The
.shoriginal was retired in PR #1986; the.tshad no co-located test.What
tools/hygiene/check-tick-history-shard-schema.ts: exportscanOneandScanResult(2-line change; no behavior change).tools/hygiene/check-tick-history-shard-schema.test.ts: 9 casesHHMMZ.md,HHMMZ-<hex>.md,HH:MM:SSZcol1insufficient pipes, empty file, col1 format error
REPO_ROOTis set to a tmpdir before moduleload; captures + restores prior
REPO_ROOTto keep env clean acrossthe broader
bun testrun.Why
The B-0156 row's audit shows all 6 non-install
.shfiles now haveworking
.tssiblings (Phase 5 sweep done), but criterion 2 (testcoverage) was unverified for the 3 hygiene ports. The schema port is
the smallest (~5KB) and has the most testable surface (per-shard
validator returning structured
ScanResult). This PR ships exactlyone bounded step toward closing B-0156.
Checks
bun test tools/hygiene/check-tick-history-shard-schema.test.ts:9/9 pass
bun test tools/hygiene/: 181/181 pass (no regression — andthe env-restore in
afterAllactually unblocked the broader suiteby avoiding
REPO_ROOTpollution)bun tools/hygiene/check-tick-history-shard-schema.ts: productionCLI runs unchanged; pre-existing repo shard violations preserved
B-0156 status after this PR
The row's audit baseline (3 remaining
.shfiles) is now stale — there-verification command in the row's self-test section shows zero
remaining non-install
.shfiles without.tssiblings. After thisPR, two
.tsports remain without co-located tests(
snapshot-github-settings.ts,check-github-settings-drift.ts); bothare candidates for follow-on slices.
Test plan
.claude/worktrees/agile-doodling-iverson); did not touch root checkoutgit ls-tree HEAD= 53 entries (no commit-tree corruption)🤖 Generated with Claude Code