Skip to content

Commit 7b7c7ea

Browse files
committed
refactor: break snapshot.ts <-> snapshot-quality.ts type cycle — Phase 5 prep
snapshot.ts (the foundational snapshot type module; Rect/SnapshotNode, 96 importers, re-exported by contracts.ts) imported SnapshotQualityVerdict from snapshot-quality.ts, which in turn imports SnapshotNode from snapshot.ts — a type-level cycle that blocks moving snapshot.ts down into a kernel layer. Move the SnapshotQualityVerdict type definition into snapshot.ts (it is referenced by a SnapshotNode field) and re-export it from snapshot-quality.ts so every existing `from './snapshot-quality.ts'` import is unaffected. The validation logic (readSnapshotQualityVerdict + const Sets) stays put. Result: snapshot.ts has zero imports (a clean leaf), unblocking the kernel-seed move and the eventual snapshot/ domain extraction. No behavior change. Verified: tsc, oxfmt + oxlint --deny-warnings, fallow audit clean, 369 tests across utils pass.
1 parent ed701f3 commit 7b7c7ea

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

‎src/utils/snapshot-quality.ts‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
import type { SnapshotNode } from './snapshot.ts';
1+
import type { SnapshotNode, SnapshotQualityVerdict } from './snapshot.ts';
22

3-
/**
4-
* Structured quality verdict computed once by the iOS runner's snapshot capture plan.
5-
* The daemon renders it; it never re-derives degradation from node shapes.
6-
*/
7-
export type SnapshotQualityVerdict = {
8-
state: 'healthy' | 'recovered' | 'sparse';
9-
backend: 'tree' | 'queries' | 'private-ax';
10-
reason?: string;
11-
reasonCode?: 'ax-rejected' | 'sparse-tree' | 'budget' | 'no-nodes' | 'capture-failed';
12-
effectiveDepth?: number;
13-
collapsedLeafIndexes?: number[];
14-
};
3+
// The type lives in snapshot.ts (the foundational type module) to avoid a cyclic
4+
// import with SnapshotNode; re-exported here so existing callers are unaffected.
5+
export type { SnapshotQualityVerdict } from './snapshot.ts';
156

167
const SNAPSHOT_QUALITY_STATES = new Set<SnapshotQualityVerdict['state']>([
178
'healthy',

‎src/utils/snapshot.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
import type { SnapshotQualityVerdict } from './snapshot-quality.ts';
1+
/**
2+
* Structured quality verdict computed once by the iOS runner's snapshot capture plan.
3+
* The daemon renders it; it never re-derives degradation from node shapes.
4+
*
5+
* Defined here (the foundational snapshot type module) rather than in
6+
* snapshot-quality.ts so SnapshotNode can reference it without a cyclic import;
7+
* snapshot-quality.ts (the validation logic) re-exports it for existing callers.
8+
*/
9+
export type SnapshotQualityVerdict = {
10+
state: 'healthy' | 'recovered' | 'sparse';
11+
backend: 'tree' | 'queries' | 'private-ax';
12+
reason?: string;
13+
reasonCode?: 'ax-rejected' | 'sparse-tree' | 'budget' | 'no-nodes' | 'capture-failed';
14+
effectiveDepth?: number;
15+
collapsedLeafIndexes?: number[];
16+
};
217

318
export type Rect = {
419
x: number;

0 commit comments

Comments
 (0)