theslopmachine 1.0.2 → 1.0.3

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 (39) hide show
  1. package/assets/agents/developer.md +38 -32
  2. package/assets/agents/slopmachine-claude.md +36 -25
  3. package/assets/agents/slopmachine.md +61 -45
  4. package/assets/claude/agents/developer.md +27 -10
  5. package/assets/skills/claude-worker-management/SKILL.md +4 -4
  6. package/assets/skills/developer-session-lifecycle/SKILL.md +13 -3
  7. package/assets/skills/development-guidance/SKILL.md +24 -5
  8. package/assets/skills/evaluation-triage/SKILL.md +4 -4
  9. package/assets/skills/final-evaluation-orchestration/SKILL.md +29 -3
  10. package/assets/skills/integrated-verification/SKILL.md +24 -23
  11. package/assets/skills/p8-readiness-reconciliation/SKILL.md +98 -0
  12. package/assets/skills/planning-gate/SKILL.md +2 -2
  13. package/assets/skills/planning-guidance/SKILL.md +7 -4
  14. package/assets/skills/scaffold-guidance/SKILL.md +2 -0
  15. package/assets/skills/submission-packaging/SKILL.md +30 -3
  16. package/assets/skills/verification-gates/SKILL.md +11 -7
  17. package/assets/slopmachine/clarification-faithfulness-review-prompt.md +69 -45
  18. package/assets/slopmachine/clarifier-agent-prompt.md +46 -40
  19. package/assets/slopmachine/exact-readme-template.md +38 -11
  20. package/assets/slopmachine/owner-verification-checklist.md +2 -2
  21. package/assets/slopmachine/phase-1-design-prompt.md +94 -17
  22. package/assets/slopmachine/phase-1-design-template.md +124 -21
  23. package/assets/slopmachine/phase-2-execution-planning-prompt.md +155 -87
  24. package/assets/slopmachine/phase-2-plan-template.md +169 -81
  25. package/assets/slopmachine/scaffold-playbooks/selection-matrix.md +8 -1
  26. package/assets/slopmachine/scaffold-playbooks/tech-frontend-vue.md +2 -0
  27. package/assets/slopmachine/scaffold-playbooks/type-web-spa.md +1 -0
  28. package/assets/slopmachine/templates/AGENTS.md +18 -17
  29. package/assets/slopmachine/templates/CLAUDE.md +18 -17
  30. package/assets/slopmachine/templates/plan.md +115 -36
  31. package/package.json +9 -2
  32. package/src/constants.js +1 -0
  33. package/src/init.js +8 -0
  34. package/src/install.js +130 -0
  35. package/assets/slopmachine/utils/__pycache__/claude_live_hook.cpython-311.pyc +0 -0
  36. package/assets/slopmachine/utils/__pycache__/cleanup_delivery_artifacts.cpython-311.pyc +0 -0
  37. package/assets/slopmachine/utils/__pycache__/convert_ai_session.cpython-311.pyc +0 -0
  38. package/assets/slopmachine/utils/__pycache__/normalize_claude_session.cpython-311.pyc +0 -0
  39. package/assets/slopmachine/utils/__pycache__/strip_session_parent.cpython-311.pyc +0 -0
@@ -28,7 +28,7 @@ You must:
28
28
  - preserve the real business goal, required user outcomes, operational flows, and meaningful constraints
29
29
  - treat accepted core requirements as binding
30
30
  - treat accepted clarifications as binding
31
- - define stable requirement IDs inside the accepted design contract so later `api-spec.md` and `plan.md` can trace the same requirement surfaces consistently
31
+ - preserve the stable requirement IDs from `../.ai/requirements-breakdown.md` so later `../docs/api-spec.md` and `plan.md` can trace the same requirement surfaces consistently
32
32
  - choose the stricter interpretation when ambiguity could cause under-delivery
33
33
  - keep all required roles, operator/admin flows, enforcement points, validations, and delivery surfaces visible
34
34
  - make assumptions explicit
@@ -45,7 +45,7 @@ You must not:
45
45
 
46
46
  If something truly cannot be locked honestly, isolate it in a very small unresolved-items section with impact and required owner decision.
47
47
 
