my-frontend-observer 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +59 -7
  3. package/dist/application/comparisonService.d.ts +56 -0
  4. package/dist/application/comparisonService.js +77 -0
  5. package/dist/application/comparisonService.js.map +1 -0
  6. package/dist/application/frontendContractEvaluationService.d.ts +49 -0
  7. package/dist/application/frontendContractEvaluationService.js +112 -0
  8. package/dist/application/frontendContractEvaluationService.js.map +1 -0
  9. package/dist/application/frontendContractPersistenceService.d.ts +56 -0
  10. package/dist/application/frontendContractPersistenceService.js +91 -0
  11. package/dist/application/frontendContractPersistenceService.js.map +1 -0
  12. package/dist/artifacts/artifactReader.d.ts +19 -0
  13. package/dist/artifacts/artifactReader.js +36 -0
  14. package/dist/artifacts/artifactReader.js.map +1 -0
  15. package/dist/artifacts/comparisonArtifactReader.d.ts +18 -0
  16. package/dist/artifacts/comparisonArtifactReader.js +35 -0
  17. package/dist/artifacts/comparisonArtifactReader.js.map +1 -0
  18. package/dist/artifacts/comparisonArtifactWriter.d.ts +41 -0
  19. package/dist/artifacts/comparisonArtifactWriter.js +67 -0
  20. package/dist/artifacts/comparisonArtifactWriter.js.map +1 -0
  21. package/dist/artifacts/frontendContractArtifactReader.d.ts +24 -0
  22. package/dist/artifacts/frontendContractArtifactReader.js +47 -0
  23. package/dist/artifacts/frontendContractArtifactReader.js.map +1 -0
  24. package/dist/artifacts/frontendContractArtifactWriter.d.ts +34 -0
  25. package/dist/artifacts/frontendContractArtifactWriter.js +70 -0
  26. package/dist/artifacts/frontendContractArtifactWriter.js.map +1 -0
  27. package/dist/artifacts/frontendContractEvaluationArtifactReader.d.ts +17 -0
  28. package/dist/artifacts/frontendContractEvaluationArtifactReader.js +34 -0
  29. package/dist/artifacts/frontendContractEvaluationArtifactReader.js.map +1 -0
  30. package/dist/artifacts/frontendContractEvaluationArtifactWriter.d.ts +32 -0
  31. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js +58 -0
  32. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js.map +1 -0
  33. package/dist/cli.js +712 -3
  34. package/dist/cli.js.map +1 -1
  35. package/dist/domain/comparison.d.ts +198 -0
  36. package/dist/domain/comparison.js +324 -0
  37. package/dist/domain/comparison.js.map +1 -0
  38. package/dist/domain/comparisonEngine.d.ts +48 -0
  39. package/dist/domain/comparisonEngine.js +694 -0
  40. package/dist/domain/comparisonEngine.js.map +1 -0
  41. package/dist/domain/comparisonIdentity.d.ts +13 -0
  42. package/dist/domain/comparisonIdentity.js +46 -0
  43. package/dist/domain/comparisonIdentity.js.map +1 -0
  44. package/dist/domain/evidence.d.ts +2 -0
  45. package/dist/domain/evidence.js +4 -0
  46. package/dist/domain/evidence.js.map +1 -1
  47. package/dist/domain/frontendContractEvaluation.d.ts +57 -0
  48. package/dist/domain/frontendContractEvaluation.js +454 -0
  49. package/dist/domain/frontendContractEvaluation.js.map +1 -0
  50. package/dist/domain/frontendContractEvaluationArtifact.d.ts +65 -0
  51. package/dist/domain/frontendContractEvaluationArtifact.js +108 -0
  52. package/dist/domain/frontendContractEvaluationArtifact.js.map +1 -0
  53. package/dist/domain/frontendContractIdentity.d.ts +39 -0
  54. package/dist/domain/frontendContractIdentity.js +70 -0
  55. package/dist/domain/frontendContractIdentity.js.map +1 -0
  56. package/dist/domain/frontendContracts.d.ts +188 -0
  57. package/dist/domain/frontendContracts.js +260 -0
  58. package/dist/domain/frontendContracts.js.map +1 -0
  59. package/dist/domain/relationships.d.ts +168 -0
  60. package/dist/domain/relationships.js +343 -0
  61. package/dist/domain/relationships.js.map +1 -0
  62. package/dist/index.d.ts +36 -1
  63. package/dist/index.js +20 -1
  64. package/dist/index.js.map +1 -1
  65. package/docs/ARCHITECTURE.md +173 -3
  66. package/docs/CI_CD.md +76 -0
  67. package/docs/COMMANDS.md +299 -0
  68. package/docs/CONTRACTS.md +270 -6
  69. package/docs/CURRENT_STATE.md +183 -8
  70. package/docs/DEVELOPMENT.md +83 -12
  71. package/docs/PROJECT_OVERVIEW.md +18 -8
  72. package/docs/QUICKSTART.md +10 -0
  73. package/docs/RELEASE.md +17 -8
  74. package/docs/ROADMAP.md +10 -0
  75. package/docs/SECURITY.md +26 -1
  76. package/docs/WORKFLOWS.md +113 -6
  77. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 - 2026-08-13
