@pukujan/create-modular-monolith 2.0.0 → 2.2.0

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 (97) hide show
  1. package/README.md +94 -23
  2. package/index.js +47 -0
  3. package/package.json +16 -19
  4. package/template/.cursor/commands/planning-study-log.md +25 -0
  5. package/template/.cursor/commands/pre-push-dev-log.md +52 -0
  6. package/template/.cursor/rules/api-documentation.mdc +21 -0
  7. package/template/.cursor/rules/file-exchange-inbox.mdc +29 -0
  8. package/template/.github/workflows/ci.yml +44 -0
  9. package/template/AGENTS.md +41 -0
  10. package/template/README.md +25 -55
  11. package/template/backend/.env.example +38 -0
  12. package/template/backend/package-lock.json +1118 -24
  13. package/template/backend/package.json +14 -4
  14. package/template/backend/scripts/check-module-boundaries.mjs +3 -0
  15. package/template/backend/src/modules/model-condenser/README.md +7 -0
  16. package/template/backend/src/modules/model-condenser/config/index.js +20 -0
  17. package/template/backend/src/modules/model-condenser/events/index.js +1 -0
  18. package/template/backend/src/modules/model-condenser/index.js +12 -0
  19. package/template/backend/src/modules/model-condenser/routes/health.routes.js +10 -0
  20. package/template/backend/src/modules/model-condenser/routes/index.js +10 -0
  21. package/template/backend/src/modules/model-condenser/routes/modelCondenser.routes.js +44 -0
  22. package/template/backend/src/modules/model-condenser/services/health.service.js +8 -0
  23. package/template/backend/src/modules/model-condenser/services/modelCondenser.facade.js +58 -0
  24. package/template/backend/src/modules/model-condenser/services/modelCondenser.service.js +513 -0
  25. package/template/backend/src/modules/model-condenser/tests/integration/modelCondenser.routes.test.js +40 -0
  26. package/template/backend/src/modules/model-condenser/tests/unit/modelCondenser.service.test.js +31 -0
  27. package/template/backend/src/modules/model-condenser/utils/index.js +1 -0
  28. package/template/backend/src/shared/contracts/consolidatedExports.contract.js +19 -0
  29. package/template/backend/src/shared/contracts/prePushDevLog.contract.js +28 -0
  30. package/template/backend/src/shared/domain/case-filing/core-models.js +117 -0
  31. package/template/backend/src/shared/http/errors.js +8 -0
  32. package/template/backend/src/shared/utils/consolidatedExport.js +30 -0
  33. package/template/backend/src/shared/utils/formatExchangeTimestamp.js +47 -0
  34. package/template/backend/src/shared/utils/formatExchangeTimestamp.test.js +30 -0
  35. package/template/backend/src/shared/utils/traceId.js +19 -0
  36. package/template/docs/API.md +42 -0
  37. package/template/docs/PUBLISHING.md +13 -1
  38. package/template/docs/README.md +7 -1
  39. package/template/docs/STARTER_PACK.md +4 -0
  40. package/template/docs/architecture/API_DOCUMENTATION_CONTRACT.md +112 -0
  41. package/template/docs/architecture/CONTRACTS_OVERVIEW.md +180 -0
  42. package/template/docs/architecture/EVAL_AND_CI.md +79 -0
  43. package/template/docs/architecture/MODULE_INTERNAL_CONTRACT.md +2 -0
  44. package/template/docs/architecture/PLATFORM_ARCHITECTURE.md +221 -0
  45. package/template/docs/architecture/REPO_ARTIFACT_LAYOUT.md +33 -0
  46. package/template/docs/architecture/contracts/apiDocumentationRegistry.contract.md +40 -0
  47. package/template/docs/architecture/contracts/changelog.jsonl +12 -0
  48. package/template/docs/architecture/contracts/consolidatedExports.contract.md +58 -0
  49. package/template/docs/architecture/contracts/fileExchange.contract.md +47 -0
  50. package/template/docs/architecture/contracts/manifest.json +39 -0
  51. package/template/docs/architecture/contracts/prePushDevLog.contract.md +69 -0
  52. package/template/docs/model-condenser/API.md +102 -0
  53. package/template/file-exchange/README.md +41 -0
  54. package/template/file-exchange/exports/.gitkeep +0 -0
  55. package/template/file-exchange/exports/consolidated-models.json +625 -0
  56. package/template/file-exchange/imports/.gitkeep +0 -0
  57. package/template/frontend/.env.example +2 -0
  58. package/template/frontend/package-lock.json +125 -122
  59. package/template/frontend/package.json +1 -1
  60. package/template/frontend/src/index.css +311 -0
  61. package/template/frontend/src/modules/_reference/services/health-api.js +1 -1
  62. package/template/frontend/src/shared/api/client.js +67 -5
  63. package/template/models/.gitkeep +0 -0
  64. package/template/package.json +13 -4
  65. package/template/scripts/check-api-docs.mjs +183 -0
  66. package/template/scripts/condense-file-structure.mjs +44 -0
  67. package/template/scripts/condense-models.mjs +70 -0
  68. package/template/scripts/condense-prompts.mjs +161 -0
  69. package/template/scripts/consolidated-output.mjs +49 -0
  70. package/template/scripts/export-consolidated-models.mjs +11 -0
  71. package/template/scripts/git-hooks/pre-push.sample +15 -0
  72. package/template/scripts/import-to-file-exchange.mjs +43 -0
  73. package/template/scripts/lib/api-inventory.mjs +182 -0
  74. package/template/scripts/lib/dev-log-human-format.mjs +360 -0
  75. package/template/scripts/lib/git-snapshot.mjs +46 -0
  76. package/template/scripts/lib/module-scaffold.mjs +37 -1
  77. package/template/scripts/lib/repo-tree.mjs +127 -0
  78. package/template/scripts/lib/run-tests.mjs +60 -0
  79. package/template/scripts/lint-contracts.mjs +57 -0
  80. package/template/scripts/lint-repo-artifacts.mjs +37 -0
  81. package/template/scripts/new-module.mjs +7 -0
  82. package/template/scripts/resolve-import-stamp.mjs +50 -0
  83. package/template/scripts/verify-dev-log.mjs +50 -0
  84. package/template/scripts/write-pre-push-dev-log.mjs +220 -0
  85. package/template/work-log/INDEX.md +3 -0
  86. package/template/work-log/README.md +40 -0
  87. package/template/work-log/dev-logs/README.md +97 -0
  88. package/template/work-log/dev-logs/schemas/dev-log-agent.v1.schema.json +119 -0
  89. package/template/work-log/dev-logs/templates/dev-log-human.template.md +10 -0
  90. package/template/work-log/handoffs/README.md +36 -0
  91. package/template/work-log/study-docs/README.md +13 -0
  92. package/bin/create-modular-monolith.js +0 -132
  93. package/template/backend/src/modules/_reference/evals/README.md +0 -6
  94. package/template/backend/src/modules/_reference/evals/datasets/example.cases.json +0 -12
  95. package/template/backend/src/modules/_reference/evals/runners/example.eval.mjs +0 -25
  96. package/template/scripts/sync-cli-template.mjs +0 -44
  97. /package/template/{frontend/src/modules → backend/db/migrations}/.gitkeep +0 -0