48
- When a design decision depends on framework, library, API, platform, or tool specifics, verify the decision against authoritative documentation first and targeted current research second. Do not guess about important stack behavior.
48
+ When a design decision depends on framework, library, API, platform, or tool specifics, verify the decision with the Context7 CLI/skill first and targeted current research second. Use `npx ctx7@latest library <name> "<question>"` before `npx ctx7@latest docs <libraryId> "<question>"` unless a valid Context7 library id is already known. Do not guess about important stack behavior.
49
49
 
50
50
  ---
51
51
 
@@ -75,11 +75,11 @@ The accepted design document must be strong enough that:
75
75
  - Phase 2 can convert it into `plan.md` without reinterpreting the product
76
76
  - the original prompt and `../.ai/requirements-breakdown.md` have been decomposed into traceable requirement surfaces rather than summarized into broad feature labels
77
77
  - when backend/fullstack APIs exist, Phase 2 can convert `../docs/api-spec.md` directly into complete API-test planning
78
- - requirement IDs defined in the accepted design can still be traced through the API contract, planning, and coverage artifacts
78
+ - requirement IDs from `../.ai/requirements-breakdown.md` can still be traced through the accepted design, API contract, planning, and coverage artifacts
79
79
  - starter/bootstrap/baseline decisions are already locked
80
80
  - security expectations and test strategy are already locked
81
81
  - runtime/bootstrap/README execution contracts are left for Phase 2 instead of being expanded inside `../docs/design.md`
82
- - required roles, pages, APIs, jobs, workflows, validations, permissions, and state transitions are already locked
82
+ - required roles, pages, APIs, jobs, lifecycle flows, validations, permissions, and state transitions are already locked
83
83
  - prompt-relevant modules are identified before planning, with each module's frontend surfaces, backend/API/job/data surfaces, verification expectations, and FE↔BE wiring expectations visible
84
84
  - the owner can reject design drift early, before execution planning begins
85
85
 
@@ -87,8 +87,8 @@ The accepted design document must be strong enough that:
87
87
 
88
88
  ## Non-Negotiable Rules
89
89
 
90
- ### 0. Design must target the final evaluator prompts directly
91
- The design must explicitly lock only the delivery obligations that the final static evaluation and test-coverage prompts will judge. Do not add broad process bloat; do add concrete design requirements for every applicable evaluator expectation below so Phase 2 can turn them into implementation and proof:
90
+ ### 0. Design must target the strict delivery contract directly
91
+ The design must explicitly lock only the delivery obligations needed for a complete, reviewable product. Do not add broad process bloat; do add concrete design requirements for every applicable expectation below so Phase 2 can turn them into implementation and proof:
92
92
  - prompt alignment: business goal, required pages/screens, main user/operator flows, constraints, and task closure must remain visible and traceable
93
93
  - static delivery credibility: repo entry points, route/app wiring, configuration shape, project structure, and primary documentation must be statically consistent
94
94
  - README hard gates: repo-root `README.md`, project type near the top using one of `backend`, `fullstack`, `web`, `android`, `ios`, or `desktop`, `docker compose up --build`, legacy compatibility string `docker-compose up`, access method, verification method, no manual install/setup dependency, and auth demo credentials for every role or explicit `No authentication required`
@@ -98,9 +98,11 @@ The design must explicitly lock only the delivery obligations that the final sta
98
98
  - fullstack proof: major user flows must have planned FE↔BE proof, not only separate backend and frontend tests
99
99
  - security and governance: auth entry points, route authorization, object-level authorization, function-level authorization, tenant/user isolation, admin/internal/debug protection, sensitive-data handling, and log/response redaction must be designed where applicable
100
100
  - mock/demo/debug honesty: mock/local/fake/demo/debug behavior must be scoped and disclosed, and fake-success paths must not hide missing real behavior
