⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.
Context
packages/loopover-engine/src/governor-ledger.ts validates and normalizes a governor ledger event
before an append-only SQLite insert. Its four private helpers — normalizeRequiredString,
normalizeOptionalRepoFullName, jsonRoundTripEqual, and serializePayload (lines 33-90) — are
wrapped in a single block comment:
/* v8 ignore start -- Normalization helpers are covered through normalizeGovernorLedgerEvent export tests. */
That claim is false for most of the file's real error branches. test/governor-ledger.test.ts (the
only file anywhere in the repo that calls normalizeGovernorLedgerEvent) contains exactly 3 tests,
and all three exercise only the repoFullName path-safety/character-set branches inside
normalizeOptionalRepoFullName. None of the following genuinely reachable throw branches in
normalizeGovernorLedgerEvent (lines 97-110) or its helpers are exercised by any test in the repo:
invalid_event — thrown when input is not an object (line 98)
invalid_event_type — thrown when eventType is missing/non-string/empty, or not one of
GOVERNOR_LEDGER_EVENT_TYPES (lines 100-101, via normalizeRequiredString)
invalid_action_class — thrown when actionClass is missing/non-string/empty (line 105)
invalid_decision — thrown when decision is missing/non-string/empty (line 106)
invalid_reason — thrown when reason is missing/non-string/empty (line 107)
invalid_payload — thrown by serializePayload (lines 74-89) for three distinct cases: a
non-object/array/null payload, a payload that throws inside JSON.stringify (e.g. a circular
reference), and a payload whose JSON.parse(JSON.stringify(...)) round-trip is not
jsonRoundTripEqual to the original (e.g. an object with undefined-valued keys, which
JSON.stringify silently drops)
Because these helpers are under a blanket v8 ignore block, Codecov's patch-coverage gate will
never force a future edit to this file to add coverage for these branches — the ignore comment
actively hides the gap it claims doesn't exist.
Requirements
- Remove the
/* v8 ignore start ... stop */ block wrapping lines 33-90 in
packages/loopover-engine/src/governor-ledger.ts. Do not add narrower, per-line ignore comments
in its place unless a specific line is genuinely unreachable — the whole point of this issue is
that these branches ARE reachable and must be tested, not re-hidden more precisely.
- Add regression tests to
packages/loopover-engine/test/governor-ledger.test.ts that directly call
normalizeGovernorLedgerEvent (via the same ../dist/index.js import the existing tests use) and
assert each of the following throws with the exact error message shown:
- non-object
input (e.g. null, "x", 42) → invalid_event
- missing
eventType → invalid_event_type
- empty-string
eventType (e.g. " ") → invalid_event_type
eventType not in GOVERNOR_LEDGER_EVENT_TYPES (e.g. "bogus") → invalid_event_type
- missing
actionClass → invalid_action_class
- missing
decision → invalid_decision
- missing
reason → invalid_reason
payload that is an array (e.g. []) → invalid_payload
payload that is null → invalid_payload
payload containing a circular reference → invalid_payload
payload containing an undefined-valued key (e.g. { a: undefined }) → invalid_payload
(this is the case jsonRoundTripEqual exists specifically to catch — JSON.stringify drops the
key silently, so a naive round-trip check without jsonRoundTripEqual would miss it)
- A valid
payload (e.g. { foo: "bar" }) must still round-trip to payloadJson: '{"foo":"bar"}'
with no throw — add or confirm a passing-case assertion for this alongside the failure cases above.
Deliverables
All three Deliverables are required in this one PR — there is no narrower scope for this issue.
Test Coverage Requirements
packages/loopover-engine/src/** is measured by Codecov via two separate uploads whose hits are
unioned — root test/** AND packages/loopover-engine/test/**. The regression tests for this
issue must be added under packages/loopover-engine/test/governor-ledger.test.ts specifically (not
only a root-level test/** file), or the patch-coverage gate can fail even with a passing
root-level test. Target 100% branch coverage of every line un-ignored by this change; every throw
statement and every non-throw fallthrough in the affected functions needs at least one asserting
test.
Expected Outcome
normalizeGovernorLedgerEvent's full validation surface — not just the repoFullName path-safety
subset — is exercised by real tests, and the Codecov patch gate will catch a future regression in
any of these branches instead of silently passing because the code is v8 ignored.
Links & Resources
packages/loopover-engine/src/governor-ledger.ts (lines 33-110)
packages/loopover-engine/test/governor-ledger.test.ts
- Milestone: Miner Wave 4.6 — AMS Hardening Round 3
Context
packages/loopover-engine/src/governor-ledger.tsvalidates and normalizes a governor ledger eventbefore an append-only SQLite insert. Its four private helpers —
normalizeRequiredString,normalizeOptionalRepoFullName,jsonRoundTripEqual, andserializePayload(lines 33-90) — arewrapped in a single block comment:
/* v8 ignore start -- Normalization helpers are covered through normalizeGovernorLedgerEvent export tests. */That claim is false for most of the file's real error branches.
test/governor-ledger.test.ts(theonly file anywhere in the repo that calls
normalizeGovernorLedgerEvent) contains exactly 3 tests,and all three exercise only the
repoFullNamepath-safety/character-set branches insidenormalizeOptionalRepoFullName. None of the following genuinely reachable throw branches innormalizeGovernorLedgerEvent(lines 97-110) or its helpers are exercised by any test in the repo:invalid_event— thrown wheninputis not an object (line 98)invalid_event_type— thrown wheneventTypeis missing/non-string/empty, or not one ofGOVERNOR_LEDGER_EVENT_TYPES(lines 100-101, vianormalizeRequiredString)invalid_action_class— thrown whenactionClassis missing/non-string/empty (line 105)invalid_decision— thrown whendecisionis missing/non-string/empty (line 106)invalid_reason— thrown whenreasonis missing/non-string/empty (line 107)invalid_payload— thrown byserializePayload(lines 74-89) for three distinct cases: anon-object/array/null
payload, apayloadthat throws insideJSON.stringify(e.g. a circularreference), and a
payloadwhoseJSON.parse(JSON.stringify(...))round-trip is notjsonRoundTripEqualto the original (e.g. an object withundefined-valued keys, whichJSON.stringifysilently drops)Because these helpers are under a blanket
v8 ignoreblock, Codecov's patch-coverage gate willnever force a future edit to this file to add coverage for these branches — the ignore comment
actively hides the gap it claims doesn't exist.
Requirements
/* v8 ignore start ... stop */block wrapping lines 33-90 inpackages/loopover-engine/src/governor-ledger.ts. Do not add narrower, per-line ignore commentsin its place unless a specific line is genuinely unreachable — the whole point of this issue is
that these branches ARE reachable and must be tested, not re-hidden more precisely.
packages/loopover-engine/test/governor-ledger.test.tsthat directly callnormalizeGovernorLedgerEvent(via the same../dist/index.jsimport the existing tests use) andassert each of the following throws with the exact error message shown:
input(e.g.null,"x",42) →invalid_eventeventType→invalid_event_typeeventType(e.g." ") →invalid_event_typeeventTypenot inGOVERNOR_LEDGER_EVENT_TYPES(e.g."bogus") →invalid_event_typeactionClass→invalid_action_classdecision→invalid_decisionreason→invalid_reasonpayloadthat is an array (e.g.[]) →invalid_payloadpayloadthat isnull→invalid_payloadpayloadcontaining a circular reference →invalid_payloadpayloadcontaining anundefined-valued key (e.g.{ a: undefined }) →invalid_payload(this is the case
jsonRoundTripEqualexists specifically to catch —JSON.stringifydrops thekey silently, so a naive round-trip check without
jsonRoundTripEqualwould miss it)payload(e.g.{ foo: "bar" }) must still round-trip topayloadJson: '{"foo":"bar"}'with no throw — add or confirm a passing-case assertion for this alongside the failure cases above.
Deliverables
v8 ignoreblock ingovernor-ledger.tsis removed.packages/loopover-engine/test/governor-ledger.test.tsasserting the exact thrown errormessage.
All three Deliverables are required in this one PR — there is no narrower scope for this issue.
Test Coverage Requirements
packages/loopover-engine/src/**is measured by Codecov via two separate uploads whose hits areunioned — root
test/**ANDpackages/loopover-engine/test/**. The regression tests for thisissue must be added under
packages/loopover-engine/test/governor-ledger.test.tsspecifically (notonly a root-level
test/**file), or the patch-coverage gate can fail even with a passingroot-level test. Target 100% branch coverage of every line un-ignored by this change; every throw
statement and every non-throw fallthrough in the affected functions needs at least one asserting
test.
Expected Outcome
normalizeGovernorLedgerEvent's full validation surface — not just therepoFullNamepath-safetysubset — is exercised by real tests, and the Codecov patch gate will catch a future regression in
any of these branches instead of silently passing because the code is
v8 ignored.Links & Resources
packages/loopover-engine/src/governor-ledger.ts(lines 33-110)packages/loopover-engine/test/governor-ledger.test.ts