@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,195 +1,195 @@
|
|
|
1
|
-
# v0.7 Prompt 2 — Explicit Reference Regions, Geometry, and Reusable Reference Relationships
|
|
2
|
-
|
|
3
|
-
## 1. Verdict
|
|
4
|
-
|
|
5
|
-
**PASS_V0_7_REFERENCE_REGIONS_PROMPT2**
|
|
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-regions`
|
|
14
|
-
|
|
15
|
-
## 4. Starting head
|
|
16
|
-
|
|
17
|
-
`ba61897e597451ae34f81583cbcffc8447b09738`
|
|
18
|
-
|
|
19
|
-
## 5. Prompt 1 base head
|
|
20
|
-
|
|
21
|
-
`ba61897e597451ae34f81583cbcffc8447b09738` (same commit — the branch was created directly from Prompt 1's completed, clean state; verified as an ancestor via `git merge-base --is-ancestor`)
|
|
22
|
-
|
|
23
|
-
## 6. Ending head
|
|
24
|
-
|
|
25
|
-
`c5c2eef66ddecb0365c2ced7d9a25f1b9e16c210`
|
|
26
|
-
|
|
27
|
-
## 7. Git status
|
|
28
|
-
|
|
29
|
-
Clean at the ending head. The Prompt 1 speculative research-agent stash (`stray-fork-writes-preserved-for-reference: ...`) remains present, untouched, unapplied, and unmined throughout this stage — verified with `git stash list` before and after implementation.
|
|
30
|
-
|
|
31
|
-
## 8. Resolved my-dev-kit version
|
|
32
|
-
|
|
33
|
-
`@dailephd/my-dev-kit@1.12.3` (unchanged from Prompt 1 — still the latest published version at execution start; re-checked via `npm view @dailephd/my-dev-kit version`, not assumed from memory)
|
|
34
|
-
|
|
35
|
-
## 9. Fresh index path / ID
|
|
36
|
-
|
|
37
|
-
`.my-dev-kit/index-prompt2` — a fresh index built this stage (`my-dev-kit index --root . --src src --out .my-dev-kit/index-prompt2 --call-graph --json`), independent of Prompt 1's `.my-dev-kit/index`/`index-after` indexes (not reused as the new-behavior evidence source, per instruction). This tooling directory is gitignored and was never staged.
|
|
38
|
-
|
|
39
|
-
## 10. Prompt 1 contract verified
|
|
40
|
-
|
|
41
|
-
Read directly from the maintained repository (not from the Prompt 1 report alone) before any change:
|
|
42
|
-
|
|
43
|
-
- `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (`ImportedExternalReferenceArtifact` | `ApprovedExternalReferenceArtifact`), `isValidExternalReferenceArtifact`, `isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact`, `EXTERNAL_REFERENCE_ARTIFACT_KIND`/`EXTERNAL_REFERENCE_SCHEMA_VERSION`.
|
|
44
|
-
- `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`/`buildExternalReferenceInstanceIdentity`.
|
|
45
|
-
- `src/domain/externalReferenceImage.ts` — format/dimension boundary (unchanged this stage).
|
|
46
|
-
- `src/artifacts/externalReferenceArtifactWriter.ts`/`Reader.ts` — atomic persistence (unchanged this stage).
|
|
47
|
-
- `src/application/externalReferencePersistenceService.ts` — `importExternalReference`/`approveExternalReference`.
|
|
48
|
-
- `src/cli.ts` — `import-reference`/`approve-reference` commands, their help text, arg parsers, and dispatch.
|
|
49
|
-
- `tests/unit/externalReference*.test.ts`, `cliExternalReference.test.ts` — the full Prompt 1 test suite (668 tests at the time), confirmed still green before touching anything.
|
|
50
|
-
|
|
51
|
-
The Prompt 1 report and the actual implementation matched exactly — no `BLOCKED_PROMPT1_IMPLEMENTATION_REPORT_MISMATCH` condition was encountered.
|
|
52
|
-
|
|
53
|
-
## 11. Region model
|
|
54
|
-
|
|
55
|
-
- **Type name**: `ReferenceRegion { id: string; rectangle: ReferenceRegionRectangle }`, `ReferenceRegionRectangle { x, y, width, height }` (`src/domain/externalReferenceRegions.ts`).
|
|
56
|
-
- **Stable region ID semantics**: `^[A-Za-z0-9_-]{1,64}$`, unique case-insensitively within one artifact — reused verbatim from `request/request.ts`'s target-name convention (exact pattern and dedup rule).
|
|
57
|
-
- **Canonical coordinate representation**: only `{x, y, width, height}` is authored/canonical; everything else is derived.
|
|
58
|
-
- **Coordinate origin/unit**: top-left of the reference image; x rightward, y downward; unit is reference-image pixels (explicitly not CSS pixels); coordinates may be fractional.
|
|
59
|
-
- **Numeric rules**: `x`/`y` finite and ≥ 0; `width`/`height` finite and > 0 (zero/negative/non-finite all rejected, never clamped).
|
|
60
|
-
- **Image-boundary rule**: a region's derived `right`/`bottom` must not exceed the owning image's own already-validated width/height; rejected outright otherwise, exact-boundary regions accepted.
|
|
61
|
-
- **Region-count bound**: `MAX_REFERENCE_REGIONS = 20` — a maximum capacity only, matching `request/request.ts`'s `MAX_TARGETS` value (independently owned constant, not imported/coupled).
|
|
62
|
-
- **Deterministic ordering rule**: authored array order is preserved and treated as semantic (never re-sorted), mirroring `domain/identity.ts`'s treatment of configured targets — both for identity hashing and for relationship derivation.
|
|
63
|
-
|
|
64
|
-
## 12. Derived geometry
|
|
65
|
-
|
|
66
|
-
- **Exact derived anchors**: `deriveReferenceRegionGeometry(rectangle) -> { x, y, width, height, right, bottom, centerX, centerY }` — a pure function, called fresh every time.
|
|
67
|
-
- **What is persisted**: only `{id, rectangle: {x, y, width, height}}` per region, inside the artifact's optional `regions` array.
|
|
68
|
-
- **What is computed**: `right`, `bottom`, `centerX`, `centerY` — never stored, so `x + width` can never disagree with a stored `right` (there is no stored `right`).
|
|
69
|
-
- **Normalized-coordinate decision**: not implemented in this stage. No normalized (`x / imageWidth`, etc.) field exists anywhere; if useful later, it would be derived on demand from the canonical rectangle plus the artifact's own image dimensions, never a second stored source of truth. This was a deliberate scope decision (request section 18 explicitly permits deferring it), not an oversight.
|
|
70
|
-
|
|
71
|
-
## 13. Relationship precedent review
|
|
72
|
-
|
|
73
|
-
- **Exact v0.4 owners inspected**: `src/domain/relationships.ts` (full file, 440 lines before this stage) — `PAIRWISE_RELATIONSHIP_KINDS`, `EvidenceReference`/`isValidEvidenceReference`, `LayoutRelationshipGraph`, `MAX_CONFIGURED_TARGETS_FOR_RELATIONSHIPS`/`MAX_PAIRWISE_RELATIONSHIP_RECORDS`, and the six pure predicates `horizontalOrderOf`/`verticalOrderOf`/`areaOverlapOf`/`relativeWidthOf`/`geometricFitOf`/`verticalSequenceOf` plus `deriveLayoutRelationships`'s pairwise-loop structure.
|
|
74
|
-
- **Relationship families reused**: all six geometry-only families — horizontal order, vertical order, area overlap, relative width, geometric fit, vertical sequencing.
|
|
75
|
-
- **Relationship families rejected as runtime-only**: `document-width-fits-viewport`/`document-width-exceeds-viewport` (page-level, needs document/viewport evidence a static image doesn't have); DOM containment (`TargetContainment` in `schema.ts` — explicitly documented there as never a layout/relationship graph concept, and an external image exposes no DOM at all); scroll ownership, runtime visibility, browser clipping, and semantic/accessibility relationships (all require live browser evidence).
|
|
76
|
-
- **Shared geometry primitives extracted**: yes — the six predicate functions were changed from private to `export`ed in `relationships.ts` with **zero formula changes** (verified by diff: only the `function` keyword gained `export`, one added a doc comment). `PAIRWISE_RELATIONSHIP_KINDS`, `EvidenceReference`, and `isValidEvidenceReference` were already exported and are imported as-is.
|
|
77
|
-
- **Proof v0.4 semantics did not change**: `npm test` (full suite), `npm run test:browser`, and a targeted run of `tests/unit/relationships.test.ts`, `relationshipDerivation.test.ts`, `comparisonEngine.test.ts`, and `frontendContractEvaluation.test.ts` all pass with identical counts to before this stage (132 tests across those four files, unchanged). No `BLOCKED_RELATIONSHIP_REUSE_REQUIRES_SEMANTIC_CHANGE` condition was encountered.
|
|
78
|
-
|
|
79
|
-
## 14. Reference relationship model
|
|
80
|
-
|
|
81
|
-
- **Type/function names**: `ReferenceRegionRelationship { kind: PairwiseRelationshipKind; subjectRegion: string; relatedRegion: string; evidence: EvidenceReference[] }`, `ReferenceRegionRelationshipGraph { referenceRequestId, geometryTolerancePx, regions: string[], pairwiseRelationships }`, `deriveReferenceRegionRelationships(referenceRequestId, regions, options)`, `isValidReferenceRegionRelationship`/`isValidReferenceRegionRelationshipGraph` (`src/domain/externalReferenceRegionRelationships.ts`).
|
|
82
|
-
- **Bounds**: `MAX_REFERENCE_REGION_PAIRS = 20*19/2 = 190`, `REFERENCE_REGION_RELATIONSHIP_FAMILY_COUNT = 6`, `MAX_REFERENCE_REGION_RELATIONSHIP_RECORDS = 1140` — the same bounding shape as `relationships.ts`'s `MAX_PAIRWISE_RELATIONSHIP_RECORDS`, over `MAX_REFERENCE_REGIONS` instead of the runtime-target limit.
|
|
83
|
-
- **Provenance model**: `evidence: [{ path: 'regions.<id>.rectangle' }, ...]` — never a `targetEvidence`/browser path; a relationship never claims runtime-target or DOM provenance (verified directly by test).
|
|
84
|
-
- **Deterministic ordering**: earlier-authored region is always `subjectRegion` for every family except `follows-vertically` (direction decided by actual geometry, matching `deriveLayoutRelationships` exactly); same input always produces the identical graph (verified by test).
|
|
85
|
-
- **Persistence decision**: relationships are **not persisted** on the artifact — always re-derivable on demand from the artifact's own `regions` field, eliminating any possibility of a stored relationship graph drifting from the region data.
|
|
86
|
-
|
|
87
|
-
## 15. Schema / artifact decision
|
|
88
|
-
|
|
89
|
-
- **Prompt 1 artifact schema changed**: yes, additively — one new optional field, `regions?: ReferenceRegion[]`, on both `ImportedExternalReferenceArtifact` and `ApprovedExternalReferenceArtifact`.
|
|
90
|
-
- **Schema version decision**: **no bump** — `EXTERNAL_REFERENCE_SCHEMA_VERSION` remains `'1.0.0'`. Rationale: the field is genuinely optional and additive with no other coupled behavior change; bumping would force a strict-equality version check (this repository's established `isValid*Artifact` convention) to reject every Prompt 1 artifact, which directly contradicts the explicit "legacy Prompt 1 reference remains valid/readable" requirement. This differs from the observation family's historical per-batch version-bump convention; documented here as a deliberate, evidence-based departure, not an oversight.
|
|
91
|
-
- **Historical Prompt 1 artifacts remain readable/valid**: yes — verified directly by test (`'a legacy (Prompt 1) artifact with no regions field at all remains valid'`), and by construction (`isValidExternalReferenceArtifact` only validates `regions` when the key is present).
|
|
92
|
-
- **Structured regions and logical identity**: `buildExternalReferenceRequestIdentity` gained an additive, optional trailing `regions` parameter. When omitted, it is left out of the hashed semantic view entirely (not defaulted to `null`, unlike `supersedesReferenceId`) so every Prompt 1 call site — and every Prompt 2 call with no regions — produces the byte-identical hash Prompt 1 already produced. When present, region content (id, rectangle, and authored order) is fully identity-bearing.
|
|
93
|
-
- **Immutable approved artifacts preserved**: `approveExternalReference` carries `imported.regions` forward verbatim (a plain copy, never re-validated or re-derived) into a **new** artifact instance; the imported artifact's own manifest is never opened for writing again. No code path in this stage ever mutates an existing persisted manifest.
|
|
94
|
-
|
|
95
|
-
## 16. Public interface
|
|
96
|
-
|
|
97
|
-
- **CLI changes**: `import-reference` gained an optional `--regions-file <json-file>` (root shape `{ "regions": [...] }`, validated by a new `loadRegionsFile` mirroring `loadTargetsFile` exactly — object root, exact allow-listed top-level field, JSON parse/read errors surfaced as `error:` lines). Both `import-reference` and `approve-reference` now print an additional `Regions: <count>` line. No existing flag, argument, or exit-code behavior changed.
|
|
98
|
-
- **Programmatic export changes**: `src/index.ts` additively exports the complete new region/relationship type, constant, and function surface (`ReferenceRegion`, `ReferenceRegionRectangle`, `ReferenceRegionGeometry`, `deriveReferenceRegionGeometry`, `isValidReferenceRegion(s)`, `REFERENCE_REGION_ID_PATTERN`, `MAX_REFERENCE_REGIONS`, `ReferenceRegionRelationship`, `ReferenceRegionRelationshipGraph`, `deriveReferenceRegionRelationships`, `isValidReferenceRegionRelationship(Graph)`, plus the `MAX_REFERENCE_REGION_*` bound constants), and the two Prompt 1 type guards (`isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact`) that had not yet been exported. `ImportExternalReferenceOptions` gained an additive `regions?` field; both application-result types gained an additive `regionCount: number` field.
|
|
99
|
-
- **Exact user/config input shape**: `{ "regions": [ { "id": "current-page-card", "rectangle": { "x": 28, "y": 92, "width": 424, "height": 82 } }, ... ] }` — chosen after precedent review (matches `--targets-file`'s object-root-wrapper convention) rather than the prompt's illustrative nested YAML-style example.
|
|
100
|
-
- **Backward compatibility**: every Prompt 1 CLI invocation and every existing `ApplicationImportExternalReferenceResult`/`ApplicationApproveExternalReferenceResult` consumer reading the pre-existing fields continues to work unchanged — verified by the full pre-existing test suite passing unmodified, plus a dedicated test confirming a regionless import reports `regionCount: 0` and no `regions` key on the manifest.
|
|
101
|
-
|
|
102
|
-
## 17. Files changed
|
|
103
|
-
|
|
104
|
-
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/domain/relationships.ts` (six predicates made `export`, formulas unchanged), `src/index.ts`, `tests/unit/cliExternalReference.test.ts`, `tests/unit/externalReference.test.ts`, `tests/unit/externalReferenceIdentity.test.ts`, `tests/unit/externalReferencePersistenceService.test.ts`.
|
|
105
|
-
New: `src/domain/externalReferenceRegions.ts`, `src/domain/externalReferenceRegionRelationships.ts`, `tests/unit/externalReferenceRegions.test.ts`, `tests/unit/externalReferenceRegionRelationships.test.ts`.
|
|
106
|
-
|
|
107
|
-
## 18. Tests added / changed
|
|
108
|
-
|
|
109
|
-
51 new tests across 2 new files and additions to 4 existing files (0 pre-existing test modified or removed):
|
|
110
|
-
|
|
111
|
-
- `externalReferenceRegions.test.ts` (18 tests): derived geometry correctness/non-contradiction, id pattern/length/duplicate rejection, finite/negative/zero-size rejection, multi-region acceptance, out-of-bounds rejection (with exact-boundary acceptance), region-count bound (exactly-max accepted, one-over rejected), immutability.
|
|
112
|
-
- `externalReferenceRegionRelationships.test.ts` (13 tests): horizontal/vertical order, overlap, relative width, geometric fit (with an explicit assertion that no DOM-containment-shaped field exists), vertical sequencing directed by geometry, determinism, evidence-path provenance (never `targetEvidence`), pair-count bound, tolerance validation, single-region no-relationships case, immutability, graph validator accept/reject.
|
|
113
|
-
- `externalReferenceIdentity.test.ts` (+8 tests): backward-compatible omission, same-content-same-identity, geometry-change/add/remove/rename-changes-identity, authored-order-is-semantic.
|
|
114
|
-
- `externalReference.test.ts` (+6 tests): legacy-no-regions-field validity, valid regions on both lifecycle variants, out-of-bounds rejection with a `"regions:"`-prefixed reason, malformed-value rejection, duplicate-id rejection.
|
|
115
|
-
- `externalReferencePersistenceService.test.ts` (+7 tests): import-with-regions persists them with correct count, regionless import has no `regions` key, out-of-bounds/duplicate-id import rejection (nothing persisted), approval carries regions forward (and forward "no regions" correctly), approved-artifact-manifest-never-mutated-by-later-activity.
|
|
116
|
-
- `cliExternalReference.test.ts` (+5 tests): end-to-end `--regions-file` import+approve, legacy no-flag invocation reports zero regions, out-of-bounds region CLI rejection, malformed-`--regions-file` rejection (bad JSON, array root, unknown top-level field).
|
|
117
|
-
|
|
118
|
-
## 19. Validation results
|
|
119
|
-
|
|
120
|
-
All on commit `c5c2eef` on `implementation/v0.7-reference-regions`:
|
|
121
|
-
|
|
122
|
-
| Command | Result |
|
|
123
|
-
|---|---|
|
|
124
|
-
| `npm run typecheck` | PASS |
|
|
125
|
-
| `npm run lint` | PASS |
|
|
126
|
-
| `npm test` | PASS — 40 files, 719 tests (up from 38/668) |
|
|
127
|
-
| `npm run build` | PASS (both new modules compiled into `dist/`) |
|
|
128
|
-
| `npm run check:docs` | PASS (17 required files) |
|
|
129
|
-
| `git diff --check` | PASS |
|
|
130
|
-
| `npm pack --dry-run` | PASS (166 files, 304.2 kB / 1.3 MB unpacked; both new modules present in the tarball listing) |
|
|
131
|
-
| `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count) |
|
|
132
|
-
| `npm run test:security` | PASS — 68 tests |
|
|
133
|
-
|
|
134
|
-
## 20. Regression results
|
|
135
|
-
|
|
136
|
-
- **Prompt 1 tests**: all 668 pre-existing tests (including every `externalReference*`/`cliExternalReference` test) pass unmodified.
|
|
137
|
-
- **v0.4 relationship/comparison tests**: `relationships.test.ts`, `relationshipDerivation.test.ts`, `comparisonEngine.test.ts` — 132 combined tests (with `frontendContractEvaluation.test.ts`) pass unchanged; the six predicate functions' formulas are byte-identical to before (only their export visibility changed).
|
|
138
|
-
- **v0.5 dependent tests**: `frontendContractEvaluation.test.ts`, `frontendContractPersistence.test.ts`, `frontendContracts.test.ts` all pass unchanged (part of the full 719-test run).
|
|
139
|
-
- **v0.6 tests**: `boundedAgentContext*.test.ts` (4 files) pass unchanged.
|
|
140
|
-
|
|
141
|
-
## 21. Boundedness
|
|
142
|
-
|
|
143
|
-
- **Region bound**: `MAX_REFERENCE_REGIONS = 20` per artifact — explicit, tested at exactly-max (accepted) and one-over (rejected, no partial acceptance).
|
|
144
|
-
- **Relationship/pair bound**: `MAX_REFERENCE_REGION_PAIRS = 190` pairs × 6 families = `MAX_REFERENCE_REGION_RELATIONSHIP_RECORDS = 1140` records maximum — explicit, tested at exactly-max region count.
|
|
145
|
-
- **One-over behavior**: both the region-collection validator and the relationship-derivation function reject a one-over-bound input outright (`{valid:false}` / `{ok:false}`) — never a silently truncated partial result.
|
|
146
|
-
|
|
147
|
-
## 22. Identity tests
|
|
148
|
-
|
|
149
|
-
- **Path-independence**: `buildExternalReferenceRequestIdentity` takes no path argument at all (structurally impossible for an operational path to leak in); confirmed at the application level by `'produces the same referenceRequestId for byte-identical images from different output roots'` (extended in spirit by the new region tests, which exercise the same function directly).
|
|
150
|
-
- **Region-content identity behavior**: same content → same identity (tested); geometry change → different identity (tested); add/remove region → different identity (tested, both directions); rename → different identity (tested); authored order → part of identity (tested); omission of the parameter entirely → byte-identical to the pre-Prompt-2 hash (tested explicitly).
|
|
151
|
-
|
|
152
|
-
## 23. Immutability
|
|
153
|
-
|
|
154
|
-
- No code path in `externalReferencePersistenceService.ts` opens an existing manifest file for writing — `writeExternalReferenceArtifact` always writes to a fresh temp directory and renames to a fresh `referenceId` directory that is verified not to already exist (Prompt 1 behavior, unchanged and re-verified this stage).
|
|
155
|
-
- Direct test proof: importing a reference with regions, approving it, then performing unrelated later activity in the same output directory, re-reads the approved artifact's manifest byte-for-byte identical to before that later activity (`'an approved artifact's manifest is never mutated by any later import/approve call'`).
|
|
156
|
-
- `approveExternalReference` reads the imported artifact's `regions` and copies the array reference into a new object literal — it never mutates the `imported` object in memory either (confirmed by TypeScript's structural typing plus the existing "never mutates" test convention carried into the new tests).
|
|
157
|
-
|
|
158
|
-
## 24. Security / privacy impact
|
|
159
|
-
|
|
160
|
-
No new network calls, no vision/AI API calls, no OCR, no automatic segmentation. `--regions-file`'s path is never persisted or included in any identity (same convention as `--targets-file`/`--contract-file`) — only its parsed, validated `regions` content reaches the artifact. Region geometry is plain numeric data; no new file-system write boundary was introduced (regions are embedded directly in the existing `manifest.json`, never a separate file). The unsupported-top-level-field rejection on `--regions-file`'s root prevents silently ignored/misinterpreted malformed input.
|
|
161
|
-
|
|
162
|
-
## 25. Documentation changes
|
|
163
|
-
|
|
164
|
-
Additive sections only: `docs/CONTRACTS.md` ("v0.7 Prompt 2 explicit reference regions and relationships" — the primary contract reference, with the exact type shapes and key rules), `docs/ARCHITECTURE.md` (relationship of the new region/relationship modules to the existing engine boundaries and to Prompt 1), `docs/CURRENT_STATE.md` ("v0.7 Prompt 2 status" section, plus updated "Not implemented"/"Next target"), `docs/WORKFLOWS.md` (the extended import/approve workflow diagram, the new relationship-derivation description, and a correction to the "Planned v0.7 reference-driven correction flow" first bullets marking regions/relationships as now implemented). `docs/ROADMAP.md` was **not** touched. `docs/COMMANDS.md` was **not** touched, consistent with Prompt 1's own precedent of not documenting `import-reference`/`approve-reference` there.
|
|
165
|
-
|
|
166
|
-
## 26. Tooling incidents
|
|
167
|
-
|
|
168
|
-
None this stage. No background/subagent write occurred during Prompt 2's implementation. The Prompt 1 speculative-write incident is historical (recorded in the Prompt 1 report) and its stash was confirmed untouched at both the start and end of this stage.
|
|
169
|
-
|
|
170
|
-
## 27. Inherited orchestrator heuristic issue
|
|
171
|
-
|
|
172
|
-
Not re-encountered as a product problem. Per instruction, `my-dev-kit-orchestrator` was not modified and no test was rewritten to satisfy its responsibility-mapping heuristic; this stage used `DIRECT_IMPLEMENTATION` and did not invoke the orchestrator's stage-context workflow at all, so the heuristic gap noted in Prompt 1 did not arise here.
|
|
173
|
-
|
|
174
|
-
## 28. Out-of-scope confirmation
|
|
175
|
-
|
|
176
|
-
This stage did **not** implement: selected design requirements, requested/expected-dependent/protected/preserved requirement mapping, design tolerance semantics, reference-evidence adequacy or sufficiency scoring, theme/application-state identity or compatibility evaluation, reference-region↔runtime-target binding, reference-vs-candidate fidelity evaluation, style/color/typography/pixel/image-similarity comparison, bounded visual correction packets, coding-agent invocation or correction, candidate rerender orchestration, the viewer, annotation, automatic segmentation/computer vision, or screenshot-to-code/raster-to-vector reconstruction. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not implemented here" documentation comments).
|
|
177
|
-
|
|
178
|
-
## 29. Known limitations
|
|
179
|
-
|
|
180
|
-
1. Normalized (0–1 range) region coordinates are not implemented — deliberately deferred per request section 18; if needed later, they should be derived on demand from the canonical rectangle plus image dimensions, never a second stored source of truth.
|
|
181
|
-
2. `--regions-file` is the only public entry point for authoring regions in this stage — there is no way to retroactively attach regions to an already-imported Prompt 1 reference without re-supplying the original image bytes and re-running `import-reference`. This was a deliberate minimal-surface choice (Option A from the architecture review, not Option B); re-supplying a local image file is cheap and the resulting artifact is a legitimately distinct logical reference, not a duplicate.
|
|
182
|
-
3. No fuzz-testing of adversarial region JSON beyond the specific malformed-shape cases already covered (bad JSON, array root, unknown field, non-object entry) — consistent with Prompt 1's own documented fuzz-testing scope boundary.
|
|
183
|
-
|
|
184
|
-
## 30. Remaining risks
|
|
185
|
-
|
|
186
|
-
- The `MAX_REFERENCE_REGIONS = 20` bound is a coincidental value-match with `request/request.ts`'s `MAX_TARGETS`, independently owned. A future change to one must not be assumed to require changing the other; this report documents that they are not structurally coupled, to prevent an accidental future assumption otherwise.
|
|
187
|
-
- Because relationships are never persisted, every consumer that wants them must call `deriveReferenceRegionRelationships` itself. Prompt 3+ should be aware this is a deliberate choice (avoids drift) rather than an oversight, so it is not "fixed" by prematurely adding persistence.
|
|
188
|
-
|
|
189
|
-
## 31. Exact next action
|
|
190
|
-
|
|
191
|
-
**v0.7 Prompt 3** — selected design requirements, tolerance semantics, and reference-evidence adequacy.
|
|
192
|
-
|
|
193
|
-
## 32. Report path
|
|
194
|
-
|
|
195
|
-
`docs/reports/v0.7-reference-regions-prompt2.md` (this file)
|
|
1
|
+
# v0.7 Prompt 2 — Explicit Reference Regions, Geometry, and Reusable Reference Relationships
|
|
2
|
+
|
|
3
|
+
## 1. Verdict
|
|
4
|
+
|
|
5
|
+
**PASS_V0_7_REFERENCE_REGIONS_PROMPT2**
|
|
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-regions`
|
|
14
|
+
|
|
15
|
+
## 4. Starting head
|
|
16
|
+
|
|
17
|
+
`ba61897e597451ae34f81583cbcffc8447b09738`
|
|
18
|
+
|
|
19
|
+
## 5. Prompt 1 base head
|
|
20
|
+
|
|
21
|
+
`ba61897e597451ae34f81583cbcffc8447b09738` (same commit — the branch was created directly from Prompt 1's completed, clean state; verified as an ancestor via `git merge-base --is-ancestor`)
|
|
22
|
+
|
|
23
|
+
## 6. Ending head
|
|
24
|
+
|
|
25
|
+
`c5c2eef66ddecb0365c2ced7d9a25f1b9e16c210`
|
|
26
|
+
|
|
27
|
+
## 7. Git status
|
|
28
|
+
|
|
29
|
+
Clean at the ending head. The Prompt 1 speculative research-agent stash (`stray-fork-writes-preserved-for-reference: ...`) remains present, untouched, unapplied, and unmined throughout this stage — verified with `git stash list` before and after implementation.
|
|
30
|
+
|
|
31
|
+
## 8. Resolved my-dev-kit version
|
|
32
|
+
|
|
33
|
+
`@dailephd/my-dev-kit@1.12.3` (unchanged from Prompt 1 — still the latest published version at execution start; re-checked via `npm view @dailephd/my-dev-kit version`, not assumed from memory)
|
|
34
|
+
|
|
35
|
+
## 9. Fresh index path / ID
|
|
36
|
+
|
|
37
|
+
`.my-dev-kit/index-prompt2` — a fresh index built this stage (`my-dev-kit index --root . --src src --out .my-dev-kit/index-prompt2 --call-graph --json`), independent of Prompt 1's `.my-dev-kit/index`/`index-after` indexes (not reused as the new-behavior evidence source, per instruction). This tooling directory is gitignored and was never staged.
|
|
38
|
+
|
|
39
|
+
## 10. Prompt 1 contract verified
|
|
40
|
+
|
|
41
|
+
Read directly from the maintained repository (not from the Prompt 1 report alone) before any change:
|
|
42
|
+
|
|
43
|
+
- `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (`ImportedExternalReferenceArtifact` | `ApprovedExternalReferenceArtifact`), `isValidExternalReferenceArtifact`, `isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact`, `EXTERNAL_REFERENCE_ARTIFACT_KIND`/`EXTERNAL_REFERENCE_SCHEMA_VERSION`.
|
|
44
|
+
- `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`/`buildExternalReferenceInstanceIdentity`.
|
|
45
|
+
- `src/domain/externalReferenceImage.ts` — format/dimension boundary (unchanged this stage).
|
|
46
|
+
- `src/artifacts/externalReferenceArtifactWriter.ts`/`Reader.ts` — atomic persistence (unchanged this stage).
|
|
47
|
+
- `src/application/externalReferencePersistenceService.ts` — `importExternalReference`/`approveExternalReference`.
|
|
48
|
+
- `src/cli.ts` — `import-reference`/`approve-reference` commands, their help text, arg parsers, and dispatch.
|
|
49
|
+
- `tests/unit/externalReference*.test.ts`, `cliExternalReference.test.ts` — the full Prompt 1 test suite (668 tests at the time), confirmed still green before touching anything.
|
|
50
|
+
|
|
51
|
+
The Prompt 1 report and the actual implementation matched exactly — no `BLOCKED_PROMPT1_IMPLEMENTATION_REPORT_MISMATCH` condition was encountered.
|
|
52
|
+
|
|
53
|
+
## 11. Region model
|
|
54
|
+
|
|
55
|
+
- **Type name**: `ReferenceRegion { id: string; rectangle: ReferenceRegionRectangle }`, `ReferenceRegionRectangle { x, y, width, height }` (`src/domain/externalReferenceRegions.ts`).
|
|
56
|
+
- **Stable region ID semantics**: `^[A-Za-z0-9_-]{1,64}$`, unique case-insensitively within one artifact — reused verbatim from `request/request.ts`'s target-name convention (exact pattern and dedup rule).
|
|
57
|
+
- **Canonical coordinate representation**: only `{x, y, width, height}` is authored/canonical; everything else is derived.
|
|
58
|
+
- **Coordinate origin/unit**: top-left of the reference image; x rightward, y downward; unit is reference-image pixels (explicitly not CSS pixels); coordinates may be fractional.
|
|
59
|
+
- **Numeric rules**: `x`/`y` finite and ≥ 0; `width`/`height` finite and > 0 (zero/negative/non-finite all rejected, never clamped).
|
|
60
|
+
- **Image-boundary rule**: a region's derived `right`/`bottom` must not exceed the owning image's own already-validated width/height; rejected outright otherwise, exact-boundary regions accepted.
|
|
61
|
+
- **Region-count bound**: `MAX_REFERENCE_REGIONS = 20` — a maximum capacity only, matching `request/request.ts`'s `MAX_TARGETS` value (independently owned constant, not imported/coupled).
|
|
62
|
+
- **Deterministic ordering rule**: authored array order is preserved and treated as semantic (never re-sorted), mirroring `domain/identity.ts`'s treatment of configured targets — both for identity hashing and for relationship derivation.
|
|
63
|
+
|
|
64
|
+
## 12. Derived geometry
|
|
65
|
+
|
|
66
|
+
- **Exact derived anchors**: `deriveReferenceRegionGeometry(rectangle) -> { x, y, width, height, right, bottom, centerX, centerY }` — a pure function, called fresh every time.
|
|
67
|
+
- **What is persisted**: only `{id, rectangle: {x, y, width, height}}` per region, inside the artifact's optional `regions` array.
|
|
68
|
+
- **What is computed**: `right`, `bottom`, `centerX`, `centerY` — never stored, so `x + width` can never disagree with a stored `right` (there is no stored `right`).
|
|
69
|
+
- **Normalized-coordinate decision**: not implemented in this stage. No normalized (`x / imageWidth`, etc.) field exists anywhere; if useful later, it would be derived on demand from the canonical rectangle plus the artifact's own image dimensions, never a second stored source of truth. This was a deliberate scope decision (request section 18 explicitly permits deferring it), not an oversight.
|
|
70
|
+
|
|
71
|
+
## 13. Relationship precedent review
|
|
72
|
+
|
|
73
|
+
- **Exact v0.4 owners inspected**: `src/domain/relationships.ts` (full file, 440 lines before this stage) — `PAIRWISE_RELATIONSHIP_KINDS`, `EvidenceReference`/`isValidEvidenceReference`, `LayoutRelationshipGraph`, `MAX_CONFIGURED_TARGETS_FOR_RELATIONSHIPS`/`MAX_PAIRWISE_RELATIONSHIP_RECORDS`, and the six pure predicates `horizontalOrderOf`/`verticalOrderOf`/`areaOverlapOf`/`relativeWidthOf`/`geometricFitOf`/`verticalSequenceOf` plus `deriveLayoutRelationships`'s pairwise-loop structure.
|
|
74
|
+
- **Relationship families reused**: all six geometry-only families — horizontal order, vertical order, area overlap, relative width, geometric fit, vertical sequencing.
|
|
75
|
+
- **Relationship families rejected as runtime-only**: `document-width-fits-viewport`/`document-width-exceeds-viewport` (page-level, needs document/viewport evidence a static image doesn't have); DOM containment (`TargetContainment` in `schema.ts` — explicitly documented there as never a layout/relationship graph concept, and an external image exposes no DOM at all); scroll ownership, runtime visibility, browser clipping, and semantic/accessibility relationships (all require live browser evidence).
|
|
76
|
+
- **Shared geometry primitives extracted**: yes — the six predicate functions were changed from private to `export`ed in `relationships.ts` with **zero formula changes** (verified by diff: only the `function` keyword gained `export`, one added a doc comment). `PAIRWISE_RELATIONSHIP_KINDS`, `EvidenceReference`, and `isValidEvidenceReference` were already exported and are imported as-is.
|
|
77
|
+
- **Proof v0.4 semantics did not change**: `npm test` (full suite), `npm run test:browser`, and a targeted run of `tests/unit/relationships.test.ts`, `relationshipDerivation.test.ts`, `comparisonEngine.test.ts`, and `frontendContractEvaluation.test.ts` all pass with identical counts to before this stage (132 tests across those four files, unchanged). No `BLOCKED_RELATIONSHIP_REUSE_REQUIRES_SEMANTIC_CHANGE` condition was encountered.
|
|
78
|
+
|
|
79
|
+
## 14. Reference relationship model
|
|
80
|
+
|
|
81
|
+
- **Type/function names**: `ReferenceRegionRelationship { kind: PairwiseRelationshipKind; subjectRegion: string; relatedRegion: string; evidence: EvidenceReference[] }`, `ReferenceRegionRelationshipGraph { referenceRequestId, geometryTolerancePx, regions: string[], pairwiseRelationships }`, `deriveReferenceRegionRelationships(referenceRequestId, regions, options)`, `isValidReferenceRegionRelationship`/`isValidReferenceRegionRelationshipGraph` (`src/domain/externalReferenceRegionRelationships.ts`).
|
|
82
|
+
- **Bounds**: `MAX_REFERENCE_REGION_PAIRS = 20*19/2 = 190`, `REFERENCE_REGION_RELATIONSHIP_FAMILY_COUNT = 6`, `MAX_REFERENCE_REGION_RELATIONSHIP_RECORDS = 1140` — the same bounding shape as `relationships.ts`'s `MAX_PAIRWISE_RELATIONSHIP_RECORDS`, over `MAX_REFERENCE_REGIONS` instead of the runtime-target limit.
|
|
83
|
+
- **Provenance model**: `evidence: [{ path: 'regions.<id>.rectangle' }, ...]` — never a `targetEvidence`/browser path; a relationship never claims runtime-target or DOM provenance (verified directly by test).
|
|
84
|
+
- **Deterministic ordering**: earlier-authored region is always `subjectRegion` for every family except `follows-vertically` (direction decided by actual geometry, matching `deriveLayoutRelationships` exactly); same input always produces the identical graph (verified by test).
|
|
85
|
+
- **Persistence decision**: relationships are **not persisted** on the artifact — always re-derivable on demand from the artifact's own `regions` field, eliminating any possibility of a stored relationship graph drifting from the region data.
|
|
86
|
+
|
|
87
|
+
## 15. Schema / artifact decision
|
|
88
|
+
|
|
89
|
+
- **Prompt 1 artifact schema changed**: yes, additively — one new optional field, `regions?: ReferenceRegion[]`, on both `ImportedExternalReferenceArtifact` and `ApprovedExternalReferenceArtifact`.
|
|
90
|
+
- **Schema version decision**: **no bump** — `EXTERNAL_REFERENCE_SCHEMA_VERSION` remains `'1.0.0'`. Rationale: the field is genuinely optional and additive with no other coupled behavior change; bumping would force a strict-equality version check (this repository's established `isValid*Artifact` convention) to reject every Prompt 1 artifact, which directly contradicts the explicit "legacy Prompt 1 reference remains valid/readable" requirement. This differs from the observation family's historical per-batch version-bump convention; documented here as a deliberate, evidence-based departure, not an oversight.
|
|
91
|
+
- **Historical Prompt 1 artifacts remain readable/valid**: yes — verified directly by test (`'a legacy (Prompt 1) artifact with no regions field at all remains valid'`), and by construction (`isValidExternalReferenceArtifact` only validates `regions` when the key is present).
|
|
92
|
+
- **Structured regions and logical identity**: `buildExternalReferenceRequestIdentity` gained an additive, optional trailing `regions` parameter. When omitted, it is left out of the hashed semantic view entirely (not defaulted to `null`, unlike `supersedesReferenceId`) so every Prompt 1 call site — and every Prompt 2 call with no regions — produces the byte-identical hash Prompt 1 already produced. When present, region content (id, rectangle, and authored order) is fully identity-bearing.
|
|
93
|
+
- **Immutable approved artifacts preserved**: `approveExternalReference` carries `imported.regions` forward verbatim (a plain copy, never re-validated or re-derived) into a **new** artifact instance; the imported artifact's own manifest is never opened for writing again. No code path in this stage ever mutates an existing persisted manifest.
|
|
94
|
+
|
|
95
|
+
## 16. Public interface
|
|
96
|
+
|
|
97
|
+
- **CLI changes**: `import-reference` gained an optional `--regions-file <json-file>` (root shape `{ "regions": [...] }`, validated by a new `loadRegionsFile` mirroring `loadTargetsFile` exactly — object root, exact allow-listed top-level field, JSON parse/read errors surfaced as `error:` lines). Both `import-reference` and `approve-reference` now print an additional `Regions: <count>` line. No existing flag, argument, or exit-code behavior changed.
|
|
98
|
+
- **Programmatic export changes**: `src/index.ts` additively exports the complete new region/relationship type, constant, and function surface (`ReferenceRegion`, `ReferenceRegionRectangle`, `ReferenceRegionGeometry`, `deriveReferenceRegionGeometry`, `isValidReferenceRegion(s)`, `REFERENCE_REGION_ID_PATTERN`, `MAX_REFERENCE_REGIONS`, `ReferenceRegionRelationship`, `ReferenceRegionRelationshipGraph`, `deriveReferenceRegionRelationships`, `isValidReferenceRegionRelationship(Graph)`, plus the `MAX_REFERENCE_REGION_*` bound constants), and the two Prompt 1 type guards (`isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact`) that had not yet been exported. `ImportExternalReferenceOptions` gained an additive `regions?` field; both application-result types gained an additive `regionCount: number` field.
|
|
99
|
+
- **Exact user/config input shape**: `{ "regions": [ { "id": "current-page-card", "rectangle": { "x": 28, "y": 92, "width": 424, "height": 82 } }, ... ] }` — chosen after precedent review (matches `--targets-file`'s object-root-wrapper convention) rather than the prompt's illustrative nested YAML-style example.
|
|
100
|
+
- **Backward compatibility**: every Prompt 1 CLI invocation and every existing `ApplicationImportExternalReferenceResult`/`ApplicationApproveExternalReferenceResult` consumer reading the pre-existing fields continues to work unchanged — verified by the full pre-existing test suite passing unmodified, plus a dedicated test confirming a regionless import reports `regionCount: 0` and no `regions` key on the manifest.
|
|
101
|
+
|
|
102
|
+
## 17. Files changed
|
|
103
|
+
|
|
104
|
+
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/domain/relationships.ts` (six predicates made `export`, formulas unchanged), `src/index.ts`, `tests/unit/cliExternalReference.test.ts`, `tests/unit/externalReference.test.ts`, `tests/unit/externalReferenceIdentity.test.ts`, `tests/unit/externalReferencePersistenceService.test.ts`.
|
|
105
|
+
New: `src/domain/externalReferenceRegions.ts`, `src/domain/externalReferenceRegionRelationships.ts`, `tests/unit/externalReferenceRegions.test.ts`, `tests/unit/externalReferenceRegionRelationships.test.ts`.
|
|
106
|
+
|
|
107
|
+
## 18. Tests added / changed
|
|
108
|
+
|
|
109
|
+
51 new tests across 2 new files and additions to 4 existing files (0 pre-existing test modified or removed):
|
|
110
|
+
|
|
111
|
+
- `externalReferenceRegions.test.ts` (18 tests): derived geometry correctness/non-contradiction, id pattern/length/duplicate rejection, finite/negative/zero-size rejection, multi-region acceptance, out-of-bounds rejection (with exact-boundary acceptance), region-count bound (exactly-max accepted, one-over rejected), immutability.
|
|
112
|
+
- `externalReferenceRegionRelationships.test.ts` (13 tests): horizontal/vertical order, overlap, relative width, geometric fit (with an explicit assertion that no DOM-containment-shaped field exists), vertical sequencing directed by geometry, determinism, evidence-path provenance (never `targetEvidence`), pair-count bound, tolerance validation, single-region no-relationships case, immutability, graph validator accept/reject.
|
|
113
|
+
- `externalReferenceIdentity.test.ts` (+8 tests): backward-compatible omission, same-content-same-identity, geometry-change/add/remove/rename-changes-identity, authored-order-is-semantic.
|
|
114
|
+
- `externalReference.test.ts` (+6 tests): legacy-no-regions-field validity, valid regions on both lifecycle variants, out-of-bounds rejection with a `"regions:"`-prefixed reason, malformed-value rejection, duplicate-id rejection.
|
|
115
|
+
- `externalReferencePersistenceService.test.ts` (+7 tests): import-with-regions persists them with correct count, regionless import has no `regions` key, out-of-bounds/duplicate-id import rejection (nothing persisted), approval carries regions forward (and forward "no regions" correctly), approved-artifact-manifest-never-mutated-by-later-activity.
|
|
116
|
+
- `cliExternalReference.test.ts` (+5 tests): end-to-end `--regions-file` import+approve, legacy no-flag invocation reports zero regions, out-of-bounds region CLI rejection, malformed-`--regions-file` rejection (bad JSON, array root, unknown top-level field).
|
|
117
|
+
|
|
118
|
+
## 19. Validation results
|
|
119
|
+
|
|
120
|
+
All on commit `c5c2eef` on `implementation/v0.7-reference-regions`:
|
|
121
|
+
|
|
122
|
+
| Command | Result |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `npm run typecheck` | PASS |
|
|
125
|
+
| `npm run lint` | PASS |
|
|
126
|
+
| `npm test` | PASS — 40 files, 719 tests (up from 38/668) |
|
|
127
|
+
| `npm run build` | PASS (both new modules compiled into `dist/`) |
|
|
128
|
+
| `npm run check:docs` | PASS (17 required files) |
|
|
129
|
+
| `git diff --check` | PASS |
|
|
130
|
+
| `npm pack --dry-run` | PASS (166 files, 304.2 kB / 1.3 MB unpacked; both new modules present in the tarball listing) |
|
|
131
|
+
| `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count) |
|
|
132
|
+
| `npm run test:security` | PASS — 68 tests |
|
|
133
|
+
|
|
134
|
+
## 20. Regression results
|
|
135
|
+
|
|
136
|
+
- **Prompt 1 tests**: all 668 pre-existing tests (including every `externalReference*`/`cliExternalReference` test) pass unmodified.
|
|
137
|
+
- **v0.4 relationship/comparison tests**: `relationships.test.ts`, `relationshipDerivation.test.ts`, `comparisonEngine.test.ts` — 132 combined tests (with `frontendContractEvaluation.test.ts`) pass unchanged; the six predicate functions' formulas are byte-identical to before (only their export visibility changed).
|
|
138
|
+
- **v0.5 dependent tests**: `frontendContractEvaluation.test.ts`, `frontendContractPersistence.test.ts`, `frontendContracts.test.ts` all pass unchanged (part of the full 719-test run).
|
|
139
|
+
- **v0.6 tests**: `boundedAgentContext*.test.ts` (4 files) pass unchanged.
|
|
140
|
+
|
|
141
|
+
## 21. Boundedness
|
|
142
|
+
|
|
143
|
+
- **Region bound**: `MAX_REFERENCE_REGIONS = 20` per artifact — explicit, tested at exactly-max (accepted) and one-over (rejected, no partial acceptance).
|
|
144
|
+
- **Relationship/pair bound**: `MAX_REFERENCE_REGION_PAIRS = 190` pairs × 6 families = `MAX_REFERENCE_REGION_RELATIONSHIP_RECORDS = 1140` records maximum — explicit, tested at exactly-max region count.
|
|
145
|
+
- **One-over behavior**: both the region-collection validator and the relationship-derivation function reject a one-over-bound input outright (`{valid:false}` / `{ok:false}`) — never a silently truncated partial result.
|
|
146
|
+
|
|
147
|
+
## 22. Identity tests
|
|
148
|
+
|
|
149
|
+
- **Path-independence**: `buildExternalReferenceRequestIdentity` takes no path argument at all (structurally impossible for an operational path to leak in); confirmed at the application level by `'produces the same referenceRequestId for byte-identical images from different output roots'` (extended in spirit by the new region tests, which exercise the same function directly).
|
|
150
|
+
- **Region-content identity behavior**: same content → same identity (tested); geometry change → different identity (tested); add/remove region → different identity (tested, both directions); rename → different identity (tested); authored order → part of identity (tested); omission of the parameter entirely → byte-identical to the pre-Prompt-2 hash (tested explicitly).
|
|
151
|
+
|
|
152
|
+
## 23. Immutability
|
|
153
|
+
|
|
154
|
+
- No code path in `externalReferencePersistenceService.ts` opens an existing manifest file for writing — `writeExternalReferenceArtifact` always writes to a fresh temp directory and renames to a fresh `referenceId` directory that is verified not to already exist (Prompt 1 behavior, unchanged and re-verified this stage).
|
|
155
|
+
- Direct test proof: importing a reference with regions, approving it, then performing unrelated later activity in the same output directory, re-reads the approved artifact's manifest byte-for-byte identical to before that later activity (`'an approved artifact's manifest is never mutated by any later import/approve call'`).
|
|
156
|
+
- `approveExternalReference` reads the imported artifact's `regions` and copies the array reference into a new object literal — it never mutates the `imported` object in memory either (confirmed by TypeScript's structural typing plus the existing "never mutates" test convention carried into the new tests).
|
|
157
|
+
|
|
158
|
+
## 24. Security / privacy impact
|
|
159
|
+
|
|
160
|
+
No new network calls, no vision/AI API calls, no OCR, no automatic segmentation. `--regions-file`'s path is never persisted or included in any identity (same convention as `--targets-file`/`--contract-file`) — only its parsed, validated `regions` content reaches the artifact. Region geometry is plain numeric data; no new file-system write boundary was introduced (regions are embedded directly in the existing `manifest.json`, never a separate file). The unsupported-top-level-field rejection on `--regions-file`'s root prevents silently ignored/misinterpreted malformed input.
|
|
161
|
+
|
|
162
|
+
## 25. Documentation changes
|
|
163
|
+
|
|
164
|
+
Additive sections only: `docs/CONTRACTS.md` ("v0.7 Prompt 2 explicit reference regions and relationships" — the primary contract reference, with the exact type shapes and key rules), `docs/ARCHITECTURE.md` (relationship of the new region/relationship modules to the existing engine boundaries and to Prompt 1), `docs/CURRENT_STATE.md` ("v0.7 Prompt 2 status" section, plus updated "Not implemented"/"Next target"), `docs/WORKFLOWS.md` (the extended import/approve workflow diagram, the new relationship-derivation description, and a correction to the "Planned v0.7 reference-driven correction flow" first bullets marking regions/relationships as now implemented). `docs/ROADMAP.md` was **not** touched. `docs/COMMANDS.md` was **not** touched, consistent with Prompt 1's own precedent of not documenting `import-reference`/`approve-reference` there.
|
|
165
|
+
|
|
166
|
+
## 26. Tooling incidents
|
|
167
|
+
|
|
168
|
+
None this stage. No background/subagent write occurred during Prompt 2's implementation. The Prompt 1 speculative-write incident is historical (recorded in the Prompt 1 report) and its stash was confirmed untouched at both the start and end of this stage.
|
|
169
|
+
|
|
170
|
+
## 27. Inherited orchestrator heuristic issue
|
|
171
|
+
|
|
172
|
+
Not re-encountered as a product problem. Per instruction, `my-dev-kit-orchestrator` was not modified and no test was rewritten to satisfy its responsibility-mapping heuristic; this stage used `DIRECT_IMPLEMENTATION` and did not invoke the orchestrator's stage-context workflow at all, so the heuristic gap noted in Prompt 1 did not arise here.
|
|
173
|
+
|
|
174
|
+
## 28. Out-of-scope confirmation
|
|
175
|
+
|
|
176
|
+
This stage did **not** implement: selected design requirements, requested/expected-dependent/protected/preserved requirement mapping, design tolerance semantics, reference-evidence adequacy or sufficiency scoring, theme/application-state identity or compatibility evaluation, reference-region↔runtime-target binding, reference-vs-candidate fidelity evaluation, style/color/typography/pixel/image-similarity comparison, bounded visual correction packets, coding-agent invocation or correction, candidate rerender orchestration, the viewer, annotation, automatic segmentation/computer vision, or screenshot-to-code/raster-to-vector reconstruction. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not implemented here" documentation comments).
|
|
177
|
+
|
|
178
|
+
## 29. Known limitations
|
|
179
|
+
|
|
180
|
+
1. Normalized (0–1 range) region coordinates are not implemented — deliberately deferred per request section 18; if needed later, they should be derived on demand from the canonical rectangle plus image dimensions, never a second stored source of truth.
|
|
181
|
+
2. `--regions-file` is the only public entry point for authoring regions in this stage — there is no way to retroactively attach regions to an already-imported Prompt 1 reference without re-supplying the original image bytes and re-running `import-reference`. This was a deliberate minimal-surface choice (Option A from the architecture review, not Option B); re-supplying a local image file is cheap and the resulting artifact is a legitimately distinct logical reference, not a duplicate.
|
|
182
|
+
3. No fuzz-testing of adversarial region JSON beyond the specific malformed-shape cases already covered (bad JSON, array root, unknown field, non-object entry) — consistent with Prompt 1's own documented fuzz-testing scope boundary.
|
|
183
|
+
|
|
184
|
+
## 30. Remaining risks
|
|
185
|
+
|
|
186
|
+
- The `MAX_REFERENCE_REGIONS = 20` bound is a coincidental value-match with `request/request.ts`'s `MAX_TARGETS`, independently owned. A future change to one must not be assumed to require changing the other; this report documents that they are not structurally coupled, to prevent an accidental future assumption otherwise.
|
|
187
|
+
- Because relationships are never persisted, every consumer that wants them must call `deriveReferenceRegionRelationships` itself. Prompt 3+ should be aware this is a deliberate choice (avoids drift) rather than an oversight, so it is not "fixed" by prematurely adding persistence.
|
|
188
|
+
|
|
189
|
+
## 31. Exact next action
|
|
190
|
+
|
|
191
|
+
**v0.7 Prompt 3** — selected design requirements, tolerance semantics, and reference-evidence adequacy.
|
|
192
|
+
|
|
193
|
+
## 32. Report path
|
|
194
|
+
|
|
195
|
+
`docs/reports/v0.7-reference-regions-prompt2.md` (this file)
|