@@ -7,7 +7,18 @@ import {
77 DEFAULT_DENY_RULES ,
88 evaluateDenyHooks ,
99} from "../../packages/loopover-miner/lib/deny-hooks.js" ;
10- import {
10+ import type { DenyRuleProposal } from "../../packages/loopover-engine/src/miner/deny-hook-synthesis" ;
11+ // #7525: normalizeRepoFullName is defined in the engine and re-exported unchanged by the miner-lib module
12+ // above; import it from the engine source directly so the guard's src branches are the ones exercised.
13+ import { normalizeRepoFullName } from "../../packages/loopover-engine/src/miner/deny-hook-synthesis" ;
14+ import { resolveLocalStoreDbPath } from "../../packages/loopover-miner/lib/local-store.js" ;
15+ import { cleanupResourceCount , resetProcessLifecycleForTesting } from "../../packages/loopover-miner/lib/process-lifecycle.js" ;
16+
17+ // Import the .ts SOURCE (not the build-time .js) via a non-literal specifier. Once `build:miner` has produced
18+ // the artifact, a plain `.js` import loads that .js and leaves coverage.include's `.ts` entry at 0% — the
19+ // .js-vs-.ts mismatch that closed #8500/#8516 on codecov/patch. Same pattern as miner-replay-snapshot.test.ts (#7796).
20+ const DENY_HOOK_SYNTHESIS_MODULE = "../../packages/loopover-miner/lib/deny-hook-synthesis.ts" ;
21+ const {
1122 aggregateBlockerHistory,
1223 changedPathToDenyGlob,
1324 initDenyHookSynthesisStore,
@@ -16,12 +27,7 @@ import {
1627 resolveEffectiveDenyRules,
1728 setProposalStatuses,
1829 synthesizeDenyRuleProposals,
19- } from "../../packages/loopover-miner/lib/deny-hook-synthesis.js" ;
20- import type { DenyRuleProposal } from "../../packages/loopover-engine/src/miner/deny-hook-synthesis" ;
21- // #7525: normalizeRepoFullName is defined in the engine and re-exported unchanged by the miner-lib module
22- // above; import it from the engine source directly so the guard's src branches are the ones exercised.
23- import { normalizeRepoFullName } from "../../packages/loopover-engine/src/miner/deny-hook-synthesis" ;
24- import { resolveLocalStoreDbPath } from "../../packages/loopover-miner/lib/local-store.js" ;
30+ } = ( await import ( DENY_HOOK_SYNTHESIS_MODULE ) ) as typeof import ( "../../packages/loopover-miner/lib/deny-hook-synthesis.js" ) ;
2531
2632const tempDirs : string [ ] = [ ] ;
2733const stores : Array < { close ( ) : void } > = [ ] ;
@@ -180,6 +186,16 @@ describe("initDenyHookSynthesisStore() (#4522)", () => {
180186 expect ( ( ) => initDenyHookSynthesisStore ( " " ) ) . toThrow ( "invalid_deny_hook_synthesis_db_path" ) ;
181187 } ) ;
182188
189+ it ( "registers the store for crash-safe cleanup via openLocalStoreDb, and unregisters it on close (#8319)" , ( ) => {
190+ resetProcessLifecycleForTesting ( ) ;
191+ expect ( cleanupResourceCount ( ) ) . toBe ( 0 ) ;
192+ const store = tempStore ( ) ;
193+ expect ( cleanupResourceCount ( ) ) . toBe ( 1 ) ;
194+ stores . splice ( stores . indexOf ( store ) , 1 ) ;
195+ store . close ( ) ;
196+ expect ( cleanupResourceCount ( ) ) . toBe ( 0 ) ;
197+ } ) ;
198+
183199 it ( "skips the forge-scope migration on a second open of an already-migrated file" , ( ) => {
184200 const dir = mkdtempSync ( join ( tmpdir ( ) , "miner-deny-hook-synthesis-remigrate-" ) ) ;
185201 tempDirs . push ( dir ) ;
0 commit comments