4
+
5
+ Executable Frontend Contracts and Explicit Change Scope.
6
+
7
+ - Two related contract classes: a `PersistentBaselineContract` (previously
8
+ approved frontend behavior that stays active across future changes unless
9
+ explicitly superseded, with append-based supersession history) and a
10
+ `PerChangeContract` (the allowed scope of one requested change).
11
+ - Four authored change-scope categories - `requested`, `expected-dependent`
12
+ (`required` or `permitted`), `protected`, `preserved` - plus a fifth,
13
+ strictly derived-only classification, `unexpected`, for a meaningful
14
+ rendered difference no active clause accounts for. `unexpected` can never
15
+ be authored as a permission.
16
+ - A closed, bounded vocabulary of 15 contract primitives (visibility,
17
+ clipping, width bounds, non-overlap, relative width, vertical sequence,
18
+ geometric fit, document-width-vs-viewport, scroll ownership, initial-
19
+ viewport position, relationship-unchanged, and property-unchanged/
20
+ increases/decreases) and three contract tolerances (`exact`,
21
+ `absolute-px`, `percent`) - independent of `compare`'s geometry tolerance,
22
+ which only suppresses insignificant noise and is never contract
23
+ authorization.
24
+ - Explicit, never-inferred baseline and per-change clause supersession; two
25
+ clauses that structurally contradict each other without explicit
26
+ supersession produce a `conflict` result rather than a silent preference.
27
+ - One canonical evaluation engine (`evaluateFrontendContract`) that owns
28
+ requested/expected-dependent/protected/preserved evaluation, unexpected-
29
+ change derivation, and the overall `PASS`/`FAIL` verdict - reusing existing
30
+ v0.4 observation/comparison evidence directly, never re-launching a
31
+ browser, re-resolving a target, or reimplementing relationship/clipping
32
+ derivation.
33
+ - Actionable per-clause results (`pass`/`fail`/`unavailable` with a required
34
+ reason/`conflict` with at least two conflicting clause identities) - never
35
+ an opaque score.
36
+ - Atomic, independently-versioned persistence for baseline contracts,
37
+ per-change contracts, and evaluation results, with no destructive artifact
38
+ overwrite, no copied screenshots, and full source observation/comparison/
39
+ contract immutability.
40
+ - Three new public commands: `approve-baseline` (the only baseline-approval
41
+ act - explicit only, never inferred from `compare` or a `PASS`
42
+ evaluation), `save-change-contract` (persistence only), and
43
+ `evaluate-contract` (runs the canonical evaluator against already-
44
+ persisted evidence and persists exactly one evaluation artifact).
45
+ `evaluate-contract --enforce` makes an already-persisted `FAIL` verdict
46
+ produce a nonzero process exit status without changing the verdict, its
47
+ identity, or its persisted content - a `FAIL` without `--enforce` still
48
+ exits `0`.
49
+ - Proven against real Chromium observations, not hand-constructed
50
+ artifacts: a fully successful contract change, and the "milestone
51
+ signature" case - a locally successful requested change coexisting with a
52
+ genuine protected-property regression and a genuine preserved-invariant
53
+ regression - producing overall `FAIL`.
54
+ - Frontend contract schema `1.0.0` and evaluation artifact schema `1.0.0`,
55
+ each its own independent schema family; observation schema remains
56
+ `1.2.0` and comparison schema remains `1.0.0`.
57
+ - Cross-platform packed-candidate validation: one hash-verified npm
58
+ candidate tarball proven on Windows, Linux, and macOS, covering the
59
+ installed candidate's `approve-baseline`, `save-change-contract`, and
60
+ `evaluate-contract` commands alongside every pre-existing v0.1-v0.4
61
+ packed observation/comparison behavior.
62
+
63
+ ## 0.4.0 - 2026-08-12
64
+
65
+ Layout Relationships, Dependency Evidence, and Before/After Comparison.
66
+
67
+ - New comparison artifact kind `my-frontend-observer/comparison`, schema
68
+ `1.0.0` - independent of and never reused for the observation schema.
69
+ - Canonical layout-relationship derivation from a single observation:
70
+ horizontal order (`left-of`/`right-of`/`horizontally-overlapping`),
71
+ vertical order (`above`/`below`/`vertically-overlapping`), area overlap,
72
+ relative width, geometric fit (kept explicitly distinct from DOM
73
+ containment), vertical sequencing (`follows-vertically`), and document-
74
+ width fit/exceeds-viewport - bounded to configured targets, with explicit
75
+ evidence-path provenance and honest unresolved-target handling.
76
+ - Comparability analysis, evaluated before any rendered difference:
77
+ `comparable` / `comparable-with-warnings` / `incomparable`, with
78
+ structured reasons (hard mismatches on page URL, viewport, browser
79
+ engine, or scroll-scenario configuration; warnings for producer/browser
80
+ version and target-configuration differences; theme/authenticated-state/
81
+ application-state recorded as unassessed, never silently equal).
82
+ - Before/after target and page differences: appeared/disappeared (never
83
+ confused with a target added/removed from configuration), moved, resized,
84
+ visibility changes, clipping changes (reusing one canonical clipping
85
+ derivation), actual horizontal/vertical dimensional-overflow changes, DOM
86
+ containment changes, page-size changes, and scroll-owner changes - each a
87
+ structured record with before/after values, deltas where meaningful, and
88
+ supporting evidence references.
89
+ - Relationship-change detection between two observations, matched by
90
+ relationship family and subject/related target (never array position),
91
+ including a `relative-position-changed` distinction from plain absolute
92
+ target movement.
93
+ - Explicit, non-causal expected-dependency evidence: a caller may declare an
94
+ expected relationship between two targets' `x`/`y`/`width`/`height`
95
+ properties and `increase`/`decrease`/`change`/`unchanged` directions; each
96
+ declaration evaluates independently to `consistent` / `not-observed` /
97
+ `contradictory-to-declaration` / `unavailable`. The observer never infers
98
+ a dependency from observed co-change and never produces a causal claim.
99
+ - Deterministic, direction-sensitive comparison identity
100
+ (`comparisonRequestId`) plus a fresh `comparisonId` per execution;
101
+ operational filesystem paths never affect identity and are never written
102
+ into the persisted manifest.
103
+ - Atomic comparison-artifact persistence: `<outputLocation>/<comparisonId>/
104
+ manifest.json` only - no screenshot bytes are copied; the manifest
105
+ retains logical references to the source observations' own
106
+ `screenshot.path`. Source observations are never modified.
107
+ - New public `compare` command: `my-frontend-observer compare --before
108
+ <observation-artifact-root> --after <observation-artifact-root> --output
109
+ <directory> [--config-file <json-file>]`. Reads two already-persisted
110
+ observation artifacts and never launches a browser. `comparable`,
111
+ `comparable-with-warnings`, and `incomparable` all persist successfully
112
+ and exit `0`; only invalid syntax, an unreadable/invalid source artifact,
113
+ invalid configuration, or a failed write exits nonzero.
114
+
3
115
  ## 0.3.0 - 2026-08-12
