# PRD Review: Lite Entry Point
**Reviewer:** Thing (adversarial QA)
**Revision:** 2/5
**Date:** 2026-03-18
**PRD under review:** `planning/lite-entry-point/prd.md` + `prd.json`
**Spec under review:** `planning/lite-entry-point/spec.md` (Rev 4)
**Previous spec review:** `planning/lite-entry-point/spec-review.md` (Rev 4/5, score 95/100)

---

## 1. Rev 1 Issues — Resolution Status

Rev 1 raised 9 defects. All 9 are addressed in this revision:

| Defect | Rev 1 Description | Rev 2 Status |
|---|---|---|
| 1 (LOW) | Story 1 heading "Files created (5)" — wrong, should be 2 | FIXED — now "Files created (2)" |
| 2 (LOW) | Story 3 heading "Files created (2)" — wrong, should be 3 | FIXED — now "Files created (3)" |
| 3 (HIGH) | ts-jest forward import failure — Stories 1 & 2 marked tests `required: true` while ts-jest would fail | FIXED — Stories 1 & 2 mark build, tests, and browser tests all `required: false` with explicit ts-jest explanation |
| 4 (LOW) | `check-lite-size.js` missing `mkdir` guard for fresh clones | FIXED — Story 5 now specifies `fs.mkdirSync(..., { recursive: true })` before webpack |
| 5 (MEDIUM) | Story 6 missing `package.json` for webpack and rollup examples | FIXED — Story 6 now lists 11 files including `webpack/package.json` and `rollup/package.json` with explicit `devDependencies` note |
| 6 (LOW) | `prepublishOnly` not updated in any story | FIXED — Story 3 `package.json` changes now explicitly include updating `prepublishOnly` to append `&& yarn check:lite-size && yarn verify:lite-sync` |
| 7 (LOW) | Story 6 parallel execution conflict on `package.json` undocumented | FIXED — Explicit "Merge-conflict warning" block added to Story 6 |
| 8 (LOW) | AC 21–23 example build verification absent from Story 7 checklist | FIXED — Story 7 checklist now has items 15, 16, 17 for AC 21–23 |
| 9 (LOW) | `src/lite/` directory creation not mentioned in Story 1 | FIXED — Story 1 now says "Create the `src/lite/` directory first: `mkdir -p src/lite`" |

---

## 2. prd.json Structure Validation

### 2.1 Unique IDs
Story IDs: `story-1`, `story-2`, `story-3`, `story-4`, `story-5`, `story-6`, `story-7`. All seven are unique. **PASS.**

### 2.2 Dependency validity
- story-1: `[]` — valid
- story-2: `["story-1"]` — valid
- story-3: `["story-1", "story-2"]` — valid
- story-4: `["story-3"]` — valid
- story-5: `["story-3"]` — valid
- story-6: `["story-3"]` — valid
- story-7: `["story-1", "story-2", "story-3", "story-4", "story-5", "story-6"]` — valid

All referenced IDs exist. **PASS.**

### 2.3 Cycle detection
Topological order: 1 → 2 → 3 → {4, 5, 6} → 7. No back-edges. **PASS.**

### 2.4 File count consistency between prd.md and prd.json

| Story | prd.md stated create count | prd.json `create` count | prd.md stated modify count | prd.json `modify` count |
|---|---|---|---|---|
| Story 1 | "(2)" | 2 | — | 0 |
| Story 2 | "(3)" | 3 | — | 0 |
| Story 3 | "(3)" | 3 | **(2)** | **1** |
| Story 4 | "(2)" | 2 | — | 0 |
| Story 5 | "(3)" | 3 | — | 0 |
| Story 6 | "(11)" | 11 | `package.json` | 1 |
| Story 7 | none | 0 | 0 expected | 0 |

**NEW DEFECT 1 (LOW) — Story 3 heading "Files modified (2)" is wrong — should be (1).** Only `package.json` is listed in the modify body and in prd.json's `modify` array. The `(2)` count was introduced during the Rev 1 repair of the create-count headers. The prd.json is correct (`modify: ['package.json']`); the prd.md heading is wrong.

### 2.5 qualityChecks structure consistency
All stories have `build`, `tests`, and `browserTests` fields. Story 5 additionally has `additionalChecks` array. Stories 1 and 2 correctly mark all three quality checks as `required: false` with explanatory notes. No story is missing required fields. **PASS.**

### 2.6 maxIterations field
`"maxIterations": 14` is present and acceptable as metadata. **PASS.**

---

## 3. Spec Acceptance Criteria — Coverage Cross-Reference (all 24)