101
- - engineering quality: module boundaries, maintainability, validation, error handling, logging categories, and avoidance of redundant/unrelated files must be planned only where they affect evaluator-visible delivery credibility
101
+ - engineering quality: module boundaries, maintainability, validation, error handling, logging categories, and avoidance of redundant/unrelated files must be planned only where they affect delivery credibility
102
+ - static architecture quality: avoid excessive single-file implementations, chaotic coupling, redundant/unnecessary files, disconnected pages/routes, disconnected state/data flow, and unclear service/adaptor/mock/storage boundaries where those would undermine static delivery credibility
103
+ - pure frontend boundary: if the project is `web` with no backend service, mock/local JSON/localStorage/sessionStorage/IndexedDB data is allowed when honest and disclosed; the design must not imply real backend integration, fake-success behavior, backend idempotency, database consistency, or backend security guarantees that a pure frontend cannot own
102
104
 
103
- If an evaluator expectation is not applicable, the design must say why in one compact row or sentence. Do not create separate large matrices when an existing ledger/table can carry the same exact obligation.
105
+ If a delivery expectation is not applicable, the design must say why in one compact row or sentence. Do not create separate large matrices when an existing ledger/table can carry the same exact obligation.
104
106
 
105
107
  ### 1. Coverage is a design obligation, not a cleanup task
106
108
  Every meaningful planned surface must have planned verification.
@@ -113,7 +115,7 @@ The design must lock the expected test layers for all meaningful behavior, inclu
113
115
 
114
116
  For all `web` projects, browser E2E is mandatory in planning scope: require Playwright or an equivalent real in-browser E2E approach in the accepted design so Phase 2 cannot leave browser E2E optional.
115
117
 
116
- The design target is evaluator-relevant coverage:
118
+ The design target is delivery-relevant coverage:
117
119
  - meaningful planned tests for every accepted endpoint, core flow, security boundary, and major failure path
118
120
 
119
121
  The design must state:
@@ -131,7 +133,71 @@ For fullstack or backend-backed frontend projects, every module that has UI beha
131
133
 
132
134
  Internal/API-only reasons must be specific and prompt-faithful. Reject generic rationales such as `not needed in UI`, `admin only`, `backend only`, or `future work` unless the design names the actor, consumer, access path, security boundary, and why omitting frontend exposure does not weaken the prompt.
133
135
 
134
- If backend/fullstack APIs exist, this phase must also produce `../docs/api-spec.md` as an exact API contract by `METHOD + PATH` so Phase 2 can plan `100%` API test coverage from the accepted spec instead of rediscovering routes later.
136
+ If backend/fullstack APIs exist, this phase must also produce `../docs/api-spec.md` as an exact API contract by `METHOD + fully resolved PATH` so Phase 2 can plan API proof from the accepted spec without losing route intent. The implemented routes and tests in the repo are the delivery truth, not this file alone; Phase 2 and implementation must keep repo route registration, tests, README, and this API spec consistent.
137
+
138
+ For every form-backed endpoint (POST, PUT, PATCH), the API spec must also document:
139
+ - the exact frontend form field names that will be rendered in templates
140
+ - the exact backend handler field names that will read the request
141
+ - a verification note that these names match, or a shared constant/typed request struct plan to prevent field-name drift
142
+ - for browser-rendered forms: the CSRF token field name and how it is delivered
143
+
144
+ For every security-critical feature, the design must specify the exact enforcement layer:
145
+ - service-layer enforcement (business logic checks)
146
+ - middleware-layer enforcement (route guards, rate limiting)
147
+ - database-layer enforcement (triggers, RLS, constraints)
148
+ - template-layer enforcement (CSRF tokens, hidden fields)
149
+ - runtime-layer enforcement (background jobs, startup wiring)
150
+ A security feature is incomplete if it exists only in the happy-path service code and not at the layer where bypass or mutation would occur.
151
+
152
+ For every background job, scheduled task, or runtime lifecycle function, the design must state:
153
+ - the exact entrypoint where it is started/stopped (e.g., `main.go`, startup hook, scheduler init)
154
+ - the exact durable storage or configured path it uses (not temp directories)
155
+ - the verification path that proves it is reachable from application startup
156
+
157
+ For every data lifecycle feature (export, deletion, retention, retry, edit), the design must state:
158
+ - whether exported values are decrypted, masked, redacted, or omitted
159
+ - retry/edit/delete semantics and deduplication rules
160
+ - whether display values and stored values are the same or separate
161
+ - any masking rules that must not corrupt source-of-truth data on edit
162
+
163
+ Write `../docs/api-spec.md` in this exact simple Markdown structure:
164
+
165
+ ```md
166
+ # API Specification
167
+
168
+ ## API Scope
169
+ - Project type:
170
+ - API base prefix:
171
+ - Versioning model:
172
+ - Auth/session model:
173
+ - Global error response shape:
174
+ - Source requirement IDs:
175
+
176
+ ## Endpoint Inventory
177
+
178
+ | Requirement ID | METHOD | Fully resolved PATH | Purpose | Actor / role | Auth required | Request params/body/query | Response shape | Side effect / persisted state | Validation / error codes | Planned test proof |
179
+ |---|---|---|---|---|---|---|---|---|---|---|
180
+
181
+ ## Endpoint Details
182
+
183
+ ### `METHOD /fully/resolved/path`
184
+ - Requirement IDs:
185
+ - Purpose:
186
+ - Actor / role:
187
+ - Auth required:
188
+ - Object ownership / tenant isolation:
189
+ - Request:
190
+ - Response:
191
+ - Side effects:
192
+ - Validation rules:
193
+ - Error cases:
194
+ - Idempotency / pagination / filtering / concurrency notes:
195
+ - Planned API proof:
196
+ - true no-mock HTTP / HTTP with mocking / unit-only exception
197
+ - planned test file:
198
+ - key request input:
199
+ - key response or side-effect assertion:
200
+ ```
135
201
 