4
116
 
5
117
  Runtime Scrolling, Overflow, and Visibility Behavior.
package/README.md CHANGED
@@ -6,12 +6,21 @@ in [docs/PROJECT_DESCRIPTION.md](docs/PROJECT_DESCRIPTION.md).
6
6
 
7
7
  ## Current status
8
8
 
9
- `v0.3.0`, Runtime Scrolling, Overflow, and Visibility Behavior, is the
9
+ `v0.5.0`, Executable Frontend Contracts and Explicit Change Scope, is the
10
10
  current published release: `my-frontend-observer observe` launches a real,
11
- sandboxed Chromium browser, enforces a loopback-only safety policy,
12
- captures a viewport screenshot plus bounded page/target evidence, and
13
- persists it as one portable `manifest.json` + `screenshot.png` artifact
14
- (observation schema `1.2.0`).
11
+ sandboxed Chromium browser, enforces a loopback-only safety policy, captures
12
+ a viewport screenshot plus bounded page/target evidence, and persists it as
13
+ one portable `manifest.json` + `screenshot.png` artifact (observation schema
14
+ `1.2.0`). `my-frontend-observer compare` reads two already-persisted
15
+ observation artifacts and derives before/after evidence purely from their
16
+ existing content, persisting a comparison artifact (comparison schema
17
+ `1.0.0`). `my-frontend-observer approve-baseline`, `save-change-contract`,
18
+ and `evaluate-contract` turn that evidence into an executable frontend
19
+ contract: an explicitly approved baseline plus a per-change contract
20
+ (requested/expected-dependent/protected/preserved scope) are evaluated
21
+ together into one `PASS`/`FAIL` verdict, so a locally successful requested
22
+ change can never silently hide a protected-region regression (frontend
23
+ contract schema `1.0.0`; evaluation artifact schema `1.0.0`).
15
24
 
16
25
  Install:
17
26
 