| AC# | Description | Covered By |
|---|---|---|
| 1 | `avo-inspector/lite` resolves via exports map | Story 3 |
| 2 | TypeScript: `publicEncryptionKey` causes compile error | Story 4 (test case 2) |
| 3 | `trackSchemaFromEvent` returns correct schema, no `encryptedPropertyValue` | Story 4 (test case 3) |
| 4 | `trackSchemaFromEvent` is async, returns `Promise<EventProperty[]>` | Story 3 + Story 4 |
| 5 | `trackSchema` completes without error | Story 4 (test case 5) |
| 6 | `extractSchema` returns correct result | Story 4 (test case 6) |
| 7 | `dist/lite/` no `"AvoEncryption"` | Story 7 verification step 3 |
| 8 | `dist/lite/` no `"AvoEventSpecFetcher"` | Story 7 verification step 4 |
| 9 | `dist/lite/` no `"safe-regex2"` | Story 7 verification step 7 |
| 10 | `dist/lite/` no `"@noble/curves"` | Story 7 verification step 6 |
| 11 | `dist/lite/` no `"EventSpecCache"` | Story 7 verification step 5 |
| 12 | Original `dist/index.js` unchanged | Story 7 (full build regression) |
| 13 | `yarn build` produces both entry points | Story 3 + Story 7 |
| 14 | All existing tests pass | Stories 1–7 |
| 15 | New tests for `AvoInspectorLite` and `AvoSchemaParserLite` pass | Story 4 |
| 16 | `npm pack --dry-run` includes lite outputs | Story 7 verification step 10 |
| 17 | Lite bundle under 7 KB gzipped — automated | Story 5 |
| 18 | `tsc --project tsconfig.lite.json --noEmit` passes | Story 3 + Story 7 |
| 19 | `yarn verify:lite-sync` passes | Story 5 |
| 20 | Static isolation test | Story 4 (test case 10) |
| 21 | `examples/lite-size-demos/terser-only/` builds < 7 KB | Story 6 + Story 7 step 15 |
| 22 | `examples/lite-size-demos/webpack/` builds < 7 KB | Story 6 + Story 7 step 16 |
| 23 | `examples/lite-size-demos/rollup/` builds < 7 KB | Story 6 + Story 7 step 17 |
| 24 | Each example has `README.md` | Story 6 |

**All 24 acceptance criteria are covered. PASS.**

---

## 4. Architecture Review

### 4.1 Codebase verification — no regressions from Rev 1
All source file claims from Rev 1 remain accurate. Verified:
- `src/AvoInspector.ts` imports `AvoStreamId` and uses it only to gate the `eventSpec` init block — `streamId` removal in lite version is correct.
- `jest.config.js` uses `preset: "ts-jest"` with `testMatch: ["**/src/__tests__/**/*.ts"]`. ts-jest compiles files lazily on import. No existing test file imports `AvoNetworkCallsHandlerLite.ts` or any other new lite file, so the forward-import issue will NOT cause test failures in Stories 1 and 2 in practice. The PRD's `required: false` annotation is conservatively correct.
- `tsconfig.json` does not set `noUnusedLocals`. The `AvoStreamIdLite as AvoStreamId` import in `AvoInspectorLite.ts` (imported but not used directly in the constructor body, since `this.streamId` is removed) will not cause a TypeScript error. Safe.

### 4.2 Story 3 `Files modified (2)` — see DEFECT 1 above
prd.json is correct (1 item: `package.json`). The heading discrepancy is cosmetic but will cause pre-story count checks to fail.

### 4.3 prepublishOnly update — now correctly specified
Story 3 prd.md line 150 explicitly states: "Update `prepublishOnly` to append `&& yarn check:lite-size && yarn verify:lite-sync`." The prd.json implementationNote says: "update prepublishOnly to append && yarn check:lite-size && yarn verify:lite-sync so the size gate and drift check are publish-blocking." This matches the spec's intent. Confirmed that the current `prepublishOnly` in `package.json` is `"yarn build && yarn test:browser && rm -rf examples/... && cd examples/... && yarn && yarn test --watchAll=false"` — the append is safe.

### 4.4 ts-jest behavior re-confirmed (not a defect)
With `jest.config.js` `testMatch: ["**/src/__tests__/**/*.ts"]`, ts-jest only compiles files transitively required by test files. The new lite source files in `src/lite/` are not test files and are not imported by any existing test. Therefore existing tests will NOT fail in Stories 1 and 2 due to the forward imports. The `required: false` safety label is conservative and appropriate for agent instructions.

### 4.5 `verify-lite-sync.sh` 10-line threshold (carry-over)
The 10-line threshold concern from Rev 1 carries over. `AvoNetworkCallsHandlerLite` changes 4 import lines + LITE COPY header (3 lines) = ~7–9 changed lines; borderline. Any single legitimate future addition to a full source file that needs propagation to its lite copy will trip the threshold. This remains a fragile CI check but is acceptable for the initial implementation; the threshold can be adjusted after observing actual diff sizes.

---

## 5. Issues Summary

### New Issues (not present in Rev 1)

**DEFECT 1 (LOW) — Story 3 heading "Files modified (2)" should be (1).** prd.md line 115 says `**Files modified (2):**` but lists only `package.json`. The prd.json correctly records `modify: ["package.json"]`. Fix: change `(2)` to `(1)` in the prd.md heading.