136
202
  ### 2. Design document boundary
137
203
  `../docs/design.md` is the system/repo design document only.
@@ -201,7 +267,9 @@ If the prompt and current repo do not already dictate the stack:
201
267
  - choose the starter/bootstrap path deliberately
202
268
  - choose the runtime/test baseline deliberately
203
269
  - prefer official or well-supported starters when they reduce setup waste and improve delivery credibility
204
- - if web frontend styling/component defaults are open, choose a mainstream documented path deliberately rather than improvising the UI system later
270
+ - if a web/frontend prompt does not specify a frontend JavaScript framework, default to Vue 3 with Vite and TypeScript
271
+ - if a web/frontend prompt does not specify a styling library, default to Tailwind CSS
272
+ - if a frontend prompt does not specify a UI component library, prefer shadcn/ui where it is compatible with the selected framework and delivery constraints; if shadcn is not compatible or would add unnecessary complexity, record the reason and choose the smallest framework-compatible component approach
205
273
  - if mobile defaults are open, choose a modern mainstream stack deliberately rather than leaving it unresolved
206
274
  - if desktop defaults are open, choose a Linux-testable mainstream stack deliberately rather than leaving it unresolved
207
275
  - do not leave those decisions for scaffold-step improvisation during development
@@ -216,9 +284,9 @@ This phase must lock the contract that Phase 2 will operationalize.
216
284
  ### 9. Run an explicit design gap sweep before finalizing
217
285
  Before finalizing the design, explicitly check for and resolve or narrow-assume the important gaps that coding LLMs commonly miss:
218
286
  - business-rule gaps such as thresholds, limits, defaults, uniqueness, deadlines, idempotency, retry behavior, ownership, and override rules
219
- - workflow gaps such as start conditions, completion conditions, exception paths, approval paths, cancellation or rollback behavior, and actor handoffs
220
- - data-model gaps such as missing entities, missing relationships, missing history or audit records, and records that should be immutable
221
- - security or compliance gaps such as auth scope, permission boundaries, audit trails, retention, masking, lockout, and recovery policy
287
+ - lifecycle gaps such as start conditions, completion conditions, exception paths, approval paths, cancellation or rollback behavior, and actor handoffs
288
+ - data-model gaps such as missing entities, missing relationships, missing history or accountability records, and records that should be immutable
289
+ - security or compliance gaps such as auth scope, permission boundaries, accountability trails, retention, masking, lockout, and recovery policy
222
290
  - offline, async, or reliability gaps where applicable, such as queueing, retries, resumability, conflict resolution, and observability
223
291
  - reporting or analytics gaps where applicable, such as KPI definitions, formulas, date grain, source of truth, and export semantics
224
292
  - config/runtime drift gaps where admin or user settings are stored but might not actually drive runtime behavior