@@ -67,6 +76,49 @@ in
67
76
  [docs/COMMANDS.md](docs/COMMANDS.md#scroll-scenario---scroll-scenario-file)
68
77
  for the exact JSON format and flag reference.
69
78
 
79
+ ### Comparison
80
+
81
+ `my-frontend-observer compare` reads two already-persisted observation
82
+ artifacts and derives before/after evidence purely from their existing
83
+ content - it never launches a browser:
84
+
85
+ ```powershell
86
+ my-frontend-observer compare `
87
+ --before observations/<before-observation-id> `
88
+ --after observations/<after-observation-id> `
89
+ --output comparisons
90
+ ```
91
+
92
+ (From a source checkout, use `node dist/cli.js compare ...` instead.)
93
+
94
+ This prints a concise result (`Comparison:`/`State:`/`Artifact:`/
95
+ `Differences:`/`Relationship changes:`/`Diagnostics:`) and exits `0` -
96
+ including when the two observations turn out to be `incomparable`, which is
97
+ itself a successful comparison outcome. See
98
+ [docs/COMMANDS.md](docs/COMMANDS.md) for the full flag reference.
99
+
100
+ ### Frontend contracts
101
+
102
+ `v0.5.0` ships a text/config-driven frontend contract and evaluation
103
+ workflow: approve a baseline against an observation, save a per-change
104
+ contract, then evaluate a candidate change against them plus existing
105
+ before/after/comparison evidence, deriving one `PASS`/`FAIL` verdict:
106
+
107
+ ```powershell
108
+ my-frontend-observer approve-baseline --observation observations/<id> --contract-file baseline.json --output baselines
109
+ my-frontend-observer save-change-contract --contract-file change.json --output contracts
110
+ my-frontend-observer evaluate-contract --before observations/<before-id> --after observations/<after-id> --comparison comparisons/<id> --baseline baselines/<baseline-id> --change contracts/<contract-id> --output evaluations [--enforce]
111
+ ```
112
+
113
+ (From a source checkout, use `node dist/cli.js approve-baseline ...` etc.
114
+ instead.)
115
+
116
+ `evaluate-contract` never launches a browser or recomputes comparison
117
+ evidence. `--enforce` only changes the process exit status for a `FAIL`
118
+ verdict; the verdict itself, and its persisted evidence, are unaffected. See
119
+ [docs/COMMANDS.md](docs/COMMANDS.md) for the full flag reference and
120
+ [docs/WORKFLOWS.md](docs/WORKFLOWS.md) for the end-to-end flow.
121
+
70
122
  Validation:
71
123
 
72
124
  ```powershell
@@ -84,8 +136,8 @@ Planning authorities:
84
136
  intent and responsibility boundaries.
85
137
  - [Project Milestones](docs/PROJECT_MILESTONES.md): complete ordered capability
86
138
  design and cross-milestone rules.
87
- - [ROADMAP](docs/ROADMAP.md): version-level requirements; v0.1, v0.2, and
88
- v0.3 are released, v0.4 is next.
139
+ - [ROADMAP](docs/ROADMAP.md): version-level requirements; v0.1-v0.5 are
140
+ released, v0.6 is next.
89
141
  - [Current State](docs/CURRENT_STATE.md): retained scaffold and release state.
90
142
 
91
143
  No sibling ecosystem repository is a runtime dependency of the retained
@@ -0,0 +1,56 @@
1
+ import type { ObservationArtifact } from '../domain/schema.js';
2
+ import type { ComparabilityState, ComparisonConfig } from '../domain/comparison.js';
3
+ import type { Diagnostic } from '../domain/diagnostics.js';
4
+ import type { WriteComparisonArtifactOptions } from '../artifacts/comparisonArtifactWriter.js';
5
+ export type { PersistedComparisonResult } from '../artifacts/comparisonArtifactWriter.js';
6
+ /** Default comparison output location, mirroring `request.ts`'s `DEFAULT_OUTPUT_LOCATION` for observations - distinct directories so comparisons never collide with source observations. */
7
+ export declare const DEFAULT_COMPARISON_OUTPUT_LOCATION = "comparisons";
8
+ export interface CompareAndPersistOptions {
9
+ config?: Partial<ComparisonConfig>;
10
+ /** Portable, relative output location (validated the same way as an observation's `outputLocation`). Defaults to `DEFAULT_COMPARISON_OUTPUT_LOCATION`. */
11
+ outputLocation?: string;
12
+ cwd?: WriteComparisonArtifactOptions['cwd'];
13
+ }
14
+ /**
15
+ * Observer-owned summary of one full compare-and-persist attempt, with just
16
+ * enough information for a presentation layer (a future Batch 4 CLI) to
17
+ * report a result without seeing a raw filesystem exception or persistence
18
+ * implementation detail.
19
+ */
20
+ export type ApplicationComparisonResult = {
21
+ ok: true;
22
+ comparisonId: string;
23
+ comparisonRequestId: string;
24
+ comparability: ComparabilityState;
25
+ artifactRoot: string;
26
+ manifestPath: string;
27
+ differenceCount: number;
28
+ relationshipChangeCount: number;
29
+ diagnosticsCount: number;
30
+ } | {
31
+ ok: false;
32
+ diagnostics: Diagnostic[];
33
+ };
34
+ /**
35
+ * The one canonical application-level comparison use case: takes two
36
+ * already-validated/in-memory `ObservationArtifact`s, runs the existing pure
37
+ * `compareObservations` exactly once, and - only for a structurally valid
38
+ * result - persists it exactly once through the existing comparison
39
+ * writer. Never launches Chromium, never re-resolves targets, never mutates
40
+ * either source observation.
41
+ */
42
+ export declare function compareAndPersist(before: ObservationArtifact, after: ObservationArtifact, options?: CompareAndPersistOptions): Promise<ApplicationComparisonResult>;
43
+ /**
44
+ * The canonical Batch 4 CLI-facing orchestration: reads two already-persisted
45
+ * observation artifacts by their root directory (each expected to contain
46
+ * `manifest.json`, mirroring `writeObservationArtifact`'s own layout) through
47
+ * the existing `readObservationArtifact` reader, then delegates to
48
+ * `compareAndPersist` exactly once. A thin wrapper only - artifact reading
49
+ * stays owned by `artifacts/artifactReader.ts`, comparison stays owned by
50
+ * `domain/comparisonEngine.ts`, and persistence stays owned by
51
+ * `artifacts/comparisonArtifactWriter.ts`. Kept in `application/` (not
52
+ * `artifacts/`) so `src/cli.ts` can depend on it without importing the
53
+ * artifacts layer directly - see `tests/unit/cli.test.ts`'s import-boundary
54
+ * assertion. Never launches a browser, never re-resolves targets.
55
+ */
56
+ export declare function compareAndPersistFromArtifactRoots(beforeRoot: string, afterRoot: string, options?: CompareAndPersistOptions): Promise<ApplicationComparisonResult>;
@@ -0,0 +1,77 @@
1
+ import path from 'node:path';
2
+ import { compareObservations } from '../domain/comparisonEngine.js';
3
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
4
+ import { normalizeOutputLocation } from '../request/paths.js';
5
+ import { writeComparisonArtifact } from '../artifacts/comparisonArtifactWriter.js';
6
+ import { readObservationArtifact } from '../artifacts/artifactReader.js';
7
+ import { MANIFEST_FILENAME as OBSERVATION_MANIFEST_FILENAME } from '../artifacts/artifactWriter.js';
8
+ /** Default comparison output location, mirroring `request.ts`'s `DEFAULT_OUTPUT_LOCATION` for observations - distinct directories so comparisons never collide with source observations. */
9
+ export const DEFAULT_COMPARISON_OUTPUT_LOCATION = 'comparisons';
10
+ /**
11
+ * The one canonical application-level comparison use case: takes two
12
+ * already-validated/in-memory `ObservationArtifact`s, runs the existing pure
13
+ * `compareObservations` exactly once, and - only for a structurally valid
14
+ * result - persists it exactly once through the existing comparison
15
+ * writer. Never launches Chromium, never re-resolves targets, never mutates
16
+ * either source observation.
17
+ */
18
+ export async function compareAndPersist(before, after, options = {}) {
19
+ const result = compareObservations(before, after, options.config ?? {});
20
+ if (!result.ok) {
21
+ return {
22
+ ok: false,
23
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: result.reason }],
24
+ };
25
+ }
26
+ const rawOutputLocation = options.outputLocation ?? DEFAULT_COMPARISON_OUTPUT_LOCATION;
27
+ const normalized = normalizeOutputLocation(rawOutputLocation);
28
+ if (!normalized.ok) {
29
+ return { ok: false, diagnostics: [normalized.diagnostic] };
30
+ }
31
+ const persisted = await writeComparisonArtifact(result.artifact, normalized.value, options.cwd === undefined ? {} : { cwd: options.cwd });
32
+ if (!persisted.ok) {
33
+ return { ok: false, diagnostics: persisted.diagnostics };
34
+ }
35
+ return {
36
+ ok: true,
37
+ comparisonId: result.artifact.comparisonId,
38
+ comparisonRequestId: result.artifact.comparisonRequestId,
39
+ comparability: result.artifact.comparability.state,
40
+ artifactRoot: persisted.artifactRoot,
41
+ manifestPath: persisted.manifestPath,
42
+ differenceCount: result.artifact.differences.length,
43
+ relationshipChangeCount: result.artifact.relationshipChanges.length,
44
+ diagnosticsCount: result.artifact.diagnostics.length,
45
+ };
46
+ }
47
+ /**
48
+ * The canonical Batch 4 CLI-facing orchestration: reads two already-persisted
49
+ * observation artifacts by their root directory (each expected to contain
50
+ * `manifest.json`, mirroring `writeObservationArtifact`'s own layout) through
51
+ * the existing `readObservationArtifact` reader, then delegates to
52
+ * `compareAndPersist` exactly once. A thin wrapper only - artifact reading
53
+ * stays owned by `artifacts/artifactReader.ts`, comparison stays owned by
54
+ * `domain/comparisonEngine.ts`, and persistence stays owned by
55
+ * `artifacts/comparisonArtifactWriter.ts`. Kept in `application/` (not
56
+ * `artifacts/`) so `src/cli.ts` can depend on it without importing the
57
+ * artifacts layer directly - see `tests/unit/cli.test.ts`'s import-boundary
58
+ * assertion. Never launches a browser, never re-resolves targets.
59
+ */
60
+ export async function compareAndPersistFromArtifactRoots(beforeRoot, afterRoot, options = {}) {
61
+ const beforeRead = await readObservationArtifact(path.join(beforeRoot, OBSERVATION_MANIFEST_FILENAME));
62
+ if (!beforeRead.ok) {
63
+ return {
64
+ ok: false,
65
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: `--before observation artifact: ${beforeRead.reason}` }],
66
+ };
67
+ }
68
+ const afterRead = await readObservationArtifact(path.join(afterRoot, OBSERVATION_MANIFEST_FILENAME));
69
+ if (!afterRead.ok) {
70
+ return {
71
+ ok: false,
72
+ diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message: `--after observation artifact: ${afterRead.reason}` }],
73
+ };
74
+ }
75
+ return compareAndPersist(beforeRead.artifact, afterRead.artifact, options);
76
+ }
77
+ //# sourceMappingURL=comparisonService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparisonService.js","sourceRoot":"","sources":["../../src/application/comparisonService.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAIpG,4LAA4L;AAC5L,MAAM,CAAC,MAAM,kCAAkC,GAAG,aAAa,CAAC;AAgChE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA2B,EAC3B,KAA0B,EAC1B,UAAoC,EAAE;IAEtC,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,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{ OverallVerdict } from '../domain/frontendContracts.js';
3
+ import type { Diagnostic } from '../domain/diagnostics.js';
4
+ import type { WriteFrontendContractEvaluationArtifactOptions } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
5
+ export type { PersistedFrontendContractEvaluationResult } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
6
+ /** Distinct from `DEFAULT_COMPARISON_OUTPUT_LOCATION`/observation `outputLocation` so evaluations never collide with source evidence. */
7
+ export declare const DEFAULT_EVALUATION_OUTPUT_LOCATION = "evaluations";
8
+ export interface EvaluateAndPersistOptions {
9
+ outputLocation?: string;
10
+ cwd?: WriteFrontendContractEvaluationArtifactOptions['cwd'];
11
+ }
12
+ export type ApplicationFrontendContractEvaluationResult = {
13
+ ok: true;
14
+ evaluationId: string;
15
+ evaluationRequestId: string;
16
+ overallVerdict: OverallVerdict;
17
+ artifactRoot: string;
18
+ manifestPath: string;
19
+ clauseResultCount: number;
20
+ unexpectedChangeCount: number;
21
+ } | {
22
+ ok: false;
23
+ diagnostics: Diagnostic[];
24
+ };
25
+ /**
26
+ * The one canonical application-level frontend-contract evaluation use case:
27
+ * takes already-validated/in-memory evidence, runs the existing pure
28
+ * `evaluateFrontendContract` exactly once, and - only for a structurally
29
+ * constructible result (`ok: true`, whether the verdict itself is `PASS` or
30
+ * `FAIL`) - persists it exactly once through the existing evaluation writer.
31
+ * Never re-evaluates, never launches Chromium, never mutates any input
32
+ * artifact. A `{ ok: false }` evaluator result (evidence could not even be
33
+ * constructed into an evaluation) is never persisted as a fabricated
34
+ * successful artifact - that is an application-level `invalid-request`
35
+ * diagnostic, distinct from a legitimate `FAIL` verdict.
36
+ */
37
+ export declare function evaluateAndPersist(input: FrontendContractEvaluationInput, options?: EvaluateAndPersistOptions): Promise<ApplicationFrontendContractEvaluationResult>;
38
+ /**
39
+ * The canonical future-CLI-facing orchestration: reads before/after
40
+ * observations (through the existing `readObservationArtifact` reader -
41
+ * never a second observation reader), the comparison (through the new
42
+ * `readComparisonArtifact`), and the baseline/per-change contracts (through
43
+ * `frontendContractArtifactReader.ts`) by their root directories, then
44
+ * delegates to `evaluateAndPersist` exactly once. A thin wrapper only -
45
+ * reading stays owned by the artifacts layer, evaluation stays owned by
46
+ * `domain/frontendContractEvaluation.ts`, persistence stays owned by
47
+ * `artifacts/frontendContractEvaluationArtifactWriter.ts`.
48
+ */
49
+ export declare function evaluateAndPersistFromArtifactRoots(beforeRoot: string, afterRoot: string, comparisonRoot: string, baselineRoot: string, changeRoot: string, options?: EvaluateAndPersistOptions): Promise<ApplicationFrontendContractEvaluationResult>;
@@ -0,0 +1,112 @@
1
+ import path from 'node:path';
2
+ import { getProducerInfo } from '../domain/schema.js';
3
+ import { evaluateFrontendContract } from '../domain/frontendContractEvaluation.js';
4
+ import { buildFrontendContractEvaluationArtifact } from '../domain/frontendContractEvaluationArtifact.js';
5
+ import { buildFrontendContractEvaluationRequestIdentity, buildFrontendContractInstanceIdentity } from '../domain/frontendContractIdentity.js';
6
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
7
+ import { normalizeOutputLocation } from '../request/paths.js';
8
+ import { writeFrontendContractEvaluationArtifact } from '../artifacts/frontendContractEvaluationArtifactWriter.js';
9
+ import { readObservationArtifact } from '../artifacts/artifactReader.js';
10
+ import { MANIFEST_FILENAME as OBSERVATION_MANIFEST_FILENAME } from '../artifacts/artifactWriter.js';
11
+ import { readComparisonArtifact } from '../artifacts/comparisonArtifactReader.js';
12
+ import { COMPARISON_MANIFEST_FILENAME } from '../artifacts/comparisonArtifactWriter.js';
13
+ import { readPersistentBaselineContract, readPerChangeContract } from '../artifacts/frontendContractArtifactReader.js';
14
+ import { FRONTEND_CONTRACT_MANIFEST_FILENAME } from '../artifacts/frontendContractArtifactWriter.js';
15
+ /** Distinct from `DEFAULT_COMPARISON_OUTPUT_LOCATION`/observation `outputLocation` so evaluations never collide with source evidence. */
16
+ export const DEFAULT_EVALUATION_OUTPUT_LOCATION = 'evaluations';
17
+ function invalidRequest(message) {
18
+ return { ok: false, diagnostics: [{ code: 'invalid-request', severity: DIAGNOSTIC_SEVERITY['invalid-request'], message }] };
19
+ }
20
+ /**
21
+ * The one canonical application-level frontend-contract evaluation use case:
22
+ * takes already-validated/in-memory evidence, runs the existing pure
23
+ * `evaluateFrontendContract` exactly once, and - only for a structurally
24
+ * constructible result (`ok: true`, whether the verdict itself is `PASS` or
25
+ * `FAIL`) - persists it exactly once through the existing evaluation writer.
26
+ * Never re-evaluates, never launches Chromium, never mutates any input
27
+ * artifact. A `{ ok: false }` evaluator result (evidence could not even be
28
+ * constructed into an evaluation) is never persisted as a fabricated
29
+ * successful artifact - that is an application-level `invalid-request`
30
+ * diagnostic, distinct from a legitimate `FAIL` verdict.
31
+ */
32
+ export async function evaluateAndPersist(input, options = {}) {
33
+ const result = evaluateFrontendContract(input);
34
+ if (!result.ok)
35
+ return invalidRequest(result.reason);
36
+ const rawOutputLocation = options.outputLocation ?? DEFAULT_EVALUATION_OUTPUT_LOCATION;
37
+ const normalized = normalizeOutputLocation(rawOutputLocation);
38
+ if (!normalized.ok)
39
+ return { ok: false, diagnostics: [normalized.diagnostic] };
40
+ const evaluationRequestId = buildFrontendContractEvaluationRequestIdentity(input.baseline.baselineId, input.change.contractId, input.comparison.before.observationId, input.comparison.after.observationId, input.comparison.comparisonRequestId);
41
+ const evaluationId = buildFrontendContractInstanceIdentity(evaluationRequestId);
42
+ const artifact = buildFrontendContractEvaluationArtifact({
43
+ evaluationId,
44
+ evaluationRequestId,
45
+ producerVersion: getProducerInfo().version,
46
+ evaluatedAt: new Date().toISOString(),
47
+ baselineId: input.baseline.baselineId,
48
+ contractId: input.change.contractId,
49
+ before: {
50
+ observationId: input.comparison.before.observationId,
51
+ requestId: input.comparison.before.requestId,
52
+ producer: input.comparison.before.producer,
53
+ observationSchemaVersion: input.comparison.before.observationSchemaVersion,
54
+ },
55
+ after: {
56
+ observationId: input.comparison.after.observationId,
57
+ requestId: input.comparison.after.requestId,
58
+ producer: input.comparison.after.producer,
59
+ observationSchemaVersion: input.comparison.after.observationSchemaVersion,
60
+ },
61
+ comparisonId: input.comparison.comparisonId,
62
+ comparisonRequestId: input.comparison.comparisonRequestId,
63
+ overallVerdict: result.evaluation.overallVerdict,
64
+ activeBaselineClauseIds: result.evaluation.activeBaselineClauseIds,
65
+ supersededBaselineClauseIds: result.evaluation.supersededBaselineClauseIds,
66
+ clauseResults: result.evaluation.clauseResults,
67
+ unexpectedChanges: result.evaluation.unexpectedChanges,
68
+ });
69
+ const persisted = await writeFrontendContractEvaluationArtifact(artifact, normalized.value, options.cwd === undefined ? {} : { cwd: options.cwd });
70
+ if (!persisted.ok)
71
+ return { ok: false, diagnostics: persisted.diagnostics };
72
+ return {
73
+ ok: true,
74
+ evaluationId: artifact.evaluationId,
75
+ evaluationRequestId: artifact.evaluationRequestId,
76
+ overallVerdict: artifact.overallVerdict,
77
+ artifactRoot: persisted.artifactRoot,
78
+ manifestPath: persisted.manifestPath,
79
+ clauseResultCount: artifact.clauseResults.length,
80
+ unexpectedChangeCount: artifact.unexpectedChanges.length,
81
+ };
82
+ }
83
+ /**
84
+ * The canonical future-CLI-facing orchestration: reads before/after
85
+ * observations (through the existing `readObservationArtifact` reader -
86
+ * never a second observation reader), the comparison (through the new
87
+ * `readComparisonArtifact`), and the baseline/per-change contracts (through
88
+ * `frontendContractArtifactReader.ts`) by their root directories, then
89
+ * delegates to `evaluateAndPersist` exactly once. A thin wrapper only -
90
+ * reading stays owned by the artifacts layer, evaluation stays owned by
91
+ * `domain/frontendContractEvaluation.ts`, persistence stays owned by
92
+ * `artifacts/frontendContractEvaluationArtifactWriter.ts`.
93
+ */
94
+ export async function evaluateAndPersistFromArtifactRoots(beforeRoot, afterRoot, comparisonRoot, baselineRoot, changeRoot, options = {}) {
95
+ const beforeRead = await readObservationArtifact(path.join(beforeRoot, OBSERVATION_MANIFEST_FILENAME));
96
+ if (!beforeRead.ok)
97
+ return invalidRequest(`before observation artifact: ${beforeRead.reason}`);
98
+ const afterRead = await readObservationArtifact(path.join(afterRoot, OBSERVATION_MANIFEST_FILENAME));
99
+ if (!afterRead.ok)
100
+ return invalidRequest(`after observation artifact: ${afterRead.reason}`);
101
+ const comparisonRead = await readComparisonArtifact(path.join(comparisonRoot, COMPARISON_MANIFEST_FILENAME));
102
+ if (!comparisonRead.ok)
103
+ return invalidRequest(`comparison artifact: ${comparisonRead.reason}`);
104
+ const baselineRead = await readPersistentBaselineContract(path.join(baselineRoot, FRONTEND_CONTRACT_MANIFEST_FILENAME));
105
+ if (!baselineRead.ok)
106
+ return invalidRequest(`baseline contract artifact: ${baselineRead.reason}`);
107
+ const changeRead = await readPerChangeContract(path.join(changeRoot, FRONTEND_CONTRACT_MANIFEST_FILENAME));
108
+ if (!changeRead.ok)
109
+ return invalidRequest(`per-change contract artifact: ${changeRead.reason}`);
110
+ return evaluateAndPersist({ before: beforeRead.artifact, after: afterRead.artifact, comparison: comparisonRead.artifact, baseline: baselineRead.contract, change: changeRead.contract }, options);
111
+ }
112
+ //# sourceMappingURL=frontendContractEvaluationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontendContractEvaluationService.js","sourceRoot":"","sources":["../../src/application/frontendContractEvaluationService.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EAAE,uCAAuC,EAAE,MAAM,iDAAiD,CAAC;AAE1G,OAAO,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,uCAAuC,CAAC;AAE9I,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,uCAAuC,EAAE,MAAM,0DAA0D,CAAC;AAEnH,OAAO,EAAE,uBAAuB,EAAE,MAAM,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C,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAC;IACrG,IAAI,CAAC,SAAS,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,+BAA+B,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5F,MAAM,cAAc,GAAG,MAAM,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,4BAA4B,CAAC,CAAC,CAAC;IAC7G,IAAI,CAAC,cAAc,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,wBAAwB,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IAE/F,MAAM,YAAY,GAAG,MAAM,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,mCAAmC,CAAC,CAAC,CAAC;IACxH,IAAI,CAAC,YAAY,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,+BAA+B,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAElG,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,mCAAmC,CAAC,CAAC,CAAC;IAC3G,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,OAAO,cAAc,CAAC,iCAAiC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAEhG,OAAO,kBAAkB,CACvB,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,EAC7J,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { Diagnostic } from '../domain/diagnostics.js';
2
+ import type { WriteFrontendContractArtifactOptions } from '../artifacts/frontendContractArtifactWriter.js';
3
+ export interface PersistFrontendContractOptions {
4
+ outputLocation: string;
5
+ cwd?: WriteFrontendContractArtifactOptions['cwd'];
6
+ }
7
+ export type ApplicationApproveBaselineResult = {
8
+ ok: true;
9
+ baselineId: string;
10
+ supersedesBaselineId?: string;
11
+ artifactRoot: string;
12
+ manifestPath: string;
13
+ clauseCount: number;
14
+ } | {
15
+ ok: false;
16
+ diagnostics: Diagnostic[];
17
+ };
18
+ export type ApplicationPersistChangeContractResult = {
19
+ ok: true;
20
+ contractId: string;
21
+ artifactRoot: string;
22
+ manifestPath: string;
23
+ clauseCount: number;
24
+ supersedesBaselineClauseCount: number;
25
+ } | {
26
+ ok: false;
27
+ diagnostics: Diagnostic[];
28
+ };
29
+ /**
30
+ * The one canonical application-level baseline-approval use case: `approve-baseline`
31
+ * is the *only* place a baseline is ever approved (see governing scope) - this
32
+ * function is never called from `observe`/`compare`/`evaluate-contract`, and a
33
+ * `PASS` evaluation never triggers it. Validates the raw (still-`unknown`,
34
+ * freshly-parsed-JSON) baseline through the existing frozen
35
+ * `isValidPersistentBaselineContract` structural gate (never a second
36
+ * validator), reads the supplied observation through the existing
37
+ * `readObservationArtifact` reader, verifies the baseline's frozen
38
+ * `sourceObservation` reference actually corresponds to that observation's
39
+ * stable identity, and - only then - persists exactly once through the
40
+ * existing contract writer. Never mutates the observation. Never infers,
41
+ * creates, or removes `supersedesBaselineId` - whatever the caller already
42
+ * authored is preserved exactly.
43
+ */
44
+ export declare function approveAndPersistBaseline(rawContract: unknown, observationRoot: string, options: PersistFrontendContractOptions): Promise<ApplicationApproveBaselineResult>;
45
+ /**
46
+ * The one canonical application-level per-change-contract persistence use
47
+ * case (`save-change-contract`) - persistence only, never approval
48
+ * terminology or semantics. Validates the raw contract through the existing
49
+ * frozen `isValidPerChangeContract` gate (which already rejects a
50
+ * `PersistentBaselineContract` passed here, an authored `category:
51
+ * "unexpected"`, and every other structural rule - never duplicated here),
52
+ * then persists exactly once. `supersedesBaselineClauseIds` is preserved
53
+ * exactly as authored; this function performs no baseline-reference
54
+ * resolution (that remains the evaluator's responsibility).
55
+ */
56
+ export declare function persistPerChangeContract(rawContract: unknown, options: PersistFrontendContractOptions): Promise<ApplicationPersistChangeContractResult>;