@dailephd/my-frontend-observer 0.10.0 → 0.10.1
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.
- package/CHANGELOG.md +490 -479
- package/LICENSE +21 -21
- package/README.md +375 -365
- package/dist/application/projectCheckService.d.ts +6 -0
- package/dist/application/projectCheckService.js +8 -1
- package/dist/application/projectCheckService.js.map +1 -1
- package/dist/application/projectWorkflowService.d.ts +7 -2
- package/dist/application/projectWorkflowService.js +10 -3
- package/dist/application/projectWorkflowService.js.map +1 -1
- package/dist/cli.js +510 -510
- package/dist/viewer/index.html +13 -13
- package/dist/viewer/sw.js +1 -1
- package/docs/ARCHITECTURE.md +1394 -1385
- package/docs/CI_CD.md +349 -338
- package/docs/COMMANDS.md +1035 -1026
- package/docs/CONTRACTS.md +1971 -1960
- package/docs/CURRENT_STATE.md +1277 -1252
- package/docs/DEVELOPMENT.md +240 -237
- package/docs/DOCUMENTATION_PRESERVATION_POLICY.md +50 -50
- package/docs/PROJECT_DESCRIPTION.md +2248 -2224
- package/docs/PROJECT_MILESTONES.md +2681 -2558
- package/docs/PROJECT_OVERVIEW.md +200 -196
- package/docs/QUICKSTART.md +100 -100
- package/docs/RELEASE.md +37 -36
- package/docs/ROADMAP.md +1105 -1034
- package/docs/SECURITY.md +297 -297
- package/docs/WORKFLOWS.md +806 -796
- package/docs/plans/v0.10-implementation-plan.md +1509 -1509
- package/docs/plans/v0.8-implementation-plan.md +655 -655
- package/docs/plans/v0.8.1-cli-usability-patch-plan.md +505 -505
- package/docs/plans/v0.9-implementation-plan.md +1529 -1529
- package/docs/plans/v0.9.1-implementation-plan.md +468 -468
- package/docs/reports/v0.10-batch1-visual-change-workflow-foundation.md +102 -102
- package/docs/reports/v0.10-batch2-project-composition-check-recording.md +103 -103
- package/docs/reports/v0.10-batch3-viewer-visual-change-workspace.md +93 -93
- package/docs/reports/v0.10-batch4-actual-frontend-entry.md +59 -59
- package/docs/reports/v0.10-batch5-reference-driven-entry.md +238 -238
- package/docs/reports/v0.10-batch6-coding-agent-handoff.md +85 -85
- package/docs/reports/v0.10-batch7-correction-review-acceptance.md +145 -145
- package/docs/reports/v0.10-batch8-integrated-acceptance.md +109 -109
- package/docs/reports/v0.10-implementation-completeness-documentation-reconciliation.md +344 -344
- package/docs/reports/v0.10-pre-release-readiness.md +120 -120
- package/docs/reports/v0.10-release-preparation.md +70 -70
- package/docs/reports/v0.10.1-project-check-baseline-context-implementation.md +86 -0
- package/docs/reports/v0.7-bounded-fidelity-context-prompt7.md +243 -243
- package/docs/reports/v0.7-implementation-completeness-documentation-reconciliation.md +497 -497
- package/docs/reports/v0.7-pre-release-readiness.md +337 -337
- package/docs/reports/v0.7-reference-binding-prompt5.md +223 -223
- package/docs/reports/v0.7-reference-compatibility-prompt4.md +234 -234
- package/docs/reports/v0.7-reference-correction-workflow-prompt8.md +222 -222
- package/docs/reports/v0.7-reference-fidelity-prompt6.md +216 -216
- package/docs/reports/v0.7-reference-foundation-prompt1.md +151 -151
- package/docs/reports/v0.7-reference-regions-prompt2.md +195 -195
- package/docs/reports/v0.7-reference-requirements-prompt3.md +217 -217
- package/docs/reports/v0.7-release-prep.md +423 -423
- package/docs/reports/v0.8-binding-fidelity-interaction-batch6.md +279 -279
- package/docs/reports/v0.8-bounded-context-correlation-batch7.md +233 -233
- package/docs/reports/v0.8-comparison-contract-inspection-batch4.md +279 -279
- package/docs/reports/v0.8-evidence-index-readers-batch2.md +247 -247
- package/docs/reports/v0.8-implementation-completeness-documentation-reconciliation.md +741 -741
- package/docs/reports/v0.8-integrated-viewer-acceptance-batch8.md +128 -128
- package/docs/reports/v0.8-observation-svg-inspection-batch3.md +223 -223
- package/docs/reports/v0.8-prerelease-readiness-cross-platform-security-code-rot.md +687 -687
- package/docs/reports/v0.8-reference-candidate-inspection-batch5.md +232 -232
- package/docs/reports/v0.8-viewer-runtime-pwa-batch1.md +278 -278
- package/docs/reports/v0.8.1-implementation-completeness-documentation-reconciliation.md +114 -114
- package/docs/reports/v0.8.1-prerelease-readiness-cross-platform-security-code-rot.md +170 -170
- package/docs/reports/v0.9-architecture-retrieval.md +14 -37
- package/docs/reports/v0.9-final-pre-release-readiness.md +209 -209
- package/docs/reports/v0.9-final-readiness-corrections.md +530 -530
- package/docs/reports/v0.9-pre-release-readiness.md +169 -169
- package/docs/reports/v0.9.1-batch1-pwa-hard-gate-isolation.md +359 -359
- package/docs/reports/v0.9.1-batch2-hard-gate-validation-integration.md +262 -262
- package/docs/reports/v0.9.1-pre-release-readiness.md +206 -206
- package/package.json +59 -59
|
@@ -1,217 +1,217 @@
|
|
|
1
|
-
# v0.7 Prompt 3 — Selected Design Requirements, Tolerance Semantics, and Reference-Evidence Adequacy
|
|
2
|
-
|
|
3
|
-
## 1. Verdict
|
|
4
|
-
|
|
5
|
-
**PASS_V0_7_REFERENCE_REQUIREMENTS_PROMPT3**
|
|
6
|
-
|
|
7
|
-
## 2. Repository
|
|
8
|
-
|
|
9
|
-
`Z:\Users\newuser\Projects\my-frontend-observer` (`https://github.com/dailephd/my-frontend-observer.git`)
|
|
10
|
-
|
|
11
|
-
## 3. Branch
|
|
12
|
-
|
|
13
|
-
`implementation/v0.7-reference-requirements`
|
|
14
|
-
|
|
15
|
-
## 4. Starting head
|
|
16
|
-
|
|
17
|
-
`3a4a2e3b2968b5788e6f3b11a3cda6d83053d9cb`
|
|
18
|
-
|
|
19
|
-
## 5. Prompt 2 base head
|
|
20
|
-
|
|
21
|
-
`3a4a2e3b2968b5788e6f3b11a3cda6d83053d9cb` (same commit — the branch was created directly from Prompt 2's completed, clean state; verified as an ancestor via `git merge-base --is-ancestor` for both `c5c2eef` and `3a4a2e3`)
|
|
22
|
-
|
|
23
|
-
## 6. Ending head
|
|
24
|
-
|
|
25
|
-
`4d7bd610d8b3ca8ed6e228eee39e08003c21161c` (implementation commit; the report commit that follows this file's own commit will be one ahead of this)
|
|
26
|
-
|
|
27
|
-
## 7. Git status
|
|
28
|
-
|
|
29
|
-
Clean at the ending head. The Prompt 1 speculative-write stash (`stray-fork-writes-preserved-for-reference: ...`) remains present, untouched, unapplied, unmined, verified via `git stash list` at both the start and end of this stage.
|
|
30
|
-
|
|
31
|
-
## 8. Resolved my-dev-kit version
|
|
32
|
-
|
|
33
|
-
`@dailephd/my-dev-kit@1.12.3` (re-checked via `npm view @dailephd/my-dev-kit version` at execution start — unchanged from Prompt 1/2, still latest)
|
|
34
|
-
|
|
35
|
-
## 9. Fresh index path / ID
|
|
36
|
-
|
|
37
|
-
`.my-dev-kit/index-prompt3` — a fresh index built this stage (`my-dev-kit index --root . --src src --out .my-dev-kit/index-prompt3 --call-graph --json`), independent of the Prompt 1/2 indexes. Gitignored, never staged.
|
|
38
|
-
|
|
39
|
-
## 10. Previous contract verification
|
|
40
|
-
|
|
41
|
-
Read directly from the maintained repository before any change:
|
|
42
|
-
|
|
43
|
-
- `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (imported/approved variants), `isValidExternalReferenceArtifact`, the `regions?` field and its validation wiring (Prompt 2).
|
|
44
|
-
- `src/domain/externalReferenceRegions.ts` — `ReferenceRegion`, `ReferenceRegionGeometry`, `deriveReferenceRegionGeometry`, `isValidReferenceRegions`, `MAX_REFERENCE_REGIONS`, `REFERENCE_REGION_ID_PATTERN`.
|
|
45
|
-
- `src/domain/externalReferenceRegionRelationships.ts` — `deriveReferenceRegionRelationships`, `ReferenceRegionRelationship`, bound constants.
|
|
46
|
-
- `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`'s existing `regions` backward-compatible-omission pattern (directly extended, not redesigned).
|
|
47
|
-
- `src/application/externalReferencePersistenceService.ts` — `importExternalReference`/`approveExternalReference`'s existing region-handling shape.
|
|
48
|
-
- `src/cli.ts` — `import-reference`/`approve-reference`'s existing `--regions-file` handling and `loadRegionsFile` pattern.
|
|
49
|
-
- The full Prompt 1/2 test suite (719 tests at the time), confirmed green before touching anything.
|
|
50
|
-
|
|
51
|
-
Prompt 1/2 reports and current source matched exactly — no `BLOCKED_PREVIOUS_PROMPT_REPORT_MISMATCH` condition was encountered.
|
|
52
|
-
|
|
53
|
-
## 11. v0.5 precedent review
|
|
54
|
-
|
|
55
|
-
- **Exact category types inspected**: `src/domain/frontendContracts.ts` — `AUTHORED_CHANGE_SCOPE_CATEGORIES`/`AuthoredChangeScopeCategory`/`isAuthoredChangeScopeCategory` (`requested`/`expected-dependent`/`protected`/`preserved`; `'unexpected'` is a separate, derived-only `CHANGE_SCOPE_CLASSIFICATIONS` member, never authorable), `EXPECTED_DEPENDENT_MODES`/`ExpectedDependentMode`/`isValidExpectedDependentMode` (`required`/`permitted`).
|
|
56
|
-
- **Contract primitive witnesses**: `ContractPrimitive`'s closed vocabulary and `hasOnlyKeys` discipline (structural style precedent, not directly reused — Prompt 3's subjects are a different, reference-specific shape).
|
|
57
|
-
- **Tolerance witnesses**: `ContractTolerance` (`exact`/`absolute-px`/`percent`) and its bounds (`CONTRACT_TOLERANCE_ABSOLUTE_PX_MIN/MAX` = 0/100, `_PERCENT_MIN/MAX` = 0/100), and `frontendContractEvaluation.ts#toleranceToPx`'s "percent denominator is the before-value" convention.
|
|
58
|
-
- **Conflict semantics inspected**: `frontendContractEvaluation.ts#primitivesConflict`/`evaluateFrontendContract`'s per-clause conflict detection — confirmed this runs at **runtime evaluation time** against actual before/after `ObservationArtifact` evidence (`toClauseResult`, `EvalContext`), not at authoring time.
|
|
59
|
-
- **What was reused**: `AuthoredChangeScopeCategory`/`AUTHORED_CHANGE_SCOPE_CATEGORIES`/`isAuthoredChangeScopeCategory` and `ExpectedDependentMode`/`EXPECTED_DEPENDENT_MODES`/`isValidExpectedDependentMode` are imported **directly** from `frontendContracts.ts` (zero duplication) — these types carry no runtime-only coupling in their own definition, so direct reuse was safe and correct. The `CONTRACT_TOLERANCE_*` numeric bound *values* (0–100 for both absolute and percent) were mirrored as independently-owned constants.
|
|
60
|
-
- **What was not reused, and why**:
|
|
61
|
-
- `ContractTolerance` was **not** reused as a type — its `absolute-px` member is implicitly runtime/CSS pixels (compared against live `TargetGeometry`); reusing it for reference-image pixels would silently mislabel the unit, which request section 20 explicitly forbids. A new `ReferenceRequirementTolerance` type was introduced instead, with the same numeric bounds but an explicitly-named `absolute-reference-px` kind.
|
|
62
|
-
- `primitivesConflict`/the whole runtime conflict-detection pass was **not** reused — it operates over before/after `ObservationArtifact` evidence that does not exist at this authoring-time stage. Prompt 3 instead restricts invalid combinations directly: no two requirements in a collection may share the same structural subject, regardless of category (see section 25).
|
|
63
|
-
|
|
64
|
-
## 12. v0.6 adequacy precedent review
|
|
65
|
-
|
|
66
|
-
- **Exact types/functions inspected**: `src/domain/boundedAgentContext.ts` — `Adequacy { state; reasons }`, `AdequacyState` (`adequate`/`partial`/`inadequate`), `ADEQUACY_REASON_CODES` (`required-runtime-target-unavailable`, `static-correlation-ambiguous`, `consumer-incompatibility`, etc.), `isValidAdequacy`.
|
|
67
|
-
- **Whether the `Adequacy` type was reused**: no.
|
|
68
|
-
- **Whether a separate reason family was introduced**: yes — `REFERENCE_REQUIREMENT_ADEQUACY_STATES` (a freshly-declared, textually-identical three-value vocabulary: `adequate`/`partial`/`inadequate`) and `REFERENCE_REQUIREMENT_ADEQUACY_REASON_CODES` (exactly two codes: `no-selected-requirements`, `missing-reference-relationship-evidence`), both owned by `externalReferenceRequirements.ts`.
|
|
69
|
-
- **Why**: `boundedAgentContext.ts`'s reason codes describe runtime-target availability and static-correlation ambiguity — concerns that do not exist at this stage (there is no runtime target, no candidate, no static correlation yet). Reusing that exact reason-code union would either force nonsensical codes onto reference-side adequacy or silently expand a runtime-specific vocabulary to mean something unrelated - both violate the explicit "must not mislabel reference adequacy as bounded-agent-context adequacy" requirement. The three-state *shape* (`adequate`/`partial`/`inadequate`) is coincidentally identical text but is an independently-declared constant in the reference module, following this repository's established convention of duplicating small shared vocabularies per family (e.g. `canonicalize()` duplicated five times) rather than cross-importing between otherwise-unrelated domains.
|
|
70
|
-
|
|
71
|
-
## 13. Requirement model
|
|
72
|
-
|
|
73
|
-
- **Actual type names**: `ExternalReferenceRequirement`, `RawReferenceRequirement` (unidentified authored input), `ReferenceRequirementSubject` (`RegionPropertyRequirementSubject | RegionRelationshipRequirementSubject | RegionMeasurementRequirementSubject`), all in `src/domain/externalReferenceRequirements.ts`.
|
|
74
|
-
- **Requirement ID semantics**: `requirementId` is **always system-computed** via `buildReferenceRequirementIdentity(subject, category, tolerance, expectedDependentMode)` (`src/domain/externalReferenceRequirementIdentity.ts`, mirroring `frontendContractIdentity.ts#buildClauseIdentity`'s exact canonicalize+sha256 shape). Authoring a `requirementId` in raw input is a validation error (`isValidRawReferenceRequirement` rejects it) — deliberately different from v0.5's `clauseId` (which authors do supply, because clauses need a cross-document-reference id for `supersedesBaselineClauseIds`; requirements have no equivalent need yet).
|
|
75
|
-
- **Category semantics**: exactly v0.5's `AuthoredChangeScopeCategory`, imported directly. `expectedDependentMode` required iff category is `expected-dependent`, forbidden otherwise (identical shape to `isValidPerChangeClause`'s rule).
|
|
76
|
-
- **Supported subjects**: `region-property` (one region + `ReferenceRequirementRegionProperty`), `region-relationship` (two regions + `PairwiseRelationshipKind`, reused from `relationships.ts`, geometry-only families only), `region-measurement` (two regions + `ReferenceRequirementMeasurement`).
|
|
77
|
-
- **Supported properties**: `REFERENCE_REQUIREMENT_REGION_PROPERTIES = ['x','y','width','height','right','bottom','centerX','centerY']` — exactly `ReferenceRegionGeometry`'s own fields, nothing invented (no separate `left`/`top` aliases).
|
|
78
|
-
- **Relationship/measurement requirements**: relationship subjects reuse Prompt 2's `PairwiseRelationshipKind` vocabulary directly (no tolerance permitted — a categorical fact). Measurement subjects use one of six pure derived measurements: `vertical-gap`, `horizontal-gap`, `center-x-delta`, `center-y-delta`, `left-edge-delta`, `right-edge-delta` (a tolerance is required).
|
|
79
|
-
- **Bounds**: `MAX_REFERENCE_REQUIREMENTS = 50` per artifact — a maximum capacity, never a required minimum; no per-region sub-cap was added (the overall bound plus the duplicate-subject rule already bounds practical growth well within it).
|
|
80
|
-
|
|
81
|
-
## 14. Tolerance model
|
|
82
|
-
|
|
83
|
-
- **Exact tolerance kinds**: `ReferenceRequirementTolerance = { kind: 'exact' } | { kind: 'absolute-reference-px'; amount } | { kind: 'percent'; amount }`.
|
|
84
|
-
- **Units**: `absolute-reference-px` is explicitly reference-image pixels, never silently treated as CSS/runtime pixels — no scale/compatibility mapping exists yet (deferred to Prompt 6, per request section 20).
|
|
85
|
-
- **Bounds**: `REFERENCE_REQUIREMENT_TOLERANCE_ABSOLUTE_PX_MIN/MAX = 0/100`, `_PERCENT_MIN/MAX = 0/100` — same numeric values as v0.5's `CONTRACT_TOLERANCE_*` constants, independently owned (not imported) for the unit-labeling reason above.
|
|
86
|
-
- **Validation**: negative, non-finite, and unsupported-kind tolerances fail closed (`isValidReferenceRequirementTolerance`); an `exact` tolerance permits no `amount` field at all.
|
|
87
|
-
- **Relationship vs numeric applicability**: `region-relationship` subjects must **not** carry a tolerance (categorical fact); `region-property`/`region-measurement` subjects **must** carry one — enforced explicitly, in both directions, by `validateAuthoredRequirementFields`.
|
|
88
|
-
- **Reuse of v0.5**: numeric bounds mirrored (see section 11); the type itself is a fresh, reference-owned type, not a v0.5 reuse (see section 11's rationale).
|
|
89
|
-
|
|
90
|
-
## 15. Reference expectation derivation
|
|
91
|
-
|
|
92
|
-
Nothing is stored beyond `{subject, category, expectedDependentMode?, tolerance?}` per requirement — no numeric expected value (e.g. `width: 424`) and no relationship-match boolean are ever persisted. `deriveReferenceRequirementExpectation(subject, regions, options)` is a pure function computing, on demand:
|
|
93
|
-
|
|
94
|
-
- for `region-property`: the named region's `ReferenceRegionGeometry[property]`, freshly derived from its canonical rectangle every call;
|
|
95
|
-
- for `region-measurement`: the named pure measurement over the two regions' derived geometries;
|
|
96
|
-
- for `region-relationship`: whether the reference actually exhibits the claimed relationship, by deriving the region pair's relationships via `deriveReferenceRegionRelationships` and checking within the **correct relationship family** (a bug caught and fixed during test-writing — see section 20) for a match in either declared or geometry-determined order (only `follows-vertically` can differ from declared order, since it is the one family whose direction depends on actual geometry rather than input order).
|
|
97
|
-
|
|
98
|
-
This directly satisfies the "avoid redundant storage, derive from canonical geometry" instruction — there is no possibility of a stored expected value drifting from the region it describes, because none is ever stored.
|
|
99
|
-
|
|
100
|
-
## 16. Adequacy model
|
|
101
|
-
|
|
102
|
-
- **Status vocabulary**: `REFERENCE_REQUIREMENT_ADEQUACY_STATES = ['adequate', 'partial', 'inadequate']`.
|
|
103
|
-
- **Reason codes**: exactly two — `no-selected-requirements`, `missing-reference-relationship-evidence`. No other reason code exists because no other condition is possible: an unknown region id, unsupported property, or malformed requirement is a **construction-time validation failure** (`isValidReferenceRequirements`) that never reaches adequacy computation at all.
|
|
104
|
-
- **Zero-requirement behavior**: explicitly `inadequate`, with a `no-selected-requirements` reason — a documented product decision (request section 24F): a region-rich, fully-valid reference is still not usable for a correction task until the user has actually selected what matters.
|
|
105
|
-
- **Missing-region behavior**: not an adequacy concern — rejected at validation time before adequacy ever runs (see section 11's "what was not reused" discussion of the D behavior choice: "authored reference requirement pointing to a nonexistent authored region should fail validation rather than become normal unavailable evidence").
|
|
106
|
-
- **Missing-relationship-evidence behavior**: a structurally-valid `region-relationship`/`region-measurement` requirement whose claimed evidence cannot actually be derived from the geometry (wrong relationship, or a measurement that is geometrically undefined, e.g. `vertical-gap` between overlapping regions) is reported `missing-reference-relationship-evidence`, contributing to a `partial` or `inadequate` overall status.
|
|
107
|
-
- **Deterministic ordering**: reasons are pushed in authored-requirement-array order, never object-key or Set-iteration order — verified by test.
|
|
108
|
-
- **Blocking intent for later stages**: `ReferenceRequirementAdequacy` is returned by both `importExternalReference`/`approveExternalReference` and printed by the CLI (`Adequacy: <status>`) so a later orchestration stage can enforce "inadequate reference → do not begin correction" without Prompt 3 itself running any coding-agent workflow.
|
|
109
|
-
|
|
110
|
-
## 17. Identity
|
|
111
|
-
|
|
112
|
-
- `buildExternalReferenceRequestIdentity` gained one additional optional trailing parameter, `requirements?: readonly ExternalReferenceRequirement[]`, following the exact `regions` precedent: omitted from the hashed semantic view entirely (never defaulted to `null`) when absent, so every Prompt 1/2 call site — and every Prompt 3 call with no requirements — produces a byte-identical hash to before this parameter existed (verified by test: `'omitting requirements produces the exact same identity as before this parameter existed'`).
|
|
113
|
-
- Path independence: the function still takes no path argument of any kind; this holds by construction, not merely by test.
|
|
114
|
-
- Content participation: verified by test that changing a requirement's category, adding, or removing a requirement each changes the artifact-level `referenceRequestId`. Each requirement's own `requirementId` additionally changes with its subject/category/mode/tolerance (tested directly in `externalReferenceRequirementIdentity.test.ts`), so a change to any requirement changes both that requirement's own id and the artifact-level identity.
|
|
115
|
-
|
|
116
|
-
## 18. Artifact / schema decision
|
|
117
|
-
|
|
118
|
-
- Requirements live as an additive, optional `requirements?: ExternalReferenceRequirement[]` field directly on `ExternalReferenceArtifactBase` (both `ImportedExternalReferenceArtifact` and `ApprovedExternalReferenceArtifact` inherit it) — the same minimal-extension shape as Prompt 2's `regions`, not a separate derived artifact family (no new persisted artifact kind was introduced).
|
|
119
|
-
- **No schema version bump** — `EXTERNAL_REFERENCE_SCHEMA_VERSION` remains `'1.0.0'`, for the identical reasoning already established in the Prompt 2 report: the field is genuinely optional/additive, and this repository's `isValid*Artifact` convention performs a strict version-equality check, so bumping would make every Prompt 1/2 artifact fail validation under the current reader — directly contradicting the explicit "legacy artifacts remain valid" requirement.
|
|
120
|
-
- **Historical artifact compatibility**: verified by test (`'U: a legacy (Prompt 1/2) artifact with no requirements field at all remains valid'`) that an artifact predating this field validates successfully.
|
|
121
|
-
- **Immutable approved-reference handling**: `approveExternalReference` copies `imported.requirements` into a **new** artifact object (fresh `referenceId`, same `referenceRequestId`) — it never reopens or rewrites the imported artifact's own manifest file. Verified by test that an approved artifact's manifest is byte-for-byte unchanged after later, unrelated import/approve activity in the same output directory (reusing the exact test already established in Prompt 2 for this purpose, now also covering requirements).
|
|
122
|
-
|
|
123
|
-
## 19. Public interface
|
|
124
|
-
|
|
125
|
-
- **CLI changes**: `import-reference` gained an optional `--requirements-file <json-file>` (root shape `{ "requirements": [...] }`, validated by a new `loadRequirementsFile` mirroring `loadRegionsFile` exactly — object root, exact allow-listed top-level field). Both `import-reference` and `approve-reference` now additionally print `Requirements: <count>` and `Adequacy: <status>` lines. No existing flag, argument, help text section, or exit code changed in meaning.
|
|
126
|
-
- **Input file shape**: `{ "requirements": [ { "category": "requested", "subject": { "kind": "region-property", "region": "current-page-card", "property": "width" }, "tolerance": { "kind": "absolute-reference-px", "amount": 4 } } ] }` — chosen directly from the `--regions-file`/`--targets-file` object-root-wrapper precedent, not the prompt's illustrative example verbatim. No `requirementId` field is accepted in this file (system-computed).
|
|
127
|
-
- **Programmatic export changes**: `src/index.ts` additively exports the complete new requirement/tolerance/adequacy type, constant, and function surface (`ExternalReferenceRequirement`, `RawReferenceRequirement`, `ReferenceRequirementSubject` variants, `ReferenceRequirementTolerance`, `ReferenceRequirementAdequacy`, `deriveReferenceRequirementExpectation`, `deriveReferenceRequirementAdequacy`, `buildReferenceRequirement`, `isValidRawReferenceRequirement`, `isValidReferenceRequirements`, plus bound/vocabulary constants). `AuthoredChangeScopeCategory`/`ExpectedDependentMode` and their constants are **not** re-exported a second time from the new module (they were already exported from `frontendContracts.js` — re-exporting would have been a duplicate-name compile error, caught and fixed during implementation). `ImportExternalReferenceOptions` gained an additive `requirements?` field; both application-result types gained additive `requirementCount: number` and `adequacy: ReferenceRequirementAdequacy` fields.
|
|
128
|
-
- **Backward compatibility**: every Prompt 1/2 CLI invocation and every existing result-consumer reading the pre-existing fields continues to work unchanged — verified by the full pre-existing suite passing unmodified, plus dedicated tests confirming a requirements-less import reports `requirementCount: 0`, `adequacy.status: 'inadequate'`, and no `requirements` key on the manifest.
|
|
129
|
-
|
|
130
|
-
## 20. Files changed
|
|
131
|
-
|
|
132
|
-
Modified: `docs/ARCHITECTURE.md`, `docs/CONTRACTS.md`, `docs/CURRENT_STATE.md`, `docs/WORKFLOWS.md`, `src/application/externalReferencePersistenceService.ts`, `src/cli.ts`, `src/domain/diagnostics.ts`, `src/domain/externalReference.ts`, `src/domain/externalReferenceIdentity.ts`, `src/index.ts`, `tests/unit/cliExternalReference.test.ts`, `tests/unit/externalReference.test.ts`, `tests/unit/externalReferenceIdentity.test.ts`, `tests/unit/externalReferencePersistenceService.test.ts`.
|
|
133
|
-
New: `src/domain/externalReferenceRequirements.ts`, `src/domain/externalReferenceRequirementIdentity.ts`, `tests/unit/externalReferenceRequirements.test.ts`, `tests/unit/externalReferenceRequirementIdentity.test.ts`.
|
|
134
|
-
|
|
135
|
-
`src/domain/relationships.ts` was **not** modified this stage (its Prompt 2 additive exports were reused as-is, imported alongside three additional pre-existing family-constant exports `HORIZONTAL_ORDER_RELATIONSHIPS`/`VERTICAL_ORDER_RELATIONSHIPS`/etc. that were already exported).
|
|
136
|
-
|
|
137
|
-
## 21. Tests added / changed
|
|
138
|
-
|
|
139
|
-
60 new tests across 2 new files and additions to 4 existing files (0 pre-existing test modified or removed):
|
|
140
|
-
|
|
141
|
-
- `externalReferenceRequirementIdentity.test.ts` (6 tests): content-determinism, subject/category/tolerance/mode sensitivity, call-site independence.
|
|
142
|
-
- `externalReferenceRequirements.test.ts` (35 tests): all four categories valid, authored `unexpected` rejected, mode required/forbidden correctly, authored `requirementId` rejected, all three subject kinds valid/invalid (including unsupported property/measurement/relationship), tolerance-applicability-by-subject-kind, unknown-region-id rejection, duplicate/conflicting-subject rejection (including relationship-subject order-independence), requirement-limit exact-max/one-over, exact/absolute/percent tolerance boundaries, negative/non-finite/unsupported-kind tolerance rejection, all six measurement derivations (including overlap-undefined cases), reference-expectation derivation for all three subject kinds (including the family-lookup bug fix - see section 20), zero/all/some-unavailable adequacy states, deterministic reason ordering, no-numeric-score assertion, immutability.
|
|
143
|
-
- `externalReferenceIdentity.test.ts` (+5 tests): requirements-omission backward compatibility, same-content-same-identity, category-change/add/remove-changes-identity.
|
|
144
|
-
- `externalReference.test.ts` (+6 tests): legacy-no-requirements validity, valid requirements on both lifecycle variants, unknown-region rejection, regions-absent rejection, malformed-value rejection.
|
|
145
|
-
- `externalReferencePersistenceService.test.ts` (+5 tests): import-with-requirements persists them and reports adequacy, regionless/requirement-less import reports zero/inadequate, unknown-region import rejection (nothing persisted), authored-id rejection, approval carries requirements forward with matching adequacy.
|
|
146
|
-
- `cliExternalReference.test.ts` (+5 tests): end-to-end `--requirements-file` import+approve with adequacy reporting, legacy no-flag invocation reports zero/inadequate, unknown-region CLI rejection, malformed-`--requirements-file` rejection (bad JSON, array root, unknown field).
|
|
147
|
-
|
|
148
|
-
## 22. Validation results
|
|
149
|
-
|
|
150
|
-
All on the ending commit (`4d7bd61`) on `implementation/v0.7-reference-requirements`:
|
|
151
|
-
|
|
152
|
-
| Command | Result |
|
|
153
|
-
|---|---|
|
|
154
|
-
| `npm run typecheck` | PASS |
|
|
155
|
-
| `npm run lint` | PASS (one `no-unused-vars` finding during development, fixed before commit) |
|
|
156
|
-
| `npm test` | PASS — 42 files, 779 tests (up from 40/719) |
|
|
157
|
-
| `npm run build` | PASS (both new modules compiled into `dist/`) |
|
|
158
|
-
| `npm run check:docs` | PASS (17 required files) |
|
|
159
|
-
| `git diff --check` | PASS |
|
|
160
|
-
| `npm pack --dry-run` | PASS (173 files, 330.5 kB / 1.4 MB unpacked; both new modules present in the tarball listing) |
|
|
161
|
-
| `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count) |
|
|
162
|
-
| `npm run test:security` | PASS — 68 tests |
|
|
163
|
-
|
|
164
|
-
## 23. Regression results
|
|
165
|
-
|
|
166
|
-
- **Prompt 1 tests**: all pre-existing `externalReference*`/`cliExternalReference` tests pass unmodified.
|
|
167
|
-
- **Prompt 2 tests**: `externalReferenceRegions.test.ts`, `externalReferenceRegionRelationships.test.ts` pass unmodified.
|
|
168
|
-
- **v0.5 dependent tests**: `frontendContracts.test.ts`, `frontendContractEvaluation.test.ts`, `frontendContractPersistence.test.ts` explicitly re-run — 207 combined tests (with `boundedAgentContext.test.ts`, `boundedAgentContextProjection.test.ts`, `relationships.test.ts`, `relationshipDerivation.test.ts`) pass unchanged. `frontendContracts.ts` itself was not modified at all (only imported from, read-only).
|
|
169
|
-
- **v0.6 tests**: `boundedAgentContext*.test.ts` (4 files) pass unchanged; `boundedAgentContext.ts` was not modified (only inspected for precedent, never imported from — see section 12).
|
|
170
|
-
|
|
171
|
-
## 24. Boundedness
|
|
172
|
-
|
|
173
|
-
- **Requirement bound**: `MAX_REFERENCE_REQUIREMENTS = 50` per artifact — explicit, tested at exactly-max (accepted) and one-over (rejected, no partial acceptance).
|
|
174
|
-
- No separate per-region requirement cap was added; the overall bound plus the duplicate-subject rule already bounds practical per-region growth (at most one requirement per distinct property/relationship/measurement combination can exist at all, well within 50 even for the maximum 20-region case).
|
|
175
|
-
|
|
176
|
-
## 25. Conflict handling
|
|
177
|
-
|
|
178
|
-
v0.5's `primitivesConflict`/`evaluateFrontendContract` conflict detection is a **runtime-evaluation-time** mechanism requiring before/after `ObservationArtifact` evidence that does not exist at requirement-authoring time — it was not reused, per request section 45's explicit permission to restrict invalid combinations instead when v0.5 semantics cannot be safely reused. Prompt 3's chosen rule: **no two requirements in one collection may share the same structural subject**, regardless of category (`sameSubject()` in `externalReferenceRequirements.ts`, with relationship/measurement subjects treated as the same regardless of which region is declared first). This single rule resolves both the "duplicate requirement" and "conflicting categories on the same subject" behavior-model questions with one mechanism, is fully deterministic, and is enforced at collection-validation time (`isValidReferenceRequirements`) — never silently choosing one requirement over another.
|
|
179
|
-
|
|
180
|
-
## 26. Security / privacy impact
|
|
181
|
-
|
|
182
|
-
No new network calls, no vision/AI API calls. `--requirements-file`'s path is never persisted or included in any identity, matching `--regions-file`/`--targets-file`/`--contract-file` convention exactly. Requirement content is plain structured data (category strings, region-id references, numeric tolerances) with no new file-system write boundary — requirements are embedded directly in the existing `manifest.json`. The unsupported-top-level-field rejection on `--requirements-file`'s root prevents silently ignored/misinterpreted malformed input, matching the existing `--regions-file` convention.
|
|
183
|
-
|
|
184
|
-
## 27. Documentation changes
|
|
185
|
-
|
|
186
|
-
Additive sections only: `docs/CONTRACTS.md` ("v0.7 Prompt 3 selected design requirements, tolerance semantics, and reference-evidence adequacy" — the primary contract reference), `docs/ARCHITECTURE.md` (relationship of the new requirement/adequacy modules to v0.5/v0.6 precedent and to Prompt 1/2), `docs/CURRENT_STATE.md` ("v0.7 Prompt 3 status" section, plus updated "Not implemented"/"Next target"), `docs/WORKFLOWS.md` (the extended import/approve workflow diagram, the new requirement/adequacy description, and a correction to the "Planned v0.7 reference-driven correction flow" marking requirements/tolerances/adequacy as now implemented). `docs/ROADMAP.md` was **not** touched. `docs/COMMANDS.md` was **not** touched, consistent with Prompt 1/2's own precedent of not documenting `import-reference`/`approve-reference` there.
|
|
187
|
-
|
|
188
|
-
## 28. Tooling incidents
|
|
189
|
-
|
|
190
|
-
None this stage. No background/subagent write occurred during Prompt 3's implementation - all work was performed directly in the main session, per the stricter no-background-speculative-writes instruction carried forward from Prompt 2. The Prompt 1 speculative-write incident remains historical; its stash was confirmed untouched at both the start and end of this stage.
|
|
191
|
-
|
|
192
|
-
## 29. Inherited orchestrator heuristic issue
|
|
193
|
-
|
|
194
|
-
Not encountered as a product problem this stage. `my-dev-kit-orchestrator` was not modified, no test was rewritten to satisfy its responsibility-mapping heuristic, and no fake evidence tags were added. This stage used `DIRECT_IMPLEMENTATION` without invoking the orchestrator's stage-context workflow at all, so the heuristic gap noted in Prompt 1 did not arise here (consistent with Prompt 2).
|
|
195
|
-
|
|
196
|
-
## 30. Out-of-scope confirmation
|
|
197
|
-
|
|
198
|
-
This stage did **not** implement: theme identity evaluation, application-state compatibility, viewport compatibility evaluation, reference/candidate comparability, reference-region↔runtime-target binding, runtime target identity in requirement subjects, candidate observation lookup or geometry, reference-vs-candidate delta, fidelity PASS/FAIL, style/color/typography/pixel/image-similarity comparison, visual score, source correlation changes, bounded correction packets, v0.6 agent-context extension, coding-agent invocation, source editing, rerender orchestration, correction iteration, the viewer, annotation, automatic requirement inference, or automatic region detection. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not yet implemented" documentation comments) and by direct code inspection: `ReferenceRequirementSubject` and `ReferenceRequirementAdequacy` contain no runtime-target/candidate/binding field of any kind, not even as a placeholder.
|
|
199
|
-
|
|
200
|
-
## 31. Known limitations
|
|
201
|
-
|
|
202
|
-
1. No fuzz-testing of adversarial requirement JSON beyond the specific malformed-shape cases already covered (bad JSON, array root, unknown field, non-object entry, unsupported property/measurement/relationship) — consistent with Prompt 1/2's own documented fuzz-testing scope boundary.
|
|
203
|
-
2. The `region-relationship` reference-expectation lookup can report "opposite region order" unavailability for the one family (`follows-vertically`) whose direction is decided by geometry rather than authored order; a user must author `subjectRegion`/`relatedRegion` matching the geometrically-determined direction to get a `matches: true/false` result for that specific family. This is documented behavior (see section 15), not a defect, but is a rough edge a future prompt's UI/authoring tooling should smooth over (e.g. by trying both orders automatically) rather than something Prompt 3 should paper over silently now.
|
|
204
|
-
3. `MAX_REFERENCE_REQUIREMENTS = 50` has no cited external precedent value (unlike `MAX_REFERENCE_REGIONS`, which coincidentally matches `MAX_TARGETS`) — it is a reasonable, documented, but ultimately judgment-call bound.
|
|
205
|
-
|
|
206
|
-
## 32. Remaining risks
|
|
207
|
-
|
|
208
|
-
- Because reference expectations and adequacy are never persisted, every future consumer (Prompt 4+) that needs them must call `deriveReferenceRequirementExpectation`/`deriveReferenceRequirementAdequacy` itself. This mirrors Prompt 2's relationship-derivation design deliberately (avoids drift) and should not be "fixed" by prematurely adding persistence.
|
|
209
|
-
- The duplicate-subject conflict rule is stricter than v0.5's category-aware conflict model (it rejects same-subject-different-category outright rather than trying to reconcile them). If a future prompt determines users genuinely need e.g. a `requested` and a `protected` requirement coexisting on the same subject for some legitimate reason, that will require a deliberate architecture revisit, not a quiet loosening of this rule.
|
|
210
|
-
|
|
211
|
-
## 33. Exact next action
|
|
212
|
-
|
|
213
|
-
**v0.7 Prompt 4** — reference applicability/state compatibility and comparability foundation.
|
|
214
|
-
|
|
215
|
-
## 34. Report path
|
|
216
|
-
|
|
217
|
-
`docs/reports/v0.7-reference-requirements-prompt3.md` (this file)
|
|
1
|
+
# v0.7 Prompt 3 — Selected Design Requirements, Tolerance Semantics, and Reference-Evidence Adequacy
|
|
2
|
+
|
|
3
|
+
## 1. Verdict
|
|
4
|
+
|
|
5
|
+
**PASS_V0_7_REFERENCE_REQUIREMENTS_PROMPT3**
|
|
6
|
+
|
|
7
|
+
## 2. Repository
|
|
8
|
+
|
|
9
|
+
`Z:\Users\newuser\Projects\my-frontend-observer` (`https://github.com/dailephd/my-frontend-observer.git`)
|
|
10
|
+
|
|
11
|
+
## 3. Branch
|
|
12
|
+
|
|
13
|
+
`implementation/v0.7-reference-requirements`
|
|
14
|
+
|
|
15
|
+
## 4. Starting head
|
|
16
|
+
|
|
17
|
+
`3a4a2e3b2968b5788e6f3b11a3cda6d83053d9cb`
|
|
18
|
+
|
|
19
|
+
## 5. Prompt 2 base head
|
|
20
|
+
|
|
21
|
+
`3a4a2e3b2968b5788e6f3b11a3cda6d83053d9cb` (same commit — the branch was created directly from Prompt 2's completed, clean state; verified as an ancestor via `git merge-base --is-ancestor` for both `c5c2eef` and `3a4a2e3`)
|
|
22
|
+
|
|
23
|
+
## 6. Ending head
|
|
24
|
+
|
|
25
|
+
`4d7bd610d8b3ca8ed6e228eee39e08003c21161c` (implementation commit; the report commit that follows this file's own commit will be one ahead of this)
|
|
26
|
+
|
|
27
|
+
## 7. Git status
|
|
28
|
+
|
|
29
|
+
Clean at the ending head. The Prompt 1 speculative-write stash (`stray-fork-writes-preserved-for-reference: ...`) remains present, untouched, unapplied, unmined, verified via `git stash list` at both the start and end of this stage.
|
|
30
|
+
|
|
31
|
+
## 8. Resolved my-dev-kit version
|
|
32
|
+
|
|
33
|
+
`@dailephd/my-dev-kit@1.12.3` (re-checked via `npm view @dailephd/my-dev-kit version` at execution start — unchanged from Prompt 1/2, still latest)
|
|
34
|
+
|
|
35
|
+
## 9. Fresh index path / ID
|
|
36
|
+
|
|
37
|
+
`.my-dev-kit/index-prompt3` — a fresh index built this stage (`my-dev-kit index --root . --src src --out .my-dev-kit/index-prompt3 --call-graph --json`), independent of the Prompt 1/2 indexes. Gitignored, never staged.
|
|
38
|
+
|
|
39
|
+
## 10. Previous contract verification
|
|
40
|
+
|
|
41
|
+
Read directly from the maintained repository before any change:
|
|
42
|
+
|
|
43
|
+
- `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (imported/approved variants), `isValidExternalReferenceArtifact`, the `regions?` field and its validation wiring (Prompt 2).
|
|
44
|
+
- `src/domain/externalReferenceRegions.ts` — `ReferenceRegion`, `ReferenceRegionGeometry`, `deriveReferenceRegionGeometry`, `isValidReferenceRegions`, `MAX_REFERENCE_REGIONS`, `REFERENCE_REGION_ID_PATTERN`.
|
|
45
|
+
- `src/domain/externalReferenceRegionRelationships.ts` — `deriveReferenceRegionRelationships`, `ReferenceRegionRelationship`, bound constants.
|
|
46
|
+
- `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`'s existing `regions` backward-compatible-omission pattern (directly extended, not redesigned).
|
|
47
|
+
- `src/application/externalReferencePersistenceService.ts` — `importExternalReference`/`approveExternalReference`'s existing region-handling shape.
|
|
48
|
+
- `src/cli.ts` — `import-reference`/`approve-reference`'s existing `--regions-file` handling and `loadRegionsFile` pattern.
|
|
49
|
+
- The full Prompt 1/2 test suite (719 tests at the time), confirmed green before touching anything.
|
|
50
|
+
|
|
51
|
+
Prompt 1/2 reports and current source matched exactly — no `BLOCKED_PREVIOUS_PROMPT_REPORT_MISMATCH` condition was encountered.
|
|
52
|
+
|
|
53
|
+
## 11. v0.5 precedent review
|
|
54
|
+
|
|
55
|
+
- **Exact category types inspected**: `src/domain/frontendContracts.ts` — `AUTHORED_CHANGE_SCOPE_CATEGORIES`/`AuthoredChangeScopeCategory`/`isAuthoredChangeScopeCategory` (`requested`/`expected-dependent`/`protected`/`preserved`; `'unexpected'` is a separate, derived-only `CHANGE_SCOPE_CLASSIFICATIONS` member, never authorable), `EXPECTED_DEPENDENT_MODES`/`ExpectedDependentMode`/`isValidExpectedDependentMode` (`required`/`permitted`).
|
|
56
|
+
- **Contract primitive witnesses**: `ContractPrimitive`'s closed vocabulary and `hasOnlyKeys` discipline (structural style precedent, not directly reused — Prompt 3's subjects are a different, reference-specific shape).
|
|
57
|
+
- **Tolerance witnesses**: `ContractTolerance` (`exact`/`absolute-px`/`percent`) and its bounds (`CONTRACT_TOLERANCE_ABSOLUTE_PX_MIN/MAX` = 0/100, `_PERCENT_MIN/MAX` = 0/100), and `frontendContractEvaluation.ts#toleranceToPx`'s "percent denominator is the before-value" convention.
|
|
58
|
+
- **Conflict semantics inspected**: `frontendContractEvaluation.ts#primitivesConflict`/`evaluateFrontendContract`'s per-clause conflict detection — confirmed this runs at **runtime evaluation time** against actual before/after `ObservationArtifact` evidence (`toClauseResult`, `EvalContext`), not at authoring time.
|
|
59
|
+
- **What was reused**: `AuthoredChangeScopeCategory`/`AUTHORED_CHANGE_SCOPE_CATEGORIES`/`isAuthoredChangeScopeCategory` and `ExpectedDependentMode`/`EXPECTED_DEPENDENT_MODES`/`isValidExpectedDependentMode` are imported **directly** from `frontendContracts.ts` (zero duplication) — these types carry no runtime-only coupling in their own definition, so direct reuse was safe and correct. The `CONTRACT_TOLERANCE_*` numeric bound *values* (0–100 for both absolute and percent) were mirrored as independently-owned constants.
|
|
60
|
+
- **What was not reused, and why**:
|
|
61
|
+
- `ContractTolerance` was **not** reused as a type — its `absolute-px` member is implicitly runtime/CSS pixels (compared against live `TargetGeometry`); reusing it for reference-image pixels would silently mislabel the unit, which request section 20 explicitly forbids. A new `ReferenceRequirementTolerance` type was introduced instead, with the same numeric bounds but an explicitly-named `absolute-reference-px` kind.
|
|
62
|
+
- `primitivesConflict`/the whole runtime conflict-detection pass was **not** reused — it operates over before/after `ObservationArtifact` evidence that does not exist at this authoring-time stage. Prompt 3 instead restricts invalid combinations directly: no two requirements in a collection may share the same structural subject, regardless of category (see section 25).
|
|
63
|
+
|
|
64
|
+
## 12. v0.6 adequacy precedent review
|
|
65
|
+
|
|
66
|
+
- **Exact types/functions inspected**: `src/domain/boundedAgentContext.ts` — `Adequacy { state; reasons }`, `AdequacyState` (`adequate`/`partial`/`inadequate`), `ADEQUACY_REASON_CODES` (`required-runtime-target-unavailable`, `static-correlation-ambiguous`, `consumer-incompatibility`, etc.), `isValidAdequacy`.
|
|
67
|
+
- **Whether the `Adequacy` type was reused**: no.
|
|
68
|
+
- **Whether a separate reason family was introduced**: yes — `REFERENCE_REQUIREMENT_ADEQUACY_STATES` (a freshly-declared, textually-identical three-value vocabulary: `adequate`/`partial`/`inadequate`) and `REFERENCE_REQUIREMENT_ADEQUACY_REASON_CODES` (exactly two codes: `no-selected-requirements`, `missing-reference-relationship-evidence`), both owned by `externalReferenceRequirements.ts`.
|
|
69
|
+
- **Why**: `boundedAgentContext.ts`'s reason codes describe runtime-target availability and static-correlation ambiguity — concerns that do not exist at this stage (there is no runtime target, no candidate, no static correlation yet). Reusing that exact reason-code union would either force nonsensical codes onto reference-side adequacy or silently expand a runtime-specific vocabulary to mean something unrelated - both violate the explicit "must not mislabel reference adequacy as bounded-agent-context adequacy" requirement. The three-state *shape* (`adequate`/`partial`/`inadequate`) is coincidentally identical text but is an independently-declared constant in the reference module, following this repository's established convention of duplicating small shared vocabularies per family (e.g. `canonicalize()` duplicated five times) rather than cross-importing between otherwise-unrelated domains.
|
|
70
|
+
|
|
71
|
+
## 13. Requirement model
|
|
72
|
+
|
|
73
|
+
- **Actual type names**: `ExternalReferenceRequirement`, `RawReferenceRequirement` (unidentified authored input), `ReferenceRequirementSubject` (`RegionPropertyRequirementSubject | RegionRelationshipRequirementSubject | RegionMeasurementRequirementSubject`), all in `src/domain/externalReferenceRequirements.ts`.
|
|
74
|
+
- **Requirement ID semantics**: `requirementId` is **always system-computed** via `buildReferenceRequirementIdentity(subject, category, tolerance, expectedDependentMode)` (`src/domain/externalReferenceRequirementIdentity.ts`, mirroring `frontendContractIdentity.ts#buildClauseIdentity`'s exact canonicalize+sha256 shape). Authoring a `requirementId` in raw input is a validation error (`isValidRawReferenceRequirement` rejects it) — deliberately different from v0.5's `clauseId` (which authors do supply, because clauses need a cross-document-reference id for `supersedesBaselineClauseIds`; requirements have no equivalent need yet).
|
|
75
|
+
- **Category semantics**: exactly v0.5's `AuthoredChangeScopeCategory`, imported directly. `expectedDependentMode` required iff category is `expected-dependent`, forbidden otherwise (identical shape to `isValidPerChangeClause`'s rule).
|
|
76
|
+
- **Supported subjects**: `region-property` (one region + `ReferenceRequirementRegionProperty`), `region-relationship` (two regions + `PairwiseRelationshipKind`, reused from `relationships.ts`, geometry-only families only), `region-measurement` (two regions + `ReferenceRequirementMeasurement`).
|
|
77
|
+
- **Supported properties**: `REFERENCE_REQUIREMENT_REGION_PROPERTIES = ['x','y','width','height','right','bottom','centerX','centerY']` — exactly `ReferenceRegionGeometry`'s own fields, nothing invented (no separate `left`/`top` aliases).
|
|
78
|
+
- **Relationship/measurement requirements**: relationship subjects reuse Prompt 2's `PairwiseRelationshipKind` vocabulary directly (no tolerance permitted — a categorical fact). Measurement subjects use one of six pure derived measurements: `vertical-gap`, `horizontal-gap`, `center-x-delta`, `center-y-delta`, `left-edge-delta`, `right-edge-delta` (a tolerance is required).
|
|
79
|
+
- **Bounds**: `MAX_REFERENCE_REQUIREMENTS = 50` per artifact — a maximum capacity, never a required minimum; no per-region sub-cap was added (the overall bound plus the duplicate-subject rule already bounds practical growth well within it).
|
|
80
|
+
|
|
81
|
+
## 14. Tolerance model
|
|
82
|
+
|
|
83
|
+
- **Exact tolerance kinds**: `ReferenceRequirementTolerance = { kind: 'exact' } | { kind: 'absolute-reference-px'; amount } | { kind: 'percent'; amount }`.
|
|
84
|
+
- **Units**: `absolute-reference-px` is explicitly reference-image pixels, never silently treated as CSS/runtime pixels — no scale/compatibility mapping exists yet (deferred to Prompt 6, per request section 20).
|
|
85
|
+
- **Bounds**: `REFERENCE_REQUIREMENT_TOLERANCE_ABSOLUTE_PX_MIN/MAX = 0/100`, `_PERCENT_MIN/MAX = 0/100` — same numeric values as v0.5's `CONTRACT_TOLERANCE_*` constants, independently owned (not imported) for the unit-labeling reason above.
|
|
86
|
+
- **Validation**: negative, non-finite, and unsupported-kind tolerances fail closed (`isValidReferenceRequirementTolerance`); an `exact` tolerance permits no `amount` field at all.
|
|
87
|
+
- **Relationship vs numeric applicability**: `region-relationship` subjects must **not** carry a tolerance (categorical fact); `region-property`/`region-measurement` subjects **must** carry one — enforced explicitly, in both directions, by `validateAuthoredRequirementFields`.
|
|
88
|
+
- **Reuse of v0.5**: numeric bounds mirrored (see section 11); the type itself is a fresh, reference-owned type, not a v0.5 reuse (see section 11's rationale).
|
|
89
|
+
|
|
90
|
+
## 15. Reference expectation derivation
|
|
91
|
+
|
|
92
|
+
Nothing is stored beyond `{subject, category, expectedDependentMode?, tolerance?}` per requirement — no numeric expected value (e.g. `width: 424`) and no relationship-match boolean are ever persisted. `deriveReferenceRequirementExpectation(subject, regions, options)` is a pure function computing, on demand:
|
|
93
|
+
|
|
94
|
+
- for `region-property`: the named region's `ReferenceRegionGeometry[property]`, freshly derived from its canonical rectangle every call;
|
|
95
|
+
- for `region-measurement`: the named pure measurement over the two regions' derived geometries;
|
|
96
|
+
- for `region-relationship`: whether the reference actually exhibits the claimed relationship, by deriving the region pair's relationships via `deriveReferenceRegionRelationships` and checking within the **correct relationship family** (a bug caught and fixed during test-writing — see section 20) for a match in either declared or geometry-determined order (only `follows-vertically` can differ from declared order, since it is the one family whose direction depends on actual geometry rather than input order).
|
|
97
|
+
|
|
98
|
+
This directly satisfies the "avoid redundant storage, derive from canonical geometry" instruction — there is no possibility of a stored expected value drifting from the region it describes, because none is ever stored.
|
|
99
|
+
|
|
100
|
+
## 16. Adequacy model
|
|
101
|
+
|
|
102
|
+
- **Status vocabulary**: `REFERENCE_REQUIREMENT_ADEQUACY_STATES = ['adequate', 'partial', 'inadequate']`.
|
|
103
|
+
- **Reason codes**: exactly two — `no-selected-requirements`, `missing-reference-relationship-evidence`. No other reason code exists because no other condition is possible: an unknown region id, unsupported property, or malformed requirement is a **construction-time validation failure** (`isValidReferenceRequirements`) that never reaches adequacy computation at all.
|
|
104
|
+
- **Zero-requirement behavior**: explicitly `inadequate`, with a `no-selected-requirements` reason — a documented product decision (request section 24F): a region-rich, fully-valid reference is still not usable for a correction task until the user has actually selected what matters.
|
|
105
|
+
- **Missing-region behavior**: not an adequacy concern — rejected at validation time before adequacy ever runs (see section 11's "what was not reused" discussion of the D behavior choice: "authored reference requirement pointing to a nonexistent authored region should fail validation rather than become normal unavailable evidence").
|
|
106
|
+
- **Missing-relationship-evidence behavior**: a structurally-valid `region-relationship`/`region-measurement` requirement whose claimed evidence cannot actually be derived from the geometry (wrong relationship, or a measurement that is geometrically undefined, e.g. `vertical-gap` between overlapping regions) is reported `missing-reference-relationship-evidence`, contributing to a `partial` or `inadequate` overall status.
|
|
107
|
+
- **Deterministic ordering**: reasons are pushed in authored-requirement-array order, never object-key or Set-iteration order — verified by test.
|
|
108
|
+
- **Blocking intent for later stages**: `ReferenceRequirementAdequacy` is returned by both `importExternalReference`/`approveExternalReference` and printed by the CLI (`Adequacy: <status>`) so a later orchestration stage can enforce "inadequate reference → do not begin correction" without Prompt 3 itself running any coding-agent workflow.
|
|
109
|
+
|
|
110
|
+
## 17. Identity
|
|
111
|
+
|
|
112
|
+
- `buildExternalReferenceRequestIdentity` gained one additional optional trailing parameter, `requirements?: readonly ExternalReferenceRequirement[]`, following the exact `regions` precedent: omitted from the hashed semantic view entirely (never defaulted to `null`) when absent, so every Prompt 1/2 call site — and every Prompt 3 call with no requirements — produces a byte-identical hash to before this parameter existed (verified by test: `'omitting requirements produces the exact same identity as before this parameter existed'`).
|
|
113
|
+
- Path independence: the function still takes no path argument of any kind; this holds by construction, not merely by test.
|
|
114
|
+
- Content participation: verified by test that changing a requirement's category, adding, or removing a requirement each changes the artifact-level `referenceRequestId`. Each requirement's own `requirementId` additionally changes with its subject/category/mode/tolerance (tested directly in `externalReferenceRequirementIdentity.test.ts`), so a change to any requirement changes both that requirement's own id and the artifact-level identity.
|
|
115
|
+
|
|
116
|
+
## 18. Artifact / schema decision
|
|
117
|
+
|
|
118
|
+
- Requirements live as an additive, optional `requirements?: ExternalReferenceRequirement[]` field directly on `ExternalReferenceArtifactBase` (both `ImportedExternalReferenceArtifact` and `ApprovedExternalReferenceArtifact` inherit it) — the same minimal-extension shape as Prompt 2's `regions`, not a separate derived artifact family (no new persisted artifact kind was introduced).
|
|
119
|
+
- **No schema version bump** — `EXTERNAL_REFERENCE_SCHEMA_VERSION` remains `'1.0.0'`, for the identical reasoning already established in the Prompt 2 report: the field is genuinely optional/additive, and this repository's `isValid*Artifact` convention performs a strict version-equality check, so bumping would make every Prompt 1/2 artifact fail validation under the current reader — directly contradicting the explicit "legacy artifacts remain valid" requirement.
|
|
120
|
+
- **Historical artifact compatibility**: verified by test (`'U: a legacy (Prompt 1/2) artifact with no requirements field at all remains valid'`) that an artifact predating this field validates successfully.
|
|
121
|
+
- **Immutable approved-reference handling**: `approveExternalReference` copies `imported.requirements` into a **new** artifact object (fresh `referenceId`, same `referenceRequestId`) — it never reopens or rewrites the imported artifact's own manifest file. Verified by test that an approved artifact's manifest is byte-for-byte unchanged after later, unrelated import/approve activity in the same output directory (reusing the exact test already established in Prompt 2 for this purpose, now also covering requirements).
|
|
122
|
+
|
|
123
|
+
## 19. Public interface
|
|
124
|
+
|
|
125
|
+
- **CLI changes**: `import-reference` gained an optional `--requirements-file <json-file>` (root shape `{ "requirements": [...] }`, validated by a new `loadRequirementsFile` mirroring `loadRegionsFile` exactly — object root, exact allow-listed top-level field). Both `import-reference` and `approve-reference` now additionally print `Requirements: <count>` and `Adequacy: <status>` lines. No existing flag, argument, help text section, or exit code changed in meaning.
|
|
126
|
+
- **Input file shape**: `{ "requirements": [ { "category": "requested", "subject": { "kind": "region-property", "region": "current-page-card", "property": "width" }, "tolerance": { "kind": "absolute-reference-px", "amount": 4 } } ] }` — chosen directly from the `--regions-file`/`--targets-file` object-root-wrapper precedent, not the prompt's illustrative example verbatim. No `requirementId` field is accepted in this file (system-computed).
|
|
127
|
+
- **Programmatic export changes**: `src/index.ts` additively exports the complete new requirement/tolerance/adequacy type, constant, and function surface (`ExternalReferenceRequirement`, `RawReferenceRequirement`, `ReferenceRequirementSubject` variants, `ReferenceRequirementTolerance`, `ReferenceRequirementAdequacy`, `deriveReferenceRequirementExpectation`, `deriveReferenceRequirementAdequacy`, `buildReferenceRequirement`, `isValidRawReferenceRequirement`, `isValidReferenceRequirements`, plus bound/vocabulary constants). `AuthoredChangeScopeCategory`/`ExpectedDependentMode` and their constants are **not** re-exported a second time from the new module (they were already exported from `frontendContracts.js` — re-exporting would have been a duplicate-name compile error, caught and fixed during implementation). `ImportExternalReferenceOptions` gained an additive `requirements?` field; both application-result types gained additive `requirementCount: number` and `adequacy: ReferenceRequirementAdequacy` fields.
|
|
128
|
+
- **Backward compatibility**: every Prompt 1/2 CLI invocation and every existing result-consumer reading the pre-existing fields continues to work unchanged — verified by the full pre-existing suite passing unmodified, plus dedicated tests confirming a requirements-less import reports `requirementCount: 0`, `adequacy.status: 'inadequate'`, and no `requirements` key on the manifest.
|
|
129
|
+
|
|
130
|
+
## 20. Files changed
|
|
131
|
+
|
|
132
|
+
Modified: `docs/ARCHITECTURE.md`, `docs/CONTRACTS.md`, `docs/CURRENT_STATE.md`, `docs/WORKFLOWS.md`, `src/application/externalReferencePersistenceService.ts`, `src/cli.ts`, `src/domain/diagnostics.ts`, `src/domain/externalReference.ts`, `src/domain/externalReferenceIdentity.ts`, `src/index.ts`, `tests/unit/cliExternalReference.test.ts`, `tests/unit/externalReference.test.ts`, `tests/unit/externalReferenceIdentity.test.ts`, `tests/unit/externalReferencePersistenceService.test.ts`.
|
|
133
|
+
New: `src/domain/externalReferenceRequirements.ts`, `src/domain/externalReferenceRequirementIdentity.ts`, `tests/unit/externalReferenceRequirements.test.ts`, `tests/unit/externalReferenceRequirementIdentity.test.ts`.
|
|
134
|
+
|
|
135
|
+
`src/domain/relationships.ts` was **not** modified this stage (its Prompt 2 additive exports were reused as-is, imported alongside three additional pre-existing family-constant exports `HORIZONTAL_ORDER_RELATIONSHIPS`/`VERTICAL_ORDER_RELATIONSHIPS`/etc. that were already exported).
|
|
136
|
+
|
|
137
|
+
## 21. Tests added / changed
|
|
138
|
+
|
|
139
|
+
60 new tests across 2 new files and additions to 4 existing files (0 pre-existing test modified or removed):
|
|
140
|
+
|
|
141
|
+
- `externalReferenceRequirementIdentity.test.ts` (6 tests): content-determinism, subject/category/tolerance/mode sensitivity, call-site independence.
|
|
142
|
+
- `externalReferenceRequirements.test.ts` (35 tests): all four categories valid, authored `unexpected` rejected, mode required/forbidden correctly, authored `requirementId` rejected, all three subject kinds valid/invalid (including unsupported property/measurement/relationship), tolerance-applicability-by-subject-kind, unknown-region-id rejection, duplicate/conflicting-subject rejection (including relationship-subject order-independence), requirement-limit exact-max/one-over, exact/absolute/percent tolerance boundaries, negative/non-finite/unsupported-kind tolerance rejection, all six measurement derivations (including overlap-undefined cases), reference-expectation derivation for all three subject kinds (including the family-lookup bug fix - see section 20), zero/all/some-unavailable adequacy states, deterministic reason ordering, no-numeric-score assertion, immutability.
|
|
143
|
+
- `externalReferenceIdentity.test.ts` (+5 tests): requirements-omission backward compatibility, same-content-same-identity, category-change/add/remove-changes-identity.
|
|
144
|
+
- `externalReference.test.ts` (+6 tests): legacy-no-requirements validity, valid requirements on both lifecycle variants, unknown-region rejection, regions-absent rejection, malformed-value rejection.
|
|
145
|
+
- `externalReferencePersistenceService.test.ts` (+5 tests): import-with-requirements persists them and reports adequacy, regionless/requirement-less import reports zero/inadequate, unknown-region import rejection (nothing persisted), authored-id rejection, approval carries requirements forward with matching adequacy.
|
|
146
|
+
- `cliExternalReference.test.ts` (+5 tests): end-to-end `--requirements-file` import+approve with adequacy reporting, legacy no-flag invocation reports zero/inadequate, unknown-region CLI rejection, malformed-`--requirements-file` rejection (bad JSON, array root, unknown field).
|
|
147
|
+
|
|
148
|
+
## 22. Validation results
|
|
149
|
+
|
|
150
|
+
All on the ending commit (`4d7bd61`) on `implementation/v0.7-reference-requirements`:
|
|
151
|
+
|
|
152
|
+
| Command | Result |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `npm run typecheck` | PASS |
|
|
155
|
+
| `npm run lint` | PASS (one `no-unused-vars` finding during development, fixed before commit) |
|
|
156
|
+
| `npm test` | PASS — 42 files, 779 tests (up from 40/719) |
|
|
157
|
+
| `npm run build` | PASS (both new modules compiled into `dist/`) |
|
|
158
|
+
| `npm run check:docs` | PASS (17 required files) |
|
|
159
|
+
| `git diff --check` | PASS |
|
|
160
|
+
| `npm pack --dry-run` | PASS (173 files, 330.5 kB / 1.4 MB unpacked; both new modules present in the tarball listing) |
|
|
161
|
+
| `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count) |
|
|
162
|
+
| `npm run test:security` | PASS — 68 tests |
|
|
163
|
+
|
|
164
|
+
## 23. Regression results
|
|
165
|
+
|
|
166
|
+
- **Prompt 1 tests**: all pre-existing `externalReference*`/`cliExternalReference` tests pass unmodified.
|
|
167
|
+
- **Prompt 2 tests**: `externalReferenceRegions.test.ts`, `externalReferenceRegionRelationships.test.ts` pass unmodified.
|
|
168
|
+
- **v0.5 dependent tests**: `frontendContracts.test.ts`, `frontendContractEvaluation.test.ts`, `frontendContractPersistence.test.ts` explicitly re-run — 207 combined tests (with `boundedAgentContext.test.ts`, `boundedAgentContextProjection.test.ts`, `relationships.test.ts`, `relationshipDerivation.test.ts`) pass unchanged. `frontendContracts.ts` itself was not modified at all (only imported from, read-only).
|
|
169
|
+
- **v0.6 tests**: `boundedAgentContext*.test.ts` (4 files) pass unchanged; `boundedAgentContext.ts` was not modified (only inspected for precedent, never imported from — see section 12).
|
|
170
|
+
|
|
171
|
+
## 24. Boundedness
|
|
172
|
+
|
|
173
|
+
- **Requirement bound**: `MAX_REFERENCE_REQUIREMENTS = 50` per artifact — explicit, tested at exactly-max (accepted) and one-over (rejected, no partial acceptance).
|
|
174
|
+
- No separate per-region requirement cap was added; the overall bound plus the duplicate-subject rule already bounds practical per-region growth (at most one requirement per distinct property/relationship/measurement combination can exist at all, well within 50 even for the maximum 20-region case).
|
|
175
|
+
|
|
176
|
+
## 25. Conflict handling
|
|
177
|
+
|
|
178
|
+
v0.5's `primitivesConflict`/`evaluateFrontendContract` conflict detection is a **runtime-evaluation-time** mechanism requiring before/after `ObservationArtifact` evidence that does not exist at requirement-authoring time — it was not reused, per request section 45's explicit permission to restrict invalid combinations instead when v0.5 semantics cannot be safely reused. Prompt 3's chosen rule: **no two requirements in one collection may share the same structural subject**, regardless of category (`sameSubject()` in `externalReferenceRequirements.ts`, with relationship/measurement subjects treated as the same regardless of which region is declared first). This single rule resolves both the "duplicate requirement" and "conflicting categories on the same subject" behavior-model questions with one mechanism, is fully deterministic, and is enforced at collection-validation time (`isValidReferenceRequirements`) — never silently choosing one requirement over another.
|
|
179
|
+
|
|
180
|
+
## 26. Security / privacy impact
|
|
181
|
+
|
|
182
|
+
No new network calls, no vision/AI API calls. `--requirements-file`'s path is never persisted or included in any identity, matching `--regions-file`/`--targets-file`/`--contract-file` convention exactly. Requirement content is plain structured data (category strings, region-id references, numeric tolerances) with no new file-system write boundary — requirements are embedded directly in the existing `manifest.json`. The unsupported-top-level-field rejection on `--requirements-file`'s root prevents silently ignored/misinterpreted malformed input, matching the existing `--regions-file` convention.
|
|
183
|
+
|
|
184
|
+
## 27. Documentation changes
|
|
185
|
+
|
|
186
|
+
Additive sections only: `docs/CONTRACTS.md` ("v0.7 Prompt 3 selected design requirements, tolerance semantics, and reference-evidence adequacy" — the primary contract reference), `docs/ARCHITECTURE.md` (relationship of the new requirement/adequacy modules to v0.5/v0.6 precedent and to Prompt 1/2), `docs/CURRENT_STATE.md` ("v0.7 Prompt 3 status" section, plus updated "Not implemented"/"Next target"), `docs/WORKFLOWS.md` (the extended import/approve workflow diagram, the new requirement/adequacy description, and a correction to the "Planned v0.7 reference-driven correction flow" marking requirements/tolerances/adequacy as now implemented). `docs/ROADMAP.md` was **not** touched. `docs/COMMANDS.md` was **not** touched, consistent with Prompt 1/2's own precedent of not documenting `import-reference`/`approve-reference` there.
|
|
187
|
+
|
|
188
|
+
## 28. Tooling incidents
|
|
189
|
+
|
|
190
|
+
None this stage. No background/subagent write occurred during Prompt 3's implementation - all work was performed directly in the main session, per the stricter no-background-speculative-writes instruction carried forward from Prompt 2. The Prompt 1 speculative-write incident remains historical; its stash was confirmed untouched at both the start and end of this stage.
|
|
191
|
+
|
|
192
|
+
## 29. Inherited orchestrator heuristic issue
|
|
193
|
+
|
|
194
|
+
Not encountered as a product problem this stage. `my-dev-kit-orchestrator` was not modified, no test was rewritten to satisfy its responsibility-mapping heuristic, and no fake evidence tags were added. This stage used `DIRECT_IMPLEMENTATION` without invoking the orchestrator's stage-context workflow at all, so the heuristic gap noted in Prompt 1 did not arise here (consistent with Prompt 2).
|
|
195
|
+
|
|
196
|
+
## 30. Out-of-scope confirmation
|
|
197
|
+
|
|
198
|
+
This stage did **not** implement: theme identity evaluation, application-state compatibility, viewport compatibility evaluation, reference/candidate comparability, reference-region↔runtime-target binding, runtime target identity in requirement subjects, candidate observation lookup or geometry, reference-vs-candidate delta, fidelity PASS/FAIL, style/color/typography/pixel/image-similarity comparison, visual score, source correlation changes, bounded correction packets, v0.6 agent-context extension, coding-agent invocation, source editing, rerender orchestration, correction iteration, the viewer, annotation, automatic requirement inference, or automatic region detection. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not yet implemented" documentation comments) and by direct code inspection: `ReferenceRequirementSubject` and `ReferenceRequirementAdequacy` contain no runtime-target/candidate/binding field of any kind, not even as a placeholder.
|
|
199
|
+
|
|
200
|
+
## 31. Known limitations
|
|
201
|
+
|
|
202
|
+
1. No fuzz-testing of adversarial requirement JSON beyond the specific malformed-shape cases already covered (bad JSON, array root, unknown field, non-object entry, unsupported property/measurement/relationship) — consistent with Prompt 1/2's own documented fuzz-testing scope boundary.
|
|
203
|
+
2. The `region-relationship` reference-expectation lookup can report "opposite region order" unavailability for the one family (`follows-vertically`) whose direction is decided by geometry rather than authored order; a user must author `subjectRegion`/`relatedRegion` matching the geometrically-determined direction to get a `matches: true/false` result for that specific family. This is documented behavior (see section 15), not a defect, but is a rough edge a future prompt's UI/authoring tooling should smooth over (e.g. by trying both orders automatically) rather than something Prompt 3 should paper over silently now.
|
|
204
|
+
3. `MAX_REFERENCE_REQUIREMENTS = 50` has no cited external precedent value (unlike `MAX_REFERENCE_REGIONS`, which coincidentally matches `MAX_TARGETS`) — it is a reasonable, documented, but ultimately judgment-call bound.
|
|
205
|
+
|
|
206
|
+
## 32. Remaining risks
|
|
207
|
+
|
|
208
|
+
- Because reference expectations and adequacy are never persisted, every future consumer (Prompt 4+) that needs them must call `deriveReferenceRequirementExpectation`/`deriveReferenceRequirementAdequacy` itself. This mirrors Prompt 2's relationship-derivation design deliberately (avoids drift) and should not be "fixed" by prematurely adding persistence.
|
|
209
|
+
- The duplicate-subject conflict rule is stricter than v0.5's category-aware conflict model (it rejects same-subject-different-category outright rather than trying to reconcile them). If a future prompt determines users genuinely need e.g. a `requested` and a `protected` requirement coexisting on the same subject for some legitimate reason, that will require a deliberate architecture revisit, not a quiet loosening of this rule.
|
|
210
|
+
|
|
211
|
+
## 33. Exact next action
|
|
212
|
+
|
|
213
|
+
**v0.7 Prompt 4** — reference applicability/state compatibility and comparability foundation.
|
|
214
|
+
|
|
215
|
+
## 34. Report path
|
|
216
|
+
|
|
217
|
+
`docs/reports/v0.7-reference-requirements-prompt3.md` (this file)
|