Skip to content

feat: add TypeScript stub detector script and pre-commit hook [OMN-5598] - #80

Merged
jonahgabriel merged 1 commit into
mainfrom
jonahgabriel/omn-5598-ts-stub-detector
Mar 20, 2026
Merged

jonahgabriel merged 1 commit into
mainfrom
jonahgabriel/omn-5598-ts-stub-detector

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Create scripts/check_ts_stubs.sh -- grep-based TS/JS stub detector
  • Add 12-case test suite (tests/test_check_ts_stubs.sh)
  • Export as check-ts-stubs pre-commit hook in .pre-commit-hooks.yaml

Context

Part of epic OMN-5597 (Stub Remediation and CI Prevention). This script detects forbidden // stub: markers in TypeScript/JavaScript files while allowing // stub-ok: <reason> and // intentional-skip: <reason> escape hatches. Downstream repos (omnidash) will consume this hook.

Test plan

  • All 12 test cases pass (forbidden stubs, case variations, allowed markers, node_modules skip, non-TS ignore)
  • Pre-commit hooks pass

Summary by CodeRabbit

  • New Features

    • Added automatic pre-commit validation to detect and prevent accidental commits of unallowed stub markers in TypeScript/JavaScript files.
  • Tests

    • Added test suite for stub detection validation.

Create a grep-based TS/JS stub detector that flags forbidden `// stub:`
comments while allowing `// stub-ok:` and `// intentional-skip:` escape
hatches. Includes 12-case test suite covering case variations, allowed
markers, non-TS files, and node_modules exclusion.

Export as `check-ts-stubs` pre-commit hook for downstream repos.
@coderabbitai

coderabbitai Bot commented Mar 20, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new pre-commit hook and accompanying Bash script have been added to detect forbidden stub markers in TypeScript and JavaScript files. The implementation includes a bash script that filters files by extension, searches for // stub: patterns (case-insensitive) while allowing stub-ok: and intentional-skip: markers, and a comprehensive test suite validating the detection logic across various scenarios.

Changes

Cohort / File(s) Summary
Pre-commit Configuration
.pre-commit-hooks.yaml
Added check-ts-stubs hook that executes the stub-checking script on TypeScript/JavaScript files, excluding node_modules/, dist/, and .next/ directories.
Stub Detection Implementation
scripts/check_ts_stubs.sh
New bash script that identifies forbidden stub markers (// stub:) in TS/JS files while permitting allowed variants (stub-ok:, intentional-skip:), with filtering for file extensions and common generated directories.
Test Suite
tests/test_check_ts_stubs.sh
Comprehensive test runner validating stub detection across multiple scenarios including forbidden markers in various cases, allowed markers, non-TS files, excluded directories, and edge cases with whitespace variations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A bash script hops to check your files,
Seeking stubs in sneaky styles,
Pre-commit hooks stand guard with care,
No hidden markers escape the snare! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a TypeScript stub detector script and pre-commit hook. It is specific, concise, and clearly summarizes the primary changes in the changeset.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonahgabriel/omn-5598-ts-stub-detector
📝 Coding Plan
  • Generate coding plan for human review comments

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

@jonahgabriel
jonahgabriel enabled auto-merge March 20, 2026 14:03
@jonahgabriel
jonahgabriel added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 465b9c1 Mar 20, 2026
12 of 13 checks passed
@jonahgabriel
jonahgabriel deleted the jonahgabriel/omn-5598-ts-stub-detector branch March 20, 2026 14:06
jonahgabriel added a commit that referenced this pull request May 22, 2026
OMN-11497:
- Update dod-product-pr-79 receipt to final SHA 763ed90 (mypy fix)
- Update contract to reflect final SHA

OMN-11502 (new):
- Add contract for rich terminal display module (PR #80)
- dod-product-pr-80: PR #80 head SHA 8f4827c
- dod-unit-tests: full suite pass
- dod-occ-self: self-binding to OCC PR #1312

Closes OMN-11497, OMN-11502
jonahgabriel added a commit that referenced this pull request May 22, 2026
* docs(OMN-11497): bind ToolRegistry evidence — PR #79 receipts

- contracts/OMN-11497.yaml: contract for in-process ToolRegistry ticket
- drift/dod_receipts/OMN-11497/dod-product-pr-79: PR #79 head SHA db84543
- drift/dod_receipts/OMN-11497/dod-unit-tests: 12 tool registry tests pass, 616 total
- drift/dod_receipts/OMN-11497/dod-occ-self: self-binding receipt

Addresses CodeRabbit review: restricted exec globals + ThreadPoolExecutor timeout.

Closes OMN-11497

* docs(OMN-11497): update self-binding receipt with OCC PR #1312 SHA

* docs(OMN-11497,OMN-11502): update PR #79 receipt + add PR #80 evidence

OMN-11497:
- Update dod-product-pr-79 receipt to final SHA 763ed90 (mypy fix)
- Update contract to reflect final SHA

OMN-11502 (new):
- Add contract for rich terminal display module (PR #80)
- dod-product-pr-80: PR #80 head SHA 8f4827c
- dod-unit-tests: full suite pass
- dod-occ-self: self-binding to OCC PR #1312

Closes OMN-11497, OMN-11502

* docs(OMN-11497,OMN-11502): fix receipt schema validation errors

- OMN-11497 dod-unit-tests: remove extra "12 passed: true" field (extra_forbidden)
- OMN-11497 dod-unit-tests: update commit_sha to final SHA 763ed90
- OMN-11502 dod-unit-tests: add required probe_command + probe_stdout fields
- OMN-11502 dod-occ-self: fix commit_sha (was "PENDING"), add probe_command + probe_stdout

All 6 receipts validate against ModelDodReceipt schema.

Closes OMN-11497, OMN-11502

* fix(OMN-11497,OMN-11502): add contract_sha256 to all receipts (OMN-10421 requirement)

Receipts produced after 2026-04-30 must record the contract hash.
Added sha256 fingerprint of OMN-11497.yaml and OMN-11502.yaml to all
six dod_receipt files for these two tickets.
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