Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cover rule-engine reconciliation paths; bump global ratchet#142

Merged
twschiller merged 1 commit into
mainfrom
coverage/rule-engine-reconcile-tests
Jun 5, 2026
Merged

Cover rule-engine reconciliation paths; bump global ratchet#142
twschiller merged 1 commit into
mainfrom
coverage/rule-engine-reconcile-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • Brings src/lib/rule-engine.ts from 65.85% → 100% statements (56.25% → 100% functions, 57.69% → 100% branches). The previous test only exercised the initial-apply path; this extends it with the reconciliation paths that fire when storage, enforcement, or availability change.
  • Ratchets global thresholds 62/58/58/61 → 65/60/61/65 to lock in the src/lib gain (src/lib overall: 87.98% → 90.38% statements).

What the new tests cover

  • Storage subscription: rule.apply fires when state flips on; revealAll + rule.teardown fire when state flips off; no-op when state didn't change.
  • Enforcement subscription: all rules tear down when enforcement disabled; all rules re-apply when re-enabled.
  • Availability subscription: rule.apply fires when availability flips true; rule.teardown fires when it flips false.
  • Missing document.body: start() skips initial apply; later state changes also skip reconcile (the about:blank / about:srcdoc iframe edge case).

Mock additions

  • jest.mock("../availability", …) — captured the subscription listener so tests can drive availability changes directly.
  • jest.mock("../placeholder", …) — preserves the real module's other exports via jest.requireActual and stubs revealAll for assertion.

Test plan

  • bun run preflight passes (lint + typecheck + knip + jest with coverage)
  • rule-engine.ts shows 100/100/100/100 in the coverage report
  • Global threshold check passes at the new 65/60/61/65 floor

🤖 Generated with Claude Code

Brings rule-engine.ts from 65.85% to 100% statements (56.25% to 100%
functions, 57.69% to 100% branches). The previous test only exercised
the initial-apply path; this extends it with the reconciliation paths
that fire when storage, enforcement, or availability change:

- storage flip on → rule.apply called
- storage flip off → revealAll + rule.teardown called
- no-op when state didn't change
- enforcement off → all rules tear down
- enforcement on → all rules re-apply
- availability flip true ↔ false routes through the same reconcile
- document.body missing skips both initial apply and reconcile

To drive the listeners directly, mock `../availability` and
`../placeholder` (preserving the real placeholder module's other
exports via jest.requireActual). Subscriber listeners are pulled
out of the mock's `mock.calls` so tests can invoke them with
arbitrary snapshots.

Ratchet global thresholds 62/58/58/61 → 65/60/61/65 to lock in the
src/lib gain.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 1:46am

Request Review

@twschiller twschiller merged commit 8f210cc into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the coverage/rule-engine-reconcile-tests branch June 5, 2026 01:51
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