@@ -0,0 +1,79 @@
1
+ # Evals, regression, and CI gates
2
+
3
+ Plain-language guide for **domain-agnostic** projects scaffolded from this template.
4
+
5
+ ---
6
+
7
+ ## What is a “gate”?
8
+
9
+ A **gate** is an automatic check that must pass before code is merged.
10
+
11
+ | Gate | What it blocks |
12
+ |------|----------------|
13
+ | `npm run lint:contracts` | Broken contract paths in `manifest.json` |
14
+ | `npm run lint:repo-artifacts` | Missing platform folders (file-exchange, dev-logs, …) |
15
+ | `npm run lint:architecture` | Module boundary / layer / API doc violations |
16
+ | `npm test` | Unit/integration failures |
17
+ | `npm run test:evals` | Module `evals/runners/*.eval.mjs` failures |
18
+
19
+ GitHub Actions runs these on push/PR (see `.github/workflows/ci.yml`). Locally: **`npm run test:ci`**.
20
+
21
+ ---
22
+
23
+ ## What is “eval / regression”?
24
+
25
+ **Eval** = automated check that output meets expectations.
26
+
27
+ **Regression** = re-run evals after a change to catch quality going **down**.
28
+
29
+ ### Golden data is per domain case — not universal
30
+
31
+ Every product case is different (different users, documents, rules). You **do not** ship one golden dataset for all future cases.
32
+
33
+ | Pattern | When to use |
34
+ |---------|-------------|
35
+ | **Module example evals** | Shipped in `_reference` — smoke tests, no API keys |
36
+ | **Optional `evals/golden/{caseId}/`** | When **you** curate expected JSON for one fixed regression case |
37
+ | **Live runs only** | New cases with no golden yet — process, review, optionally add golden later |
38
+
39
+ Golden answers the question: *“On **this** known fixture, did we get worse than last time?”*
40
+ Not: *“We already know the truth for every new case.”*
41
+
42
+ When you add a domain module (`npm run new:module`), add `evals/runners/` and optional `evals/golden/` for cases you control.
43
+
44
+ ---
45
+
46
+ ## Trace IDs (observability)
47
+
48
+ Use `backend/src/shared/utils/traceId.js` in long-running workflows:
49
+
50
+ ```js
51
+ import { createTraceId, docTraceId } from "../shared/utils/traceId.js";
52
+
53
+ const batchTraceId = createTraceId("batch_my-job");
54
+ const traceId = docTraceId(batchTraceId, 1);
55
+ ```
56
+
57
+ Log both IDs in JSONL or structured logs so agents and humans can correlate steps. Plug the same IDs into Langfuse/OpenTelemetry later if needed.
58
+
59
+ ---
60
+
61
+ ## CI workflow
62
+
63
+ `.github/workflows/ci.yml`:
64
+
65
+ 1. Install backend + frontend
66
+ 2. `lint:contracts` · `lint:repo-artifacts` · `lint:architecture`
67
+ 3. `npm test` · `npm run test:evals`
68
+
69
+ ---
70
+
71
+ ## Adding domain evals
72
+
73
+ ```bash
74
+ npm run new:module -- billing --label "Billing"
75
+ # Add backend/src/modules/billing/evals/runners/my-check.eval.mjs
76
+ npm run test:evals -- billing
77
+ ```
78
+
79
+ See [MODULE_INTERNAL_CONTRACT.md](./MODULE_INTERNAL_CONTRACT.md) for colocated `prompts/` and `evals/`.
@@ -44,6 +44,8 @@ Every feature module lives at `backend/src/modules/<module-name>/` and **must**
44
44
  | --- | --- | --- |