@@ -269,10 +337,11 @@ Create a direct ledger of:
269
337
  Also include a no-orphan trace table with columns: `Requirement ID`, `Requirement summary`, `Design surface(s)`, `Owning module`, `API/data surface if applicable`, `UX/actor path if applicable`, `Security/failure case`, `Planned proof layer`, and `Status`. No row may remain `unmapped` when the design is accepted.
270
338
 
271
339
  ### B.1 Final Evaluation Target Contract
272
- Include a compact contract that maps the final evaluator prompts into design obligations. Required rows, with `Not Applicable` allowed only with a reason:
340
+ Include a compact contract that maps strict delivery review concerns into design obligations. Required rows, with `Not Applicable` allowed only with a reason:
273
341
  - prompt-fit and core requirement coverage
274
342
  - end-to-end delivery/project shape
275
343
  - static startup/build/config/entrypoint traceability
344
+ - static consistency across README/docs/scripts/routes/config/examples/manifests/env examples without relying on runtime execution
276
345
  - README hard gates and demo credentials/no-auth disclosure
277
346
  - API endpoint inventory and real HTTP test strategy where applicable
278
347
  - API coverage summary computability where applicable: total endpoints, endpoints with HTTP tests, endpoints with true no-mock HTTP tests, and mocked/indirect exceptions must be derivable from the accepted API/test plan
@@ -282,6 +351,7 @@ Include a compact contract that maps the final evaluator prompts into design obl
282
351
  - security/auth/authorization/isolation/admin-debug protection
283
352
  - validation, error handling, logging, and sensitive-data leakage controls
284
353
  - mock/local/demo/debug disclosure and fake-success prevention
354
+ - pure-frontend mock/local-data disclosure and boundary honesty where applicable
285
355
  - unit/API/integration/E2E or platform-equivalent test expectations
286
356
 
287
357
  ### C. Actors, Roles, and Paths to Success
@@ -354,6 +424,7 @@ For each module define:
354
424
  - failure behavior
355
425
  - security considerations
356
426
  - planned verification layers
427
+ - static architecture risks to avoid, including disconnected pages/routes/data flow, excessive single-file concentration, redundant/unnecessary files, and unclear adaptor/mock/storage boundaries
357
428
 
358
429
  Each module must also name `requirements explicitly not owned by this module but adjacent to it` so Phase 2 can catch cross-module gaps rather than assuming the neighbor owns them.
359
430
 
@@ -414,14 +485,14 @@ Define the required test layers and the major coverage expectations for:
414
485
  - logging redaction / sensitive-data exposure
415
486
  - pagination / sorting / filtering where relevant
416
487
  - frontend state and route coverage where applicable
417
- - frontend unit-test audit readability for `web` / `fullstack` so later review can state `Frontend unit tests: PRESENT` or `Frontend unit tests: MISSING` from file-level evidence
488
+ - frontend unit-test readability for `web` / `fullstack` so later review can state `Frontend unit tests: PRESENT` or `Frontend unit tests: MISSING` from file-level evidence
418
489
  - E2E/platform proof where applicable, including Playwright for web/fullstack major flows when applicable, Playwright Electron/Xvfb or equivalent for Linux-targetable desktop flows, no-emulator-default broad verification for Android, and honest Linux proof boundaries for iOS
419
490
  - API test observability where applicable, including request input visibility and simple useful response evidence such as status-code and response-summary assertions
420
491
  - visibility of important untested module families where applicable, especially controllers, services, repositories, auth, guards, and middleware
421
492
  - `../docs/test-coverage.md` structure when applicable: requirement/risk point, mapped test files, key assertions/fixtures, current status, remaining gap, and minimum test addition
422
493
 
423
494
  This phase must define the test strategy strongly enough that Phase 2 can map every surface to owned tests.
424
- Requirement IDs defined in this design must be reusable by `../docs/api-spec.md` and `plan.md` rather than being renamed later.
495
+ Requirement IDs from `../.ai/requirements-breakdown.md` must be reused by `../docs/api-spec.md` and `plan.md` rather than being renamed later.
425
496
 
426
497
  ### N. Definition of Done for Design
427
498
  State what must already be locked before the design can be accepted and handed into Phase 2.