### Carry-over Low-Severity Issues (from Rev 1, acknowledged, not blocking)

**Carry-over A** — `verify-lite-sync.sh` 10-line threshold is fragile (noted in Rev 1 §6.2). Acceptable for initial implementation; document threshold as adjustable.

**Carry-over B** — Missing test for `trackSchema` deduplication path in lite (noted in Rev 1 §5.1). Not blocking — deduplication is tested via `trackSchemaFromEvent`; `trackSchema` tests completeness is reasonable to omit.

**Carry-over C** — Missing constructor error-path tests for null `apiKey`/`version` (noted in Rev 1 §5.1). Not blocking.

**Carry-over D** — Missing network-call integration test for lite path (noted in Rev 1 §5.3). Not blocking given the architecture verification via `grep` steps in Story 7.

---

## 6. Stage Scores

### Stage 1: Architecture & Approach — 23/25

The architecture is sound and correctly verified against the actual codebase. All critical implementation details are specified (import substitutions, constructor differences, static getter/setter replication, `prepublishOnly` update). The ts-jest concern is resolved with conservative `required: false` labels that match actual ts-jest behavior.

Deductions:
- (-1) Story 3 "Files modified (2)" heading error (DEFECT 1) — minor accuracy issue, newly introduced in Rev 2
- (-1) 10-line drift threshold fragility carry-over — acknowledged risk with no resolution path specified

### Stage 2: Story Quality — 22/25

All stories are implementation-ready with precise instructions. File counts match between prd.md and prd.json (except the one new heading error). Merge-conflict warning and directory creation instructions are properly placed. Example apps now include their own `package.json` files. `prepublishOnly` update is specified.

Deductions:
- (-1) Story 3 "Files modified (2)" — wrong count heading (DEFECT 1)
- (-1) No `terser-only/package.json` listed — the `terser-only` example uses `npx esbuild` and `npx terser` without declaring them anywhere, which will fail if neither is globally installed. The spec's `build.sh` uses `npx`, so this works as long as `npx` resolves the packages. However, `esbuild` is not in the root `devDependencies` either. A `terser-only/package.json` with `esbuild` as a devDependency would make the example fully self-contained. This is minor — `npx` will auto-install if not present, but it is inconsistent with the explicit package.json files for webpack and rollup.
- (-1) `AvoBatcherLite` import-path fix for `AvoNetworkCallsHandlerLite` types is partially under-specified: the prd.md says "change import of `AvoNetworkCallsHandler` types to from `./AvoNetworkCallsHandlerLite`" but does not specify what the full original import line looks like or what the exact replacement line is. This is less precise than other import specifications in the PRD. Unlikely to block an agent, but slightly underspecified.

### Stage 3: Test & Acceptance Criteria — 22/25

All 24 acceptance criteria are covered. Story 7 now includes the three example build verifications (AC 21–23). Test cases are well-specified.

Deductions:
- (-1) Missing constructor error-path tests (null `apiKey`/`version`) — carry-over
- (-1) Missing `trackSchema` deduplication path test — carry-over
- (-1) Missing network-call integration test for lite path — carry-over

### Stage 4: Execution & Performance — 23/25

The size target is feasible. The CI scripts are now complete. `prepublishOnly` is updated. The `mkdir` guard is specified for `check-lite-size.js`. The example apps are self-contained with their own `package.json` files.

Deductions:
- (-1) 10-line drift threshold fragility — carry-over
- (-1) `terser-only` example missing `esbuild` dependency declaration — minor inconsistency

---

## 7. Score Summary

| Stage | Score | Max | Notes |
|---|---|---|---|
| Stage 1: Architecture & Approach | 23 | 25 | One new heading error; drift threshold fragility carry-over |
| Stage 2: Story Quality | 22 | 25 | New heading error; terser-only example missing esbuild dep; AvoBatcherLite import slightly underspecified |
| Stage 3: Test & Acceptance Criteria | 22 | 25 | All 24 AC covered; three minor test coverage gaps carry-over |
| Stage 4: Execution & Performance | 23 | 25 | Scripts complete; prepublishOnly fixed; minor terser-only dep gap |
| **Total** | **90** | **100** | |

---

## 8. Verdict

**SCORE: 90/100 — PASS (threshold: 85)**
**STRUCTURE_VALID: true** (unique IDs, valid deps, no cycles, consistent field structure)

All 9 Rev 1 defects are resolved. The PRD is implementation-ready. The single new defect (Story 3 "Files modified (2)" heading should be (1)) is low severity and will not block an agent — agents read the body and prd.json, not just the heading count. The remaining issues are carry-over low-severity gaps that do not affect the ability of an autonomous agent to implement the feature correctly.

The architecture is verified against the actual codebase, all acceptance criteria are covered, the dependency graph is correct, and the implementation instructions are precise enough for autonomous agent execution.