45
45
  | **index** | `register(app, context)` — mount routes, register listeners | Any layer in **this** module, `src/shared/*`, npm |
46
46
  | **routes** | HTTP mapping, status codes, call services | `services`, `schemas`, `shared`, npm |
47
+
48
+ **HTTP API docs:** Every route must be listed in `docs/<module-name>/API.md` and `docs/API.md` (endpoint registry). See [API documentation contract](./API_DOCUMENTATION_CONTRACT.md). Enforced via `npm run lint:api-docs`.
47
49
  | **services** | Business logic, transactions, AI orchestration | `domain`, `repositories`, `adapters`, `prompts`, `schemas`, `events`, `utils`, `config`, `shared`, npm |
48
50
  | **repositories** | DB/files/API persistence | `domain`, `adapters`, `schemas`, `utils`, `shared`, npm |
49
51
  | **adapters** | Third-party APIs, SDK wrappers | `domain`, `schemas`, `utils`, `shared`, npm |
@@ -0,0 +1,221 @@
1
+ # Platform architecture — built for agents and engineering at scale
2
+
3
+ This starter is designed so **Cursor agents, CI, and humans** share the same map of the repository. Business features are added as modules; the **platform layer** stays stable.
4
+
5
+ ---
6
+
7
+ ## Design goals
8
+
9
+ | Goal | Mechanism |
10
+ |------|-----------|
11
+ | **Agents know where files go** | `REPO_ARTIFACT_LAYOUT.md`, `file-exchange/`, contract manifest |
12
+ | **Agents know what changed** | Pre-push dev log: Part I summary (mermaid, tables) + Part II detail + full tree |
13
+ | **Agents know which APIs exist** | `docs/API.md` registry + `api-inventory` in every dev log |
14
+ | **No silent drift** | `lint:contracts`, `lint:api-docs`, `lint:repo-artifacts` |
15
+ | **Handoff without chaos** | Dated `file-exchange/imports/{stamp}/` — never process from `Downloads/` |
16
+ | **Onboarding in one read** | `condense:all` → consolidated models, prompts, file tree in `exports/` |
17
+
18
+ ---
19
+
20
+ ## System map
21
+
22
+ ```mermaid
23
+ flowchart TB
24
+ subgraph human [Human workflow]
25
+ import[npm run import:file-exchange]
26
+ code[Implement in modules]
27
+ devlog[npm run dev-log:pre-push]
28
+ push[git push]
29
+ end
30
+
31
+ subgraph artifacts [Canonical artifacts]
32
+ fx[file-exchange/]
33
+ wl[work-log/dev-logs/]
34
+ docs[docs/architecture/contracts/]
35
+ api[docs/API.md]
36
+ end
37
+
38
+ subgraph agent [Agent reads first]
39
+ agentJson[work-log/dev-logs/agent/*.json]
40
+ consolidated[file-exchange/exports/consolidated-*.json]
41
+ end
42
+
43
+ import --> fx
44
+ code --> api
45
+ devlog --> wl
46
+ devlog --> agentJson
47
+ condense[npm run condense:all] --> consolidated
48
+ agentJson --> code
49
+ consolidated --> code
50
+ push --> devlog
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Modular monolith core
56
+
57
+ ```text
58
+ backend/src/core/ module-loader → register(app)
59
+ backend/src/modules/* one feature = one folder
60
+ frontend/src/core/ App shell + moduleRegistry
61
+ frontend/src/modules/* one route module per feature
62
+ ```
63
+
64
+ **Rules** (enforced by `lint:boundaries`, `lint:layers`):
65
+
66
+ - Modules import `shared/`, not other modules.
67
+ - Backend: routes → services → repositories/domain.
68
+ - Every new route appears in `docs/API.md`.
69
+
70
+ Scaffold: `npm run new:module -- my-feature --label "My Feature"`
71
+
72
+ ---
73
+
74
+ ## Contract pipeline
75
+
76
+ See [CONTRACTS_OVERVIEW.md](./CONTRACTS_OVERVIEW.md).
77
+
78
+ 1. **Register** in `contracts/manifest.json`
79
+ 2. **Document** in `contracts/*.contract.md`
80
+ 3. **Implement** in `*.contract.js` when code needs constants
81
+ 4. **Changelog** in `contracts/changelog.jsonl`
82
+ 5. **Lint** with `npm run lint:contracts`
83
+
84
+ Contracts version independently (e.g. `fileExchange` v001, `prePushDevLog` v001).
85
+
86
+ ---
87
+
88
+ ## File exchange (agent inbox)
89
+
90
+ ```text
91
+ file-exchange/imports/2026-05-23_15-59-43Z/ ← inbound only
92
+ file-exchange/exports/2026-05-23_16-00-00Z/ ← session outputs
93
+ file-exchange/exports/consolidated-*.json ← repo snapshots
94
+ ```
95
+
96
+ Stamp format: `YYYY-MM-DD_HH-MM-SSZ` via `formatExchangeTimestamp()`.
97
+
98
+ **Cursor rule** (`.cursor/rules/file-exchange-inbox.mdc`, `alwaysApply: true`) makes import mandatory before processing user files.
99
+
100
+ ---
101
+
102
+ ## Pre-push dev log (audit trail)
103
+
104
+ **Before every push:**
105
+
106
+ ```bash
107
+ npm run dev-log:pre-push -- --slug <kebab-topic>
108
+ ```
109
+
110
+ | File | Audience | Contents |
111
+ |------|----------|----------|
112
+ | `human/*_dev-log_*.md` | Humans | Part I: TOC, mermaid, API/version/test/git tables, condensed tree. Part II: decisions, iterations, full tree |
113
+ | `agent/*_dev-log-agent_*.json` | Agents | Same facts in structured JSON — read this first when resuming |
114
+
115
+ Tree capture ignores: `node_modules`, `.git`, `dist`, `build` (equivalent to `tree -I "node_modules|.git|dist|build"`).
116
+
117
+ Works **without git** until `git init`; then git sections auto-fill.
118
+
119
+ ---
120
+
121
+ ## Consolidated exports (repository X-ray)
122
+
123
+ ```bash
124
+ npm run condense:all
125
+ ```
126
+
127
+ | Output | Purpose |
128
+ |--------|---------|
129
+ | `consolidated-models.json` | Schema inventory (model-condenser) |
130
+ | `consolidated-prompts.json` | All prompt templates + manifests |
131
+ | `consolidated-file-structure.json` | Full file tree + stats |
132
+
133
+ Primary handoff path: `file-exchange/exports/`. Mirror: `models/` for API compatibility.
134
+
135
+ ---
136
+
137
+ ## Automation scripts reference
138
+
139
+ ### Governance (run in CI)
140
+
141
+ | Command | Script |
142
+ |---------|--------|
143
+ | `npm run lint:contracts` | `scripts/lint-contracts.mjs` |
144
+ | `npm run lint:repo-artifacts` | `scripts/lint-repo-artifacts.mjs` |
145
+ | `npm run lint:api-docs` | `scripts/check-api-docs.mjs` |
146
+ | `npm run lint:architecture` | boundaries + layers + api-docs |
147
+
148
+ ### Agent / session workflow
149
+
150
+ | Command | Script |
151
+ |---------|--------|
152
+ | `npm run import:file-exchange` | `scripts/import-to-file-exchange.mjs` |
153
+ | `npm run dev-log:pre-push` | `scripts/write-pre-push-dev-log.mjs` |
154
+ | `npm run dev-log:verify` | `scripts/verify-dev-log.mjs` |
155
+ | `npm run condense:all` | condense-prompts + file-structure + condense-models |
156
+
157
+ ### Scaffolding
158
+
159
+ | Command | Script |
160
+ |---------|--------|
161
+ | `npm run new:module` | `scripts/new-module.mjs` |
162
+
163
+ ---
164
+
165
+ ## Scaling to many modules
166
+
167
+ ```mermaid
168
+ flowchart LR
169
+ m1[module-a]
170
+ m2[module-b]
171
+ m3[module-n]
172
+ core[core + shared]
173
+ contracts[contracts/manifest]
174
+ m1 --> core
175
+ m2 --> core
176
+ m3 --> core
177
+ contracts --> m1
178
+ contracts --> m2
179
+ contracts --> m3
180
+ ```
181
+
182
+ Adding a module does **not** change the platform contracts. You:
183
+
184
+ 1. Run `new:module`
185
+ 2. Add rows to `docs/API.md`
186
+ 3. Register prompts in `prompts/manifest.json`
187
+ 4. Run `dev-log:pre-push` before push
188
+
189
+ The condenser and dev-log scripts scan the **whole repo** — new modules appear automatically in the next tree and API inventory.
190
+
191
+ ---
192
+
193
+ ## Cursor integration
194
+
195
+ | File | Role |
196
+ |------|------|
197
+ | `AGENTS.md` | Mandatory workflows for agents |
198
+ | `.cursor/commands/pre-push-dev-log.md` | How to fill dev logs |
199
+ | `.cursor/commands/planning-study-log.md` | Planning-only study logs |
200
+ | `.cursor/rules/file-exchange-inbox.mdc` | alwaysApply import discipline |
201
+ | `.cursor/rules/api-documentation.mdc` | Keep API docs in sync |
202
+
203
+ ---
204
+
205
+ ## What to read first (agents)
206
+
207
+ 1. `work-log/dev-logs/agent/` — latest `*_dev-log-agent_*.json`
208
+ 2. `file-exchange/exports/consolidated-file-structure.json` — layout
209
+ 3. `docs/architecture/CONTRACTS_OVERVIEW.md` — contract index
210
+ 4. `docs/API.md` — HTTP surface
211
+ 5. `AGENTS.md` — required commands
212
+
213
+ ---
214
+
215
+ ## Related docs
216
+
217
+ - [CONTRACTS_OVERVIEW.md](./CONTRACTS_OVERVIEW.md)
218
+ - [REPO_ARTIFACT_LAYOUT.md](./REPO_ARTIFACT_LAYOUT.md)
219
+ - [ARCHITECTURE_GUARDRAILS.md](./ARCHITECTURE_GUARDRAILS.md)
220
+ - [MODULE_INTERNAL_CONTRACT.md](./MODULE_INTERNAL_CONTRACT.md)
221
+ - [../STARTER_PACK.md](../STARTER_PACK.md)
@@ -0,0 +1,33 @@
1
+ # Repository artifact layout
2
+
3
+ Canonical paths for platform artifacts and human↔agent exchange.
4
+
5
+ ## Roots
6
+
7
+ | Root | Writable at runtime | Purpose |
8
+ |------|---------------------|---------|
9
+ | `file-exchange/imports\|exports/` | Yes | Dated human↔agent handoff |
10
+ | `work-log/dev-logs/human\|agent/` | Yes | Pre-push audit pairs |
11
+ | `models/consolidated-*.json` | Yes | Mirror of `file-exchange/exports/consolidated-*.json` |
12
+ | `work-log/handoffs/` | Yes | Session handoffs (markdown) |
13
+ | `data/` | Yes | **Your** domain runtime data (gitignore by default) |
14
+ | `evals/golden/{caseId}/` | Optional | Per-case regression fixtures when you add them |
15
+
16
+ ## File exchange
17
+
18
+ Imports: `file-exchange/imports/{2026-05-23_15-59-43Z}/`
19
+ Session exports: `file-exchange/exports/{stamp}/`
20
+ Consolidated snapshots: `file-exchange/exports/consolidated-*.json`
21
+
22
+ See [file-exchange/README.md](../../file-exchange/README.md).
23
+
24
+ ## Pre-push dev logs
25
+
26
+ ```text
27
+ work-log/dev-logs/human/{NNN}_{date}_{time}_dev-log_{slug}.md
28
+ work-log/dev-logs/agent/{NNN}_{date}_{time}_dev-log-agent_{slug}.json
29
+ ```
30
+
31
+ ## Domain modules
32
+
33
+ When you add features with `npm run new:module`, colocate runtime data under `data/<module>/` and optional `evals/golden/` per [EVAL_AND_CI.md](./EVAL_AND_CI.md).
@@ -0,0 +1,40 @@
1
+ # Contract: API documentation registry
2
+
3
+ **Version:** `v001`
4
+ **Registry:** [docs/API.md](../../API.md)
5
+ **Lint:** `npm run lint:api-docs` (`scripts/check-api-docs.mjs`)
6
+ **Dev-log inventory:** `scripts/lib/api-inventory.mjs`
7
+
8
+ ## Purpose
9
+
10
+ Single **endpoint registry** for all mounted Express routes. Pre-push dev logs and agents read this for active / stub / deprecated HTTP surfaces.
11
+
12
+ ## Registry sections (docs/API.md)
13
+
14
+ | Section | Use |
15
+ |---------|-----|
16
+ | **Endpoint registry** | Method, full path, module, description |
17
+ | **Module index** | Active vs stub modules |
18
+
19
+ ## Route classification (dev-log / agents)
20
+
21
+ | Class | Rule |
22
+ |-------|------|
23
+ | **active** | Documented route, not stub/deprecated in description |
24
+ | **stub** | Description contains `stub` or `health only` |
25
+ | **deprecated** | Description contains `deprecated` |
26
+
27
+ Do not remove deprecated rows from the registry until the route is removed from code ([API_DOCUMENTATION_CONTRACT.md](../API_DOCUMENTATION_CONTRACT.md)).
28
+
29
+ ## Versioned surfaces (not HTTP)
30
+
31
+ Captured in dev-log `apis.versioned` from:
32
+
33
+ - `backend/src/modules/case-filing-ai/contracts/pipelineVersions.js`
34
+ - `backend/src/modules/case-filing-ai/prompts/promptVersions.js`
35
+ - `MASTER_PROMPT_VERSION` env (`v1` \| `compact` \| `v2` \| `v001`)
36
+
37
+ ## Related
38
+
39
+ - [API_DOCUMENTATION_CONTRACT.md](../API_DOCUMENTATION_CONTRACT.md)
40
+ - [prePushDevLog.contract.md](./prePushDevLog.contract.md)
@@ -0,0 +1,12 @@
1
+ {"time":"2026-05-23T15:45:00Z","contract":"repoArtifactLayout","from":null,"to":"v001","reason":"Initial REPO_ARTIFACT_LAYOUT and file-exchange","author":"agent"}
2
+ {"time":"2026-05-23T15:45:00Z","contract":"fileExchange","from":null,"to":"v001","reason":"file-exchange/ imports and exports dated folders","author":"agent"}
3
+ {"time":"2026-05-23T15:46:00Z","contract":"caseFilingStorageLayout","from":null,"to":"v001","reason":"storageLayout.contract.js and storagePaths.js","author":"agent"}
4
+ {"time":"2026-05-23T15:46:00Z","contract":"parsedDocumentArtifacts","from":null,"to":"v001","reason":"parsed-documents artifact names and audit events","author":"agent"}
5
+ {"time":"2026-05-23T17:00:00Z","contract":"pipelineVersions","from":"case_001-v0-wiped","to":"case_001-v1-parsed-synthetic","reason":"Ingested synthetic golden parsed baseline (14 docs)","author":"agent"}
6
+ {"time":"2026-05-23T17:00:00Z","contract":"ruleAuthority","from":null,"to":"v001","reason":"Court rules services and authority rank enum","author":"agent"}
7
+ {"time":"2026-05-23T18:00:00Z","contract":"pipelineVersions","from":"case_001-v1-parsed-synthetic","to":"case_001-v2-full-expected","reason":"Ingested full doc/snapshot golden from bundle ground_truth.json","author":"agent"}
8
+ {"time":"2026-05-23T19:00:00Z","contract":"fileExchange","from":"v001","to":"v001","reason":"AGENTS.md + alwaysApply file-exchange-inbox rule; import:file-exchange script","author":"agent"}
9
+ {"time":"2026-05-23T20:00:00Z","contract":"consolidatedExports","from":null,"to":"v001","reason":"file-exchange/exports consolidated-*.json + models/ mirror; condense:all","author":"agent"}
10
+ {"time":"2026-05-23T20:00:00Z","contract":"prePushDevLog","from":null,"to":"v001","reason":"Paired human MD + agent JSON pre-push logs; API/tree/test audits","author":"agent"}
11
+ {"time":"2026-05-23T20:00:00Z","contract":"apiDocumentationRegistry","from":null,"to":"v001","reason":"docs/API.md registry contract for dev-log api inventory","author":"agent"}
12
+ {"time":"2026-05-23T20:01:00Z","contract":"fileExchange","from":"v001","to":"v001","reason":"Human-readable stamps; consolidated exports at exports root; contract doc","author":"agent"}
@@ -0,0 +1,58 @@
1
+ # Contract: consolidated exports
2
+
3
+ **Version:** `v001`
4
+ **Code:** `backend/src/shared/contracts/consolidatedExports.contract.js`
5
+
6
+ ## Purpose
7
+
8
+ Regenerable **repo snapshots** for human handoff and agent onboarding — not runtime filing data.
9
+
10
+ ## Primary paths (handoff)
11
+
12
+ ```text
13
+ file-exchange/exports/
14
+ consolidated-models.json
15
+ consolidated-prompts.json
16
+ consolidated-file-structure.json
17
+ ```
18
+
19
+ ## Mirror paths (API / git)
20
+
21
+ ```text
22
+ models/
23
+ consolidated-models.json ← model-condenser API writes here first
24
+ consolidated-prompts.json
25
+ consolidated-file-structure.json
26
+ ```
27
+
28
+ Every condense run writes **both** export and mirror.
29
+
30
+ ## Commands
31
+
32
+ ```bash
33
+ npm run condense:all
34
+ npm run condense-prompts
35
+ npm run condense-file-structure
36
+ npm --prefix backend run condense-models # or POST /api/model-condenser/condense
37
+ ```
38
+
39
+ ## Contents
40
+
41
+ | File | Source |
42
+ |------|--------|
43
+ | `consolidated-models.json` | Model condenser — schema inventory |
44
+ | `consolidated-prompts.json` | All `.prompt.md` / `.prompt.js` + manifests |
45
+ | `consolidated-file-structure.json` | Full file tree (tree ignore rules) |
46
+
47
+ ## File tree ignore (consolidated-file-structure)
48
+
49
+ Same as pre-push dev log: `node_modules`, `.git`, `dist`, `build`.
50
+
51
+ ## Deprecated
52
+
53
+ - `scripts/export-consolidated-models.mjs` → use `npm run condense-models` or `POST /api/model-condenser/condense`
54
+
55
+ ## Related
56
+
57
+ - [file-exchange/README.md](../../../file-exchange/README.md)
58
+ - [docs/model-condenser/API.md](../../model-condenser/API.md)
@@ -0,0 +1,47 @@
1
+ # Contract: file exchange
2
+
3
+ **Version:** `v001`
4
+ **Timestamp helper:** `backend/src/shared/utils/formatExchangeTimestamp.js`
5
+ **User doc:** [file-exchange/README.md](../../../file-exchange/README.md)
6
+
7
+ ## Layout
8
+
9
+ ```text
10
+ file-exchange/
11
+ imports/{stamp}/ ← inbound bundles (mandatory before processing)
12
+ exports/{stamp}/ ← session deliverables (batch runs, curl logs)
13
+ exports/consolidated-*.json ← see consolidatedExports contract
14
+ ```
15
+
16
+ ## Stamp format (human-readable UTC)
17
+
18
+ ```text
19
+ YYYY-MM-DD_HH-MM-SSZ
20
+ ```
21
+
22
+ Example: `2026-05-23_15-59-43Z`
23
+
24
+ Legacy compact stamps (`20260523T155943Z`) are normalized by `normalizeExchangeStamp()` in the timestamp helper.
25
+
26
+ ## Mandatory workflow (agents)
27
+
28
+ 1. `npm run import:file-exchange -- "<path>"`
29
+ 2. Process only from `imports/{stamp}/`
30
+ 3. Copy deliverables to `exports/{stamp}/`
31
+ 4. `npm run condense:all` when refreshing consolidated snapshots
32
+
33
+ Enforced by `AGENTS.md` and `.cursor/rules/file-exchange-inbox.mdc` (`alwaysApply: true`).
34
+
35
+ ## Scripts
36
+
37
+ | Script | Purpose |
38
+ |--------|---------|
39
+ | `scripts/import-to-file-exchange.mjs` | Copy bundle → `imports/{stamp}/` |
40
+ | `scripts/resolve-import-stamp.mjs` | Resolve human or legacy stamp folder |
41
+ | `scripts/ingest-golden-parsed.mjs` | Parsed cache → `evals/golden/` |
42
+ | `scripts/ingest-golden-expected.mjs` | Ground truth → `doc_NNN.expected.json` |
43
+
44
+ ## Related contracts
45
+
46
+ - [consolidatedExports.contract.md](./consolidatedExports.contract.md)
47
+ - [prePushDevLog.contract.md](./prePushDevLog.contract.md)
@@ -0,0 +1,39 @@
1
+ {
2
+ "repoArtifactLayout": {
3
+ "version": "v001",
4
+ "doc": "docs/architecture/REPO_ARTIFACT_LAYOUT.md",
5
+ "overview": "docs/architecture/CONTRACTS_OVERVIEW.md"
6
+ },
7
+ "fileExchange": {
8
+ "version": "v001",
9
+ "doc": "docs/architecture/contracts/fileExchange.contract.md",
10
+ "userDoc": "file-exchange/README.md",
11
+ "timestampHelper": "backend/src/shared/utils/formatExchangeTimestamp.js",
12
+ "importScript": "scripts/import-to-file-exchange.mjs"
13
+ },
14
+ "consolidatedExports": {
15
+ "version": "v001",
16
+ "doc": "docs/architecture/contracts/consolidatedExports.contract.md",
17
+ "file": "backend/src/shared/contracts/consolidatedExports.contract.js",
18
+ "utility": "backend/src/shared/utils/consolidatedExport.js"
19
+ },
20
+ "prePushDevLog": {
21
+ "version": "v001",
22
+ "doc": "docs/architecture/contracts/prePushDevLog.contract.md",
23
+ "file": "backend/src/shared/contracts/prePushDevLog.contract.js",
24
+ "schema": "work-log/dev-logs/schemas/dev-log-agent.v1.schema.json",
25
+ "generator": "scripts/write-pre-push-dev-log.mjs",
26
+ "humanFormat": "scripts/lib/dev-log-human-format.mjs",
27
+ "verify": "scripts/verify-dev-log.mjs",
28
+ "apiInventory": "scripts/lib/api-inventory.mjs",
29
+ "repoTree": "scripts/lib/repo-tree.mjs",
30
+ "workLogReadme": "work-log/dev-logs/README.md"
31
+ },
32
+ "apiDocumentationRegistry": {
33
+ "version": "v001",
34
+ "doc": "docs/architecture/contracts/apiDocumentationRegistry.contract.md",
35
+ "registry": "docs/API.md",
36
+ "lintScript": "scripts/check-api-docs.mjs",
37
+ "architectureDoc": "docs/architecture/API_DOCUMENTATION_CONTRACT.md"
38
+ }
39
+ }
@@ -0,0 +1,69 @@
1
+ # Contract: pre-push dev log
2
+
3
+ **Version:** `v001`
4
+ **Code:** `backend/src/shared/contracts/prePushDevLog.contract.js`
5
+ **Agent schema:** `work-log/dev-logs/schemas/dev-log-agent.v1.schema.json` (`1.0.0`)
6
+
7
+ ## Purpose
8
+
9
+ Before each git push, produce a **paired audit**:
10
+
11
+ | Audience | Path | Format |
12
+ |----------|------|--------|
13
+ | Human | `work-log/dev-logs/human/` | Markdown — Part I summary + Part II detail |
14
+ | Agent | `work-log/dev-logs/agent/` | JSON — machine-readable audit |
15
+
16
+ ## Commands
17
+
18
+ ```bash
19
+ npm run dev-log:pre-push -- --slug <kebab-topic> [--program 005] [--no-tests]
20
+ npm run dev-log:verify
21
+ npm run dev-log:pre-push -- --check # requires git + agent log for HEAD
22
+ ```
23
+
24
+ ## Human log structure (Part I + Part II)
25
+
26
+ **Part I — Summary** (auto-filled):
27
+
28
+ - Table of contents with anchor links
29
+ - Mermaid: HTTP modules, pipeline versions, pre-push flow
30
+ - Audit tables: API surface, version/prompt contracts, tests, git, repo shape
31
+ - Condensed repository tree (link to full tree in Part II)
32
+
33
+ **Part II — Detailed** (fill):
34
+
35
+ - Goals, decisions, changes, iterations, outcomes, follow-ups
36
+ - Full HTTP registry from `docs/API.md`
37
+ - Full git porcelain + diff stat
38
+ - Full repository tree
39
+
40
+ Generator: `scripts/lib/dev-log-human-format.mjs`
41
+
42
+ ## Agent log (required fields)
43
+
44
+ - `meta`, `summary`, `apis`, `git`, `tests`, `repositoryTree`
45
+ - `changes`, `decisions[]`, `iterations[]`
46
+ - `tradeoffs`, `improvements`, `regressions`, `risks`, `followUps`
47
+
48
+ `apis` is built by `scripts/lib/api-inventory.mjs` from `docs/API.md` + `pipelineVersions.js` + `promptVersions.js`.
49
+
50
+ ## Repository tree rules
51
+
52
+ Equivalent to:
53
+
54
+ ```bash
55
+ tree -I "node_modules|.git|dist|build"
56
+ ```
57
+
58
+ Implemented in `scripts/lib/repo-tree.mjs`. `.DS_Store` files also excluded.
59
+
60
+ ## Git
61
+
62
+ - Works **without** git (fields show `unknown` until `git init`)
63
+ - After git init: branch, SHA, porcelain, diff stat populate automatically
64
+
65
+ ## Related
66
+
67
+ - [work-log/dev-logs/README.md](../../../work-log/dev-logs/README.md)
68
+ - [AGENTS.md](../../../AGENTS.md) — pre-push section
69
+ - `.cursor/commands/pre-push-dev-log.md`