@@ -456,6 +527,12 @@ Produce the design document in this order:
456
527
 
457
528
  ---
458
529
 
530
+ ## Section-by-Section Delivery Rule
531
+
532
+ Write `../docs/design.md` one template section at a time, appending each completed section to the file on disk. Do not paste full section text in chat and do not dump the accumulated document text in the final response. When backend/fullstack APIs exist, write `../docs/api-spec.md` endpoint family by endpoint family using the same rule.
533
+
534
+ ---
535
+
459
536
  ## Design Quality Bar
460
537
 
461
538
  The design is acceptable only if:
@@ -3,6 +3,8 @@
3
3
  Use this template to produce the accepted design document.
4
4
  The output should normally be written to `../docs/design.md`.
5
5
 
6
+ > Write this template section by section, appending each completed section to `../docs/design.md`. Do not paste full section text in chat or dump the accumulated document at the end.
7
+
6
8
  ---
7
9
 
8
10
  ## 1. Project Type and Delivery Shape
@@ -55,7 +57,7 @@ The output should normally be written to `../docs/design.md`.
55
57
  -
56
58
 
57
59
  ### 2.6 Final Evaluation Target Contract
58
- Map only the final static evaluator and test-coverage/README expectations that apply. Use `Not Applicable` with a short reason when an item does not apply.
60
+ Map only the strict delivery, test-coverage, and README expectations that apply. Use `Not Applicable` with a short reason when an item does not apply.
59
61
 
60
62
  | Evaluator expectation | Design obligation | Owning section/module | Planned proof layer | Status |
61
63
  |---|---|---|---|---|
@@ -73,6 +75,20 @@ Map only the final static evaluator and test-coverage/README expectations that a
73
75
  | mock/local/demo/debug disclosure and fake-success prevention | | | | planned |
74
76
  | unit/API/integration/E2E or platform-equivalent test expectations | | | | planned |
75
77
 
78
+ ### 2.7 No-Orphan Requirement Trace Table
79
+
80
+ Every requirement ID from `../.ai/requirements-breakdown.md`, every accepted clarification that affects delivery, and every locked safe default must appear here.
81
+
82
+ No row may remain `unmapped` when the design is accepted.
83
+
84
+ Allowed statuses: `mapped`, `not applicable with accepted reason`, `blocked pending owner decision`.
85
+
86
+ Disallowed statuses: `covered generally`, `later`, `TBD`, `unmapped`.
87
+
88
+ | Requirement ID | Requirement summary | Design surface(s) | Owning module | API/data surface if applicable | UX/actor path if applicable | Security/failure case | Planned proof layer | Status |
89
+ |---|---|---|---|---|---|---|---|---|
90
+ | REQ-001 | | | | | | | | mapped |
91
+
76
92
  ---
77
93
 
78
94
  ## 3. Accepted Clarification Ledger
@@ -163,7 +179,7 @@ List only items that do not shrink the prompt.
163
179
  | | | | | |
164
180
 
165
181
  ### 8.2.1 Role Surface Matrix
166
- Use this matrix for every role-sensitive project. If the project has no role, auth, ownership, public/private route, admin, audit, or read-only distinction, state `Not Applicable` and explain why.
182
+ Use this matrix for every role-sensitive project. If the project has no role, auth, ownership, public/private route, admin, accountability logging, or read-only distinction, state `Not Applicable` and explain why.
167
183
 
168
184
  | Route / page / API / action / data object / notification / export / admin function | Roles allowed | Read/write scope | Object ownership rule | Admin override rule | Viewer/read-only rule | Audit/logging requirement | Frontend route/nav expectation | Test evidence required later |
169
185
  |---|---|---|---|---|---|---|---|---|
@@ -223,6 +239,31 @@ Design must identify modules before Phase 2 plans execution order or file/locati
223
239
  |---|---|---|---|---|
224
240
  | | | | | |
225
241
 
