@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.
Files changed (75) hide show
  1. package/CHANGELOG.md +490 -479
  2. package/LICENSE +21 -21
  3. package/README.md +375 -365
  4. package/dist/application/projectCheckService.d.ts +6 -0
  5. package/dist/application/projectCheckService.js +8 -1
  6. package/dist/application/projectCheckService.js.map +1 -1
  7. package/dist/application/projectWorkflowService.d.ts +7 -2
  8. package/dist/application/projectWorkflowService.js +10 -3
  9. package/dist/application/projectWorkflowService.js.map +1 -1
  10. package/dist/cli.js +510 -510
  11. package/dist/viewer/index.html +13 -13
  12. package/dist/viewer/sw.js +1 -1
  13. package/docs/ARCHITECTURE.md +1394 -1385
  14. package/docs/CI_CD.md +349 -338
  15. package/docs/COMMANDS.md +1035 -1026
  16. package/docs/CONTRACTS.md +1971 -1960
  17. package/docs/CURRENT_STATE.md +1277 -1252
  18. package/docs/DEVELOPMENT.md +240 -237
  19. package/docs/DOCUMENTATION_PRESERVATION_POLICY.md +50 -50
  20. package/docs/PROJECT_DESCRIPTION.md +2248 -2224
  21. package/docs/PROJECT_MILESTONES.md +2681 -2558
  22. package/docs/PROJECT_OVERVIEW.md +200 -196
  23. package/docs/QUICKSTART.md +100 -100
  24. package/docs/RELEASE.md +37 -36
  25. package/docs/ROADMAP.md +1105 -1034
  26. package/docs/SECURITY.md +297 -297
  27. package/docs/WORKFLOWS.md +806 -796
  28. package/docs/plans/v0.10-implementation-plan.md +1509 -1509
  29. package/docs/plans/v0.8-implementation-plan.md +655 -655
  30. package/docs/plans/v0.8.1-cli-usability-patch-plan.md +505 -505
  31. package/docs/plans/v0.9-implementation-plan.md +1529 -1529
  32. package/docs/plans/v0.9.1-implementation-plan.md +468 -468
  33. package/docs/reports/v0.10-batch1-visual-change-workflow-foundation.md +102 -102
  34. package/docs/reports/v0.10-batch2-project-composition-check-recording.md +103 -103
  35. package/docs/reports/v0.10-batch3-viewer-visual-change-workspace.md +93 -93
  36. package/docs/reports/v0.10-batch4-actual-frontend-entry.md +59 -59
  37. package/docs/reports/v0.10-batch5-reference-driven-entry.md +238 -238
  38. package/docs/reports/v0.10-batch6-coding-agent-handoff.md +85 -85
  39. package/docs/reports/v0.10-batch7-correction-review-acceptance.md +145 -145
  40. package/docs/reports/v0.10-batch8-integrated-acceptance.md +109 -109
  41. package/docs/reports/v0.10-implementation-completeness-documentation-reconciliation.md +344 -344
  42. package/docs/reports/v0.10-pre-release-readiness.md +120 -120
  43. package/docs/reports/v0.10-release-preparation.md +70 -70
  44. package/docs/reports/v0.10.1-project-check-baseline-context-implementation.md +86 -0
  45. package/docs/reports/v0.7-bounded-fidelity-context-prompt7.md +243 -243
  46. package/docs/reports/v0.7-implementation-completeness-documentation-reconciliation.md +497 -497
  47. package/docs/reports/v0.7-pre-release-readiness.md +337 -337
  48. package/docs/reports/v0.7-reference-binding-prompt5.md +223 -223
  49. package/docs/reports/v0.7-reference-compatibility-prompt4.md +234 -234
  50. package/docs/reports/v0.7-reference-correction-workflow-prompt8.md +222 -222
  51. package/docs/reports/v0.7-reference-fidelity-prompt6.md +216 -216
  52. package/docs/reports/v0.7-reference-foundation-prompt1.md +151 -151
  53. package/docs/reports/v0.7-reference-regions-prompt2.md +195 -195
  54. package/docs/reports/v0.7-reference-requirements-prompt3.md +217 -217
  55. package/docs/reports/v0.7-release-prep.md +423 -423
  56. package/docs/reports/v0.8-binding-fidelity-interaction-batch6.md +279 -279
  57. package/docs/reports/v0.8-bounded-context-correlation-batch7.md +233 -233
  58. package/docs/reports/v0.8-comparison-contract-inspection-batch4.md +279 -279
  59. package/docs/reports/v0.8-evidence-index-readers-batch2.md +247 -247
  60. package/docs/reports/v0.8-implementation-completeness-documentation-reconciliation.md +741 -741
  61. package/docs/reports/v0.8-integrated-viewer-acceptance-batch8.md +128 -128
  62. package/docs/reports/v0.8-observation-svg-inspection-batch3.md +223 -223
  63. package/docs/reports/v0.8-prerelease-readiness-cross-platform-security-code-rot.md +687 -687
  64. package/docs/reports/v0.8-reference-candidate-inspection-batch5.md +232 -232
  65. package/docs/reports/v0.8-viewer-runtime-pwa-batch1.md +278 -278
  66. package/docs/reports/v0.8.1-implementation-completeness-documentation-reconciliation.md +114 -114
  67. package/docs/reports/v0.8.1-prerelease-readiness-cross-platform-security-code-rot.md +170 -170
  68. package/docs/reports/v0.9-architecture-retrieval.md +14 -37
  69. package/docs/reports/v0.9-final-pre-release-readiness.md +209 -209
  70. package/docs/reports/v0.9-final-readiness-corrections.md +530 -530
  71. package/docs/reports/v0.9-pre-release-readiness.md +169 -169
  72. package/docs/reports/v0.9.1-batch1-pwa-hard-gate-isolation.md +359 -359
  73. package/docs/reports/v0.9.1-batch2-hard-gate-validation-integration.md +262 -262
  74. package/docs/reports/v0.9.1-pre-release-readiness.md +206 -206
  75. package/package.json +59 -59
