Skip to content

test(B-0156): co-located tests for check-tick-history-shard-schema.ts (9 tests)#4047

Merged
AceHack merged 1 commit into
mainfrom
otto-bg/b0156-schema-test-2026-05-17
May 17, 2026
Merged

test(B-0156): co-located tests for check-tick-history-shard-schema.ts (9 tests)#4047
AceHack merged 1 commit into
mainfrom
otto-bg/b0156-schema-test-2026-05-17

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 17, 2026

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 .sh original was retired in PR #1986; the .ts had no co-located test.

What

  • tools/hygiene/check-tick-history-shard-schema.ts: export scanOne and
    ScanResult (2-line change; no behavior change).
  • tools/hygiene/check-tick-history-shard-schema.test.ts: 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 + restores prior REPO_ROOT to keep env clean across
    the broader bun test run.

Why

The B-0156 row's audit shows all 6 non-install .sh files now have
working .ts siblings (Phase 5 sweep done), but criterion 2 (test
coverage) 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 exactly
one 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 — and
    the env-restore in afterAll actually unblocked the broader suite
    by avoiding REPO_ROOT pollution)
  • bun tools/hygiene/check-tick-history-shard-schema.ts: production
    CLI runs unchanged; pre-existing repo shard violations preserved

B-0156 status after this PR

The row's audit baseline (3 remaining .sh files) is now stale — the
re-verification command in the row's self-test section shows zero
remaining non-install .sh files without .ts siblings. After this
PR, two .ts ports remain without co-located tests
(snapshot-github-settings.ts, check-github-settings-drift.ts); both
are candidates for follow-on slices.

Test plan

  • Tests pass standalone
  • Tests pass in broader hygiene suite
  • Production CLI unaffected
  • Pushed claim branch before write work (otto-bg/b0156-schema-test-2026-05-17)
  • Isolated worktree (.claude/worktrees/agile-doodling-iverson); did not touch root checkout
  • Branch guard verified pre-commit
  • git ls-tree HEAD = 53 entries (no commit-tree corruption)

🤖 Generated with Claude Code

… (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>
Copilot AI review requested due to automatic review settings May 17, 2026 08:01
@AceHack AceHack enabled auto-merge (squash) May 17, 2026 08:01
@AceHack AceHack merged commit 7383c95 into main May 17, 2026
32 checks passed
@AceHack AceHack deleted the otto-bg/b0156-schema-test-2026-05-17 branch May 17, 2026 08:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ScanResult and scanOne from the shard schema checker.
  • Adds 9 Bun tests covering valid shards and common schema violations.
  • Uses a temporary REPO_ROOT fixture 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;
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