242
+ ### 10.5 Design-Level FE↔BE Integration Map
243
+
244
+ Required for every fullstack or backend-backed frontend project. If not applicable, state `Not Applicable` and why.
245
+
246
+ | Frontend page/component/action | Requirement ID | Backend endpoint/service/job | Payload/state input | Expected response/side effect | Required frontend states | Required proof layer |
247
+ |---|---|---|---|---|---|---|
248
+ | | | | | | loading / empty / submitting / disabled / success / error / duplicate-action | |
249
+
250
+ For every form-backed frontend action in this map, also document:
251
+ - Exact rendered form field names (as they will appear in HTML templates)
252
+ - Exact backend handler field names (as they will be read from request)
253
+ - CSRF token field name and delivery mechanism
254
+ - Form submission success response (redirect, JSON, or rendered page)
255
+ - Form submission failure response (validation errors, re-render, or JSON)
256
+
257
+ A form is incomplete until the rendered fields match the handler's expected fields and a valid submit reaches the intended side effect.
258
+
259
+ ### 10.6 Backend-to-Frontend Exposure Check
260
+
261
+ Every prompt-relevant backend capability must either be exposed through the required frontend/operator surface or explicitly accepted as internal/API-only.
262
+
263
+ | Backend capability / endpoint / job / data feature | User-facing/frontend exposure | If internal/API-only, accepted reason | Actor/consumer | Invocation path | Authorization boundary | Proof required |
264
+ |---|---|---|---|---|---|---|
265
+ | | | | | | | |
266
+
226
267
  Rules:
227
268
  - every prompt-relevant module must have real behavior, not a shell
228
269
  - every module must name its surfaces and verification expectations
@@ -270,8 +311,8 @@ Extract exact prompt-critical rules here so implementation cannot lose them late
270
311
 
271
312
  ## 11. State and Lifecycle Models
272
313
 
273
- ### 11.1 Core entities/workflows with state
274
- | Entity / workflow | States | Valid transitions | Invalid transitions | Notes |
314
+ ### 11.1 Core entities/lifecycles with state
315
+ | Entity / lifecycle | States | Valid transitions | Invalid transitions | Notes |
275
316
  |---|---|---|---|---|
276
317
  | | | | | |
277
318
 
@@ -300,6 +341,18 @@ Extract exact prompt-critical rules here so implementation cannot lose them late
300
341
  ### 12.5 Function-level / admin / internal / debug protection
301
342
  -
302
343
 
344
+ ### 12.5.1 Security Enforcement Layer Map
345
+ For each security-critical feature, document the exact layer that enforces it:
346
+
347
+ | Security feature | Service layer | Middleware layer | Database layer | Template layer | Runtime layer | Notes |
348
+ |---|---|---|---|---|---|---|
349
+ | | | | | | | |
350
+
351
+ Rules:
352
+ - a security feature is incomplete if it exists only in happy-path service code
353
+ - every security feature must have enforcement at the layer where bypass or mutation would occur
354
+ - do not rely on route-level middleware alone for defense-in-depth; handler-level checks are required for privileged operations
355
+
303
356
  ### 12.6 Tenant/user isolation model if applicable
304
357
  -
305
358
 
@@ -378,6 +431,18 @@ If not applicable, state `Not Applicable`.
378
431
  |---|---|---|---|---|
379
432
  | | | | | |
380
433
 
434
+ ### 16.2.1 Runtime Entrypoint Wiring
435
+ For every background job or scheduled task, document:
436
+
437
+ | Job / worker | Entrypoint startup location | Entrypoint stop location | Durable storage/config path | Verification path |
438
+ |---|---|---|---|---|
439
+ | | | | | |
440
+
441
+ Rules:
442
+ - every runtime job must be reachable from application startup
443
+ - storage paths must be durable or explicitly configured, not temp defaults
444
+ - a runtime job is incomplete until it is wired from the entrypoint
445
+
381
446
  ### 16.3 API design-level contracts
382
447
  - Resource families:
383
448
  - Request/response shape principles:
@@ -385,21 +450,46 @@ If not applicable, state `Not Applicable`.
385
450
  - Error-shape principles:
386
451
 
387
452
  ### 16.4 Companion `../docs/api-spec.md` requirement