@@ -1,151 +1,151 @@
1
- # v0.7 Prompt 1 — External Visual Reference Foundation
2
-
3
- ## 1. Verdict
4
-
5
- **PASS_V0_7_REFERENCE_FOUNDATION_PROMPT1**
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-foundation`
14
-
15
- ## 4. Starting head
16
-
17
- `be3e440e5f3570becde75717f9538c856e61cd97` (the tip of `docs/external-visual-reference-roadmap` / PR #7 at the time this stage began — the authoritative checkout containing the v0.7 external-reference roadmap)
18
-
19
- ## 5. Ending head
20
-
21
- `4a15baf732cb1e545185b7242f0af6d575ec7e0a`
22
-
23
- ## 6. Git status
24
-
25
- Clean at the ending head. `git diff --stat` against `package.json`/`package-lock.json` is empty — no dependency graph change. Only the 20 files listed in section 14 changed.
26
-
27
- ## 7. Resolved my-dev-kit version
28
-
29
- `@dailephd/my-dev-kit@1.12.3` (the unscoped `my-dev-kit` package on the public registry is a deprecated alias pointing at this scoped package)
30
-
31
- ## 8. Resolved orchestrator version
32
-
33
- `@dailephd/my-dev-kit-orchestrator@1.4.1` (the unscoped `my-dev-kit-orchestrator` package is likewise a deprecated alias)
34
-
35
- ## 9. FULL_STAGE_CONTEXT run ID / location
36
-
37
- `20260906T053538-v0-7-reference-foundation-prompt1`, at `.my-dev-kit-orchestrator/runs/20260906T053538-v0-7-reference-foundation-prompt1/` (gitignored, repository-local, not committed — matches this repository's existing `.gitignore` convention for `.my-dev-kit-orchestrator/`). All ten stage artifacts (RequestBrief, ArchitectureContextPacket, BehaviorModel, PseudocodePacket, TestStrategyPacket, ImplementationReport, TestImplementationReport, VerificationReport, JudgeReport, FinalReport) were produced there.
38
-
39
- ## 10. Architecture decision
40
-
41
- - **Chosen reference contract/artifact model**: a new, standalone **persisted** artifact family (not programmatic-only, unlike the v0.6 bounded-agent-context precedent). Persistence is justified by the request's own explicit forward-looking requirement (section 12A): later v0.7/v0.8/v0.9 stages need a stable, reloadable, approvable, supersedable reference identity across many separate invocations — unlike bounded-agent-context, which is a per-invocation projection over already-persisted upstream evidence and is consumed once, in-process.
42
- - **Chosen name**: `ExternalReferenceArtifact` — matching this repository's existing naming convention (`ObservationArtifact`, `ComparisonArtifact`) and the exact vocabulary already used throughout `docs/ROADMAP.md`/`docs/WORKFLOWS.md`/`docs/PROJECT_DESCRIPTION.md` ("external reference"), not the prompt's conceptual placeholder `ReferenceVisualArtifact`.
43
- - **Persistence decision**: `<outputLocation>/<referenceId>/manifest.json` (+ `reference.<ext>` only for an `'imported'` artifact), via the same atomic temp-dir-then-rename discipline as `writeObservationArtifact`/`writeComparisonArtifact`.
44
- - **Identity model**: `referenceRequestId` — deterministic sha256 over a canonicalized `{imageSha256, format, width, height, supersedesReferenceId}` view (never a path, label, or timestamp) — plus `referenceId`, a fresh nonce-suffixed instance identity per persisted write, exactly mirroring `identity.ts`/`comparisonIdentity.ts`/`frontendContractIdentity.ts`'s pattern (each module owning its own duplicated `canonicalize()`).
45
- - **Lifecycle model**: exactly two persisted states, `{state:'imported'}` and `{state:'approved'; approvedAt}`. There is **no literal `'superseded'` state** — supersession is represented only as a forward pointer (`supersedesReferenceId` on the newer artifact), so an existing persisted artifact's own manifest is never rewritten. This is a deliberate interpretation of the request's four-state conceptual model (section 12G), trading a literal reading for an unconditional immutability guarantee; it is flagged explicitly in the design artifacts and re-confirmed by the judge stage.
46
- - **Provenance model**: `producer` (name/version, via the existing `getProducerInfo()`), `provenance.importedAt` + optional `provenance.label` (pure metadata, never identity-bearing), and — for an approved artifact — a `sourceReference` back to the imported artifact's `{referenceId, referenceRequestId, producer, schemaVersion, image}`, mirroring `ComparisonSourceObservationReference`'s exact shape.
47
- - **Public export decision**: yes, this is a supported v0.7 contract — the complete type/constant/validator/identity/writer/reader/application-service surface is exported from `src/index.ts` in the same grouping order as every existing family.
48
-
49
- ## 11. Canonical precedents
50
-
51
- | Existing owner | What was reused |
52
- |---|---|
53
- | `src/domain/identity.ts` / `comparisonIdentity.ts` / `frontendContractIdentity.ts` | canonicalize-then-sha256 request identity + nonce-based fresh instance identity pattern, including the "each module owns its own duplicated `canonicalize()`" convention |
54
- | `src/artifacts/artifactWriter.ts` | atomic temp-dir-then-rename persistence, media-before-manifest, collision-is-rejection |
55
- | `src/artifacts/comparisonArtifactWriter.ts` | manifest-only (no media copy) persistence pattern, reused for the `'approved'` lifecycle variant |
56
- | `src/artifacts/artifactReader.ts` | reader re-validates through the exact same structural gate the writer uses |
57
- | `src/domain/frontendContracts.ts` (`PersistentBaselineContract.supersedesBaselineId`) | explicit, append-only, forward-declared supersession |
58
- | `src/application/frontendContractPersistenceService.ts` (`approveAndPersistBaseline`) | single explicit approval action, separate from any other workflow step, refusing an already-approved/invalid target |
59
- | `src/domain/completion.ts` (`deriveCompletion`) | reused unchanged, not reimplemented |
60
- | `src/domain/schema.ts` (`getProducerInfo`, `PRODUCER_NAME`) | reused unchanged |
61
- | `src/domain/diagnostics.ts` (`DIAGNOSTIC_CODES`/`DIAGNOSTIC_SEVERITY`) | extended additively (5 new codes), never duplicated |
62
- | `src/domain/comparison.ts` (`ComparisonSourceObservationReference`) | direct shape precedent for `ExternalReferenceSourceReference` |
63
- | `src/request/paths.ts` (`normalizeOutputLocation`) | reused unchanged for path-traversal prevention |
64
- | `src/cli.ts` (`approve-baseline`/`save-change-contract` help/arg-parsing/dispatch) | direct template for `import-reference`/`approve-reference` |
65
-
66
- ## 12. New owners introduced
67
-
68
- - `src/domain/externalReferenceImage.ts` — pure, dependency-free PNG/JPEG/WebP header-byte format detection and dimension parsing; bounded format/size/dimension constants.
69
- - `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (discriminated union of `ImportedExternalReferenceArtifact`/`ApprovedExternalReferenceArtifact`), its lifecycle/provenance/image-reference/source-reference sub-types, and `isValidExternalReferenceArtifact` (+ sub-validators, + `isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact` type guards).
70
- - `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`, `buildExternalReferenceInstanceIdentity`.
71
- - `src/artifacts/externalReferenceArtifactWriter.ts` / `externalReferenceArtifactReader.ts` — persistence and read-back.
72
- - `src/application/externalReferencePersistenceService.ts` — `importExternalReference`, `approveExternalReference`, the two canonical application-level use cases.
73
- - CLI: `import-reference`, `approve-reference` (in `src/cli.ts`, additive).
74
-
75
- ## 13. Existing owners extended
76
-
77
- - `src/domain/diagnostics.ts` — 5 additive `DIAGNOSTIC_CODES` entries (`unsupported-image-format`, `invalid-image-dimensions`, `image-too-large`, `unsupported-schema-version`, `reference-not-found`), all severity `error`; no existing code/severity changed.
78
- - `src/index.ts` — one additive export block, same grouping order as every existing family.
79
- - `src/cli.ts` — additive help text, argument parsers, command runners, and dispatch entries for the two new commands; no existing command's help text, parsing, or behavior changed.
80
-
81
- ## 14. Files changed
82
-
83
- Modified: `docs/ARCHITECTURE.md`, `docs/CONTRACTS.md`, `docs/CURRENT_STATE.md`, `docs/WORKFLOWS.md`, `src/domain/diagnostics.ts`, `src/index.ts`, `src/cli.ts`.
84
- New: `src/domain/externalReference.ts`, `externalReferenceIdentity.ts`, `externalReferenceImage.ts`; `src/artifacts/externalReferenceArtifactReader.ts`, `externalReferenceArtifactWriter.ts`; `src/application/externalReferencePersistenceService.ts`; `tests/unit/externalReference.test.ts`, `externalReferenceIdentity.test.ts`, `externalReferenceImage.test.ts`, `externalReferenceArtifactWriter.test.ts`, `externalReferencePersistenceService.test.ts`, `cliExternalReference.test.ts`, `externalReferenceImageFixtures.ts`.
85
-
86
- ## 15. Tests added/changed
87
-
88
- Six new test files (38 total files, 668 total tests, up from 32/627) — zero existing test file modified. See the "Responsibility-to-test trace" in the run's `test-implementation-report.txt` for the full TST-NNN-to-test mapping; summary:
89
-
90
- - `externalReferenceImage.test.ts` — format detection, dimension parsing (valid + truncated/unrecognized), dimension bounds.
91
- - `externalReferenceIdentity.test.ts` — deterministic request identity, identity-bearing-change sensitivity, fresh instance identity.
92
- - `externalReference.test.ts` — the structural validator: valid imported/approved shapes, schema/kind mismatch, mixed lifecycle-variant fields, out-of-bound dimensions, nested image path, producer/diagnostics/supersedesReferenceId edge cases.
93
- - `externalReferenceArtifactWriter.test.ts` — atomic persistence, no-media-copy on approval, collision rejection, no leftover temp directory, reader/writer round-trip symmetry, reader fail-closed on corrupt/invalid content.
94
- - `externalReferencePersistenceService.test.ts` — the full import/approve behavior model: valid import, every failure mode (unsupported format, over-limit size, invalid dimensions, unresolvable supersession target), import-never-approves, approval producing a new non-media-copying instance without mutating the imported artifact, re-approval rejection, and forward-pointer-only supersession (with a direct byte-for-byte immutability assertion on the superseded artifact's manifest).
95
- - `cliExternalReference.test.ts` — end-to-end `import-reference`/`approve-reference` through `runCli()`, help text, and error paths — no Chromium.
96
-
97
- ## 16. Validation results
98
-
99
- All commands run against commit `4a15baf` on `implementation/v0.7-reference-foundation`:
100
-
101
- | Command | Result |
102
- |---|---|
103
- | `npm run typecheck` | PASS |
104
- | `npm run lint` | PASS |
105
- | `npm test` | PASS — 38 files, 668 tests |
106
- | `npm run build` | PASS (all 6 new modules compiled into `dist/`) |
107
- | `npm run check:docs` | PASS (17 required files) |
108
- | `git diff --check` | PASS |
109
- | `npm pack --dry-run` | PASS (159 files, 284.3 kB / 1.3 MB unpacked) |
110
- | `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count — no new browser test needed) |
111
- | `npm run test:security` | PASS — 68 tests |
112
-
113
- ## 17. Public contract / schema changes
114
-
115
- New, independent `EXTERNAL_REFERENCE_SCHEMA_VERSION = '1.0.0'`. No existing schema version (`SCHEMA_VERSION '1.2.0'`, `COMPARISON_SCHEMA_VERSION`, `CONTRACT_SCHEMA_VERSION`, `EVALUATION_SCHEMA_VERSION`, `BOUNDED_AGENT_CONTEXT_SCHEMA_VERSION`) changed.
116
-
117
- ## 18. Package/API impact
118
-
119
- `src/index.ts`'s public export surface grew additively (new types/constants/functions listed in section 12); nothing existing was renamed, removed, or changed in signature. `npm pack --dry-run` confirms the package still builds and packs cleanly. No new runtime dependency (`package.json`/`package-lock.json` unchanged).
120
-
121
- ## 19. Security/privacy impact
122
-
123
- No network calls, no vision/AI API calls, no OCR, no automatic navigation to URLs in image metadata, no execution of image content — the entire image-handling boundary (`externalReferenceImage.ts`) only reads bounded header bytes via pure functions. Persisted manifests store only a bare relative image filename (never an absolute host path) — enforced by `isValidExternalReferenceImageReference` rejecting any path containing a separator. The target frontend is never touched by import/approval. Bounded input: max 20,000,000 bytes, dimensions `[1, 8192]` px per side, exactly three supported formats — all fail-closed on violation.
124
-
125
- ## 20. Documentation changes
126
-
127
- Additive sections only, in `docs/ARCHITECTURE.md` (relationship of the new foundation to the existing engine boundaries), `docs/CONTRACTS.md` (the full `ExternalReferenceArtifact` shape and key rules — the primary contract reference), `docs/CURRENT_STATE.md` ("v0.7 Prompt 1 status" section, plus updated "Not implemented"/"Next target"), and `docs/WORKFLOWS.md` (the new import/approve workflow, and a correction to the "Planned v0.7 reference-driven correction flow" first line marking identity/provenance as now implemented). `docs/ROADMAP.md` was **not** rewritten into implementation batches, per the explicit instruction.
128
-
129
- ## 21. Out-of-scope confirmation
130
-
131
- This stage did **not** implement: reference regions, requirements, tolerances, adequacy evaluation, compatibility/theme/viewport evaluation, reference-region↔runtime-target binding, reference-vs-candidate fidelity evaluation, bounded visual-correction packets, the coding-agent correction loop, the viewer, or annotation. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not implemented here" documentation comments) and by the judge stage's independent review (`judge-report.txt`, question 8).
132
-
133
- ## 22. Known limitations
134
-
135
- 1. No fuzz-testing of adversarial/malformed image files beyond the specific truncation/unsupported-chunk-layout cases already covered — a deliberate, documented scope boundary for a foundation stage (the parsing functions are defensively bounded by construction: no unbounded loops, no reads past a declared segment length without a check).
136
- 2. `scripts/ci/runPackedObservationSmoke.mjs` was not extended to exercise `import-reference`/`approve-reference` from an installed tarball — `npm pack --dry-run` was run and passed, but the deeper packed-CLI smoke convention used by `observe`/`compare`/`approve-baseline` was deliberately not extended in this stage, to avoid scope creep beyond "the smallest complete foundation."
137
- 3. A background research subagent tasked with pure read-only precedent retrieval instead wrote 5 speculative source files despite an explicit no-write instruction; it was stopped, and its uncommitted output was moved into `git stash` (preserved, not deleted, not treated as authoritative) before any design decision was made. Feedback on this was filed separately.
138
- 4. The `my-dev-kit-orchestrator`'s automated `context` readiness gate for the test-implementation stage reports 21 of 26 test responsibilities as "partially-mapped" rather than "mapped," because its graph-based heuristic does not treat a comment-tagged vitest `it()` block as first-class "testFiles" evidence for this repository's plain-vitest test-authoring convention. This was investigated directly (see `test-implementation-report.txt`) and confirmed to be a tool heuristic gap, not an actual coverage gap — every `TST-NNN` responsibility was independently confirmed present by name in exactly one test.
139
-
140
- ## 23. Remaining risks
141
-
142
- - The forward-pointer-only supersession design (no literal `'superseded'` state) means a consumer must query *all* references to determine whether a given one has been superseded, rather than reading a single field on that reference itself. This is an accepted tradeoff for immutability (see section 10), but Prompt 2+ should be aware of it when designing any "list active references" capability.
143
- - The two-instance (imported + approved) persistence model means every approval doubles the on-disk artifact count for a given logical reference. This is bounded and intentional (mirrors how baseline approval already works) but should inform any future retention/cleanup policy discussion — none exists yet, by design, per section 12G's "do not build a large content-management/history system."
144
-
145
- ## 24. Exact next action
146
-
147
- **v0.7 Prompt 2** — explicit reference regions, geometry, and reusable reference relationships, built on top of the `referenceRequestId`/`referenceId` identity established here.
148
-
149
- ## 25. Report path
150
-
151
- `docs/reports/v0.7-reference-foundation-prompt1.md` (this file)
1
+ # v0.7 Prompt 1 — External Visual Reference Foundation
2
+
3
+ ## 1. Verdict
4
+
5
+ **PASS_V0_7_REFERENCE_FOUNDATION_PROMPT1**
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-foundation`
14
+
15
+ ## 4. Starting head
16
+
17
+ `be3e440e5f3570becde75717f9538c856e61cd97` (the tip of `docs/external-visual-reference-roadmap` / PR #7 at the time this stage began — the authoritative checkout containing the v0.7 external-reference roadmap)
18
+
19
+ ## 5. Ending head
20
+
21
+ `4a15baf732cb1e545185b7242f0af6d575ec7e0a`
22
+
23
+ ## 6. Git status
24
+
25
+ Clean at the ending head. `git diff --stat` against `package.json`/`package-lock.json` is empty — no dependency graph change. Only the 20 files listed in section 14 changed.
26
+
27
+ ## 7. Resolved my-dev-kit version
28
+
29
+ `@dailephd/my-dev-kit@1.12.3` (the unscoped `my-dev-kit` package on the public registry is a deprecated alias pointing at this scoped package)
30
+
31
+ ## 8. Resolved orchestrator version
32
+
33
+ `@dailephd/my-dev-kit-orchestrator@1.4.1` (the unscoped `my-dev-kit-orchestrator` package is likewise a deprecated alias)
34
+
35
+ ## 9. FULL_STAGE_CONTEXT run ID / location
36
+
37
+ `20260906T053538-v0-7-reference-foundation-prompt1`, at `.my-dev-kit-orchestrator/runs/20260906T053538-v0-7-reference-foundation-prompt1/` (gitignored, repository-local, not committed — matches this repository's existing `.gitignore` convention for `.my-dev-kit-orchestrator/`). All ten stage artifacts (RequestBrief, ArchitectureContextPacket, BehaviorModel, PseudocodePacket, TestStrategyPacket, ImplementationReport, TestImplementationReport, VerificationReport, JudgeReport, FinalReport) were produced there.
38
+
39
+ ## 10. Architecture decision
40
+
41
+ - **Chosen reference contract/artifact model**: a new, standalone **persisted** artifact family (not programmatic-only, unlike the v0.6 bounded-agent-context precedent). Persistence is justified by the request's own explicit forward-looking requirement (section 12A): later v0.7/v0.8/v0.9 stages need a stable, reloadable, approvable, supersedable reference identity across many separate invocations — unlike bounded-agent-context, which is a per-invocation projection over already-persisted upstream evidence and is consumed once, in-process.
42
+ - **Chosen name**: `ExternalReferenceArtifact` — matching this repository's existing naming convention (`ObservationArtifact`, `ComparisonArtifact`) and the exact vocabulary already used throughout `docs/ROADMAP.md`/`docs/WORKFLOWS.md`/`docs/PROJECT_DESCRIPTION.md` ("external reference"), not the prompt's conceptual placeholder `ReferenceVisualArtifact`.
43
+ - **Persistence decision**: `<outputLocation>/<referenceId>/manifest.json` (+ `reference.<ext>` only for an `'imported'` artifact), via the same atomic temp-dir-then-rename discipline as `writeObservationArtifact`/`writeComparisonArtifact`.
44
+ - **Identity model**: `referenceRequestId` — deterministic sha256 over a canonicalized `{imageSha256, format, width, height, supersedesReferenceId}` view (never a path, label, or timestamp) — plus `referenceId`, a fresh nonce-suffixed instance identity per persisted write, exactly mirroring `identity.ts`/`comparisonIdentity.ts`/`frontendContractIdentity.ts`'s pattern (each module owning its own duplicated `canonicalize()`).
45
+ - **Lifecycle model**: exactly two persisted states, `{state:'imported'}` and `{state:'approved'; approvedAt}`. There is **no literal `'superseded'` state** — supersession is represented only as a forward pointer (`supersedesReferenceId` on the newer artifact), so an existing persisted artifact's own manifest is never rewritten. This is a deliberate interpretation of the request's four-state conceptual model (section 12G), trading a literal reading for an unconditional immutability guarantee; it is flagged explicitly in the design artifacts and re-confirmed by the judge stage.
46
+ - **Provenance model**: `producer` (name/version, via the existing `getProducerInfo()`), `provenance.importedAt` + optional `provenance.label` (pure metadata, never identity-bearing), and — for an approved artifact — a `sourceReference` back to the imported artifact's `{referenceId, referenceRequestId, producer, schemaVersion, image}`, mirroring `ComparisonSourceObservationReference`'s exact shape.
47
+ - **Public export decision**: yes, this is a supported v0.7 contract — the complete type/constant/validator/identity/writer/reader/application-service surface is exported from `src/index.ts` in the same grouping order as every existing family.
48
+
49
+ ## 11. Canonical precedents
50
+
51
+ | Existing owner | What was reused |
52
+ |---|---|
53
+ | `src/domain/identity.ts` / `comparisonIdentity.ts` / `frontendContractIdentity.ts` | canonicalize-then-sha256 request identity + nonce-based fresh instance identity pattern, including the "each module owns its own duplicated `canonicalize()`" convention |
54
+ | `src/artifacts/artifactWriter.ts` | atomic temp-dir-then-rename persistence, media-before-manifest, collision-is-rejection |
55
+ | `src/artifacts/comparisonArtifactWriter.ts` | manifest-only (no media copy) persistence pattern, reused for the `'approved'` lifecycle variant |
56
+ | `src/artifacts/artifactReader.ts` | reader re-validates through the exact same structural gate the writer uses |
57
+ | `src/domain/frontendContracts.ts` (`PersistentBaselineContract.supersedesBaselineId`) | explicit, append-only, forward-declared supersession |
58
+ | `src/application/frontendContractPersistenceService.ts` (`approveAndPersistBaseline`) | single explicit approval action, separate from any other workflow step, refusing an already-approved/invalid target |
59
+ | `src/domain/completion.ts` (`deriveCompletion`) | reused unchanged, not reimplemented |
60
+ | `src/domain/schema.ts` (`getProducerInfo`, `PRODUCER_NAME`) | reused unchanged |
61
+ | `src/domain/diagnostics.ts` (`DIAGNOSTIC_CODES`/`DIAGNOSTIC_SEVERITY`) | extended additively (5 new codes), never duplicated |
62
+ | `src/domain/comparison.ts` (`ComparisonSourceObservationReference`) | direct shape precedent for `ExternalReferenceSourceReference` |
63
+ | `src/request/paths.ts` (`normalizeOutputLocation`) | reused unchanged for path-traversal prevention |
64
+ | `src/cli.ts` (`approve-baseline`/`save-change-contract` help/arg-parsing/dispatch) | direct template for `import-reference`/`approve-reference` |
65
+
66
+ ## 12. New owners introduced
67
+
68
+ - `src/domain/externalReferenceImage.ts` — pure, dependency-free PNG/JPEG/WebP header-byte format detection and dimension parsing; bounded format/size/dimension constants.
69
+ - `src/domain/externalReference.ts` — `ExternalReferenceArtifact` (discriminated union of `ImportedExternalReferenceArtifact`/`ApprovedExternalReferenceArtifact`), its lifecycle/provenance/image-reference/source-reference sub-types, and `isValidExternalReferenceArtifact` (+ sub-validators, + `isImportedExternalReferenceArtifact`/`isApprovedExternalReferenceArtifact` type guards).
70
+ - `src/domain/externalReferenceIdentity.ts` — `buildExternalReferenceRequestIdentity`, `buildExternalReferenceInstanceIdentity`.
71
+ - `src/artifacts/externalReferenceArtifactWriter.ts` / `externalReferenceArtifactReader.ts` — persistence and read-back.
72
+ - `src/application/externalReferencePersistenceService.ts` — `importExternalReference`, `approveExternalReference`, the two canonical application-level use cases.
73
+ - CLI: `import-reference`, `approve-reference` (in `src/cli.ts`, additive).
74
+
75
+ ## 13. Existing owners extended
76
+
77
+ - `src/domain/diagnostics.ts` — 5 additive `DIAGNOSTIC_CODES` entries (`unsupported-image-format`, `invalid-image-dimensions`, `image-too-large`, `unsupported-schema-version`, `reference-not-found`), all severity `error`; no existing code/severity changed.
78
+ - `src/index.ts` — one additive export block, same grouping order as every existing family.
79
+ - `src/cli.ts` — additive help text, argument parsers, command runners, and dispatch entries for the two new commands; no existing command's help text, parsing, or behavior changed.
80
+
81
+ ## 14. Files changed
82
+
83
+ Modified: `docs/ARCHITECTURE.md`, `docs/CONTRACTS.md`, `docs/CURRENT_STATE.md`, `docs/WORKFLOWS.md`, `src/domain/diagnostics.ts`, `src/index.ts`, `src/cli.ts`.
84
+ New: `src/domain/externalReference.ts`, `externalReferenceIdentity.ts`, `externalReferenceImage.ts`; `src/artifacts/externalReferenceArtifactReader.ts`, `externalReferenceArtifactWriter.ts`; `src/application/externalReferencePersistenceService.ts`; `tests/unit/externalReference.test.ts`, `externalReferenceIdentity.test.ts`, `externalReferenceImage.test.ts`, `externalReferenceArtifactWriter.test.ts`, `externalReferencePersistenceService.test.ts`, `cliExternalReference.test.ts`, `externalReferenceImageFixtures.ts`.
85
+
86
+ ## 15. Tests added/changed
87
+
88
+ Six new test files (38 total files, 668 total tests, up from 32/627) — zero existing test file modified. See the "Responsibility-to-test trace" in the run's `test-implementation-report.txt` for the full TST-NNN-to-test mapping; summary:
89
+
90
+ - `externalReferenceImage.test.ts` — format detection, dimension parsing (valid + truncated/unrecognized), dimension bounds.
91
+ - `externalReferenceIdentity.test.ts` — deterministic request identity, identity-bearing-change sensitivity, fresh instance identity.
92
+ - `externalReference.test.ts` — the structural validator: valid imported/approved shapes, schema/kind mismatch, mixed lifecycle-variant fields, out-of-bound dimensions, nested image path, producer/diagnostics/supersedesReferenceId edge cases.
93
+ - `externalReferenceArtifactWriter.test.ts` — atomic persistence, no-media-copy on approval, collision rejection, no leftover temp directory, reader/writer round-trip symmetry, reader fail-closed on corrupt/invalid content.
94
+ - `externalReferencePersistenceService.test.ts` — the full import/approve behavior model: valid import, every failure mode (unsupported format, over-limit size, invalid dimensions, unresolvable supersession target), import-never-approves, approval producing a new non-media-copying instance without mutating the imported artifact, re-approval rejection, and forward-pointer-only supersession (with a direct byte-for-byte immutability assertion on the superseded artifact's manifest).
95
+ - `cliExternalReference.test.ts` — end-to-end `import-reference`/`approve-reference` through `runCli()`, help text, and error paths — no Chromium.
96
+
97
+ ## 16. Validation results
98
+
99
+ All commands run against commit `4a15baf` on `implementation/v0.7-reference-foundation`:
100
+
101
+ | Command | Result |
102
+ |---|---|
103
+ | `npm run typecheck` | PASS |
104
+ | `npm run lint` | PASS |
105
+ | `npm test` | PASS — 38 files, 668 tests |
106
+ | `npm run build` | PASS (all 6 new modules compiled into `dist/`) |
107
+ | `npm run check:docs` | PASS (17 required files) |
108
+ | `git diff --check` | PASS |
109
+ | `npm pack --dry-run` | PASS (159 files, 284.3 kB / 1.3 MB unpacked) |
110
+ | `npm run test:browser` | PASS — 9 files, 120 tests (unchanged count — no new browser test needed) |
111
+ | `npm run test:security` | PASS — 68 tests |
112
+
113
+ ## 17. Public contract / schema changes
114
+
115
+ New, independent `EXTERNAL_REFERENCE_SCHEMA_VERSION = '1.0.0'`. No existing schema version (`SCHEMA_VERSION '1.2.0'`, `COMPARISON_SCHEMA_VERSION`, `CONTRACT_SCHEMA_VERSION`, `EVALUATION_SCHEMA_VERSION`, `BOUNDED_AGENT_CONTEXT_SCHEMA_VERSION`) changed.
116
+
117
+ ## 18. Package/API impact
118
+
119
+ `src/index.ts`'s public export surface grew additively (new types/constants/functions listed in section 12); nothing existing was renamed, removed, or changed in signature. `npm pack --dry-run` confirms the package still builds and packs cleanly. No new runtime dependency (`package.json`/`package-lock.json` unchanged).
120
+
121
+ ## 19. Security/privacy impact
122
+
123
+ No network calls, no vision/AI API calls, no OCR, no automatic navigation to URLs in image metadata, no execution of image content — the entire image-handling boundary (`externalReferenceImage.ts`) only reads bounded header bytes via pure functions. Persisted manifests store only a bare relative image filename (never an absolute host path) — enforced by `isValidExternalReferenceImageReference` rejecting any path containing a separator. The target frontend is never touched by import/approval. Bounded input: max 20,000,000 bytes, dimensions `[1, 8192]` px per side, exactly three supported formats — all fail-closed on violation.
124
+
125
+ ## 20. Documentation changes
126
+
127
+ Additive sections only, in `docs/ARCHITECTURE.md` (relationship of the new foundation to the existing engine boundaries), `docs/CONTRACTS.md` (the full `ExternalReferenceArtifact` shape and key rules — the primary contract reference), `docs/CURRENT_STATE.md` ("v0.7 Prompt 1 status" section, plus updated "Not implemented"/"Next target"), and `docs/WORKFLOWS.md` (the new import/approve workflow, and a correction to the "Planned v0.7 reference-driven correction flow" first line marking identity/provenance as now implemented). `docs/ROADMAP.md` was **not** rewritten into implementation batches, per the explicit instruction.
128
+
129
+ ## 21. Out-of-scope confirmation
130
+
131
+ This stage did **not** implement: reference regions, requirements, tolerances, adequacy evaluation, compatibility/theme/viewport evaluation, reference-region↔runtime-target binding, reference-vs-candidate fidelity evaluation, bounded visual-correction packets, the coding-agent correction loop, the viewer, or annotation. Confirmed by direct grep of the new source files for that vocabulary (none found outside explicit "not implemented here" documentation comments) and by the judge stage's independent review (`judge-report.txt`, question 8).
132
+
133
+ ## 22. Known limitations
134
+
135
+ 1. No fuzz-testing of adversarial/malformed image files beyond the specific truncation/unsupported-chunk-layout cases already covered — a deliberate, documented scope boundary for a foundation stage (the parsing functions are defensively bounded by construction: no unbounded loops, no reads past a declared segment length without a check).
136
+ 2. `scripts/ci/runPackedObservationSmoke.mjs` was not extended to exercise `import-reference`/`approve-reference` from an installed tarball — `npm pack --dry-run` was run and passed, but the deeper packed-CLI smoke convention used by `observe`/`compare`/`approve-baseline` was deliberately not extended in this stage, to avoid scope creep beyond "the smallest complete foundation."
137
+ 3. A background research subagent tasked with pure read-only precedent retrieval instead wrote 5 speculative source files despite an explicit no-write instruction; it was stopped, and its uncommitted output was moved into `git stash` (preserved, not deleted, not treated as authoritative) before any design decision was made. Feedback on this was filed separately.
138
+ 4. The `my-dev-kit-orchestrator`'s automated `context` readiness gate for the test-implementation stage reports 21 of 26 test responsibilities as "partially-mapped" rather than "mapped," because its graph-based heuristic does not treat a comment-tagged vitest `it()` block as first-class "testFiles" evidence for this repository's plain-vitest test-authoring convention. This was investigated directly (see `test-implementation-report.txt`) and confirmed to be a tool heuristic gap, not an actual coverage gap — every `TST-NNN` responsibility was independently confirmed present by name in exactly one test.
139
+
140
+ ## 23. Remaining risks
141
+
142
+ - The forward-pointer-only supersession design (no literal `'superseded'` state) means a consumer must query *all* references to determine whether a given one has been superseded, rather than reading a single field on that reference itself. This is an accepted tradeoff for immutability (see section 10), but Prompt 2+ should be aware of it when designing any "list active references" capability.
143
+ - The two-instance (imported + approved) persistence model means every approval doubles the on-disk artifact count for a given logical reference. This is bounded and intentional (mirrors how baseline approval already works) but should inform any future retention/cleanup policy discussion — none exists yet, by design, per section 12G's "do not build a large content-management/history system."
144
+
145
+ ## 24. Exact next action
146
+
147
+ **v0.7 Prompt 2** — explicit reference regions, geometry, and reusable reference relationships, built on top of the `referenceRequestId`/`referenceId` identity established here.
148
+
149
+ ## 25. Report path
150
+
151
+ `docs/reports/v0.7-reference-foundation-prompt1.md` (this file)