388
- If backend/fullstack APIs exist, create `../docs/api-spec.md` as the accepted API contract with an exact `METHOD + PATH` inventory and enough detail that Phase 2 can plan `100%` API test coverage directly from it.
389
-
390
- Required `api-spec.md` fields:
391
- - Source requirement ID(s)
392
- - METHOD
393
- - PATH
394
- - Purpose
395
- - Auth / actor / role scope
396
- - Role surface matrix row reference when applicable
397
- - Object ownership, admin override, viewer/read-only, public/private, audit/logging, and signed-link/token rules when applicable
398
- - Request shape
399
- - Response shape
400
- - Validation and error codes
401
- - Important failure paths
402
- - Notes on idempotency / pagination / filtering / concurrency when relevant
453
+ When backend/fullstack APIs exist, write `../docs/api-spec.md` in this exact simple Markdown structure.
454
+
455
+ The implemented routes and tests in the repo are the delivery truth, not this file alone; Phase 2 and implementation must keep repo route registration, tests, README, and this API spec consistent.
456
+
457
+ ```md
458
+ # API Specification
459
+
460
+ ## API Scope
461
+ - Project type:
462
+ - API base prefix:
463
+ - Versioning model:
464
+ - Auth/session model:
465
+ - Global error response shape:
466
+ - Source requirement IDs:
467
+
468
+ ## Endpoint Inventory
469
+
470
+ | Requirement ID | METHOD | Fully resolved PATH | Purpose | Actor / role | Auth required | Request params/body/query | Response shape | Side effect / persisted state | Validation / error codes | Planned test proof |
471
+ |---|---|---|---|---|---|---|---|---|---|---|
472
+
473
+ ## Endpoint Details
474
+
475
+ ### `METHOD /fully/resolved/path`
476
+ - Requirement IDs:
477
+ - Purpose:
478
+ - Actor / role:
479
+ - Auth required:
480
+ - Object ownership / tenant isolation:
481
+ - Request:
482
+ - Response:
483
+ - Side effects:
484
+ - Validation rules:
485
+ - Error cases:
486
+ - Idempotency / pagination / filtering / concurrency notes:
487
+ - Planned API proof:
488
+ - true no-mock HTTP / HTTP with mocking / unit-only exception
489
+ - planned test file:
490
+ - key request input:
491
+ - key response or side-effect assertion:
492
+ ```
403
493
 
404
494
  ---
405
495
 
@@ -421,6 +511,19 @@ If not applicable, state `Not Applicable`.
421
511
  ### 17.4 Indexing/partitioning/retention/performance rules if prompt-critical
422
512
  -
423
513
 
514
+ ### 17.5 Data Lifecycle Semantics
515
+ For every data feature involving export, deletion, retention, retry, or edit:
516
+
517
+ | Data feature | Export format | Masking rule | Retry/edit semantics | Dedup rule | Source-of-truth vs display |
518
+ |---|---|---|---|---|---|
519
+ | | decrypted / masked / redacted / omitted | | | | same / separate |
520
+
521
+ Rules:
522
+ - display values and stored values must not be interchangeable
523
+ - masked display fields must not be submitted back as source-of-truth values
524
+ - retry flows must be explicitly designed, not just first-create flows
525
+ - data export must specify whether values are decrypted, masked, or redacted
526
+
424
527
  ---
425
528
 
426
529
  ## 18. Documentation Artifact Expectations
@@ -472,7 +575,7 @@ If not applicable, state `Not Applicable`.
472
575
  ### 19.4 Frontend test requirement
473
576
  If project type is `web` or `fullstack`, frontend unit/component/state tests must be present and visible by file-level evidence.
474
577
 
475
- Required audit-readable fields:
578
+ Required review-readable fields:
476
579
  - Frontend unit tests verdict: [PRESENT | MISSING]
477
580
  - Frameworks/tools detected or planned:
478
581
  - Frontend test files / locations:
@@ -481,7 +584,7 @@ Required audit-readable fields:
481
584
  ### 19.5 API test requirement
482
585
  If backend/fullstack APIs exist, all shipped/documented `METHOD + PATH` surfaces must be planned for true no-mock HTTP coverage unless a narrow explicit exception is accepted.
483
586
 
484
- Required audit-readable fields:
587
+ Required review-readable fields:
485
588
  - Request/response observability expectations:
486
589
  - Useful response evidence expectations (status codes / response summaries):
487
590
  - Important backend module families that must not remain invisible if untested: