@pukujan/create-modular-monolith 2.0.0 → 2.1.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.
- package/README.md +91 -22
- package/index.js +47 -0
- package/package.json +16 -19
- package/template/.cursor/commands/planning-study-log.md +25 -0
- package/template/.cursor/commands/pre-push-dev-log.md +52 -0
- package/template/.cursor/rules/api-documentation.mdc +21 -0
- package/template/.cursor/rules/file-exchange-inbox.mdc +29 -0
- package/template/AGENTS.md +41 -0
- package/template/README.md +18 -57
- package/template/backend/.env.example +38 -0
- package/template/backend/package.json +14 -4
- package/template/backend/src/modules/model-condenser/README.md +7 -0
- package/template/backend/src/modules/model-condenser/config/index.js +20 -0
- package/template/backend/src/modules/model-condenser/events/index.js +1 -0
- package/template/backend/src/modules/model-condenser/index.js +12 -0
- package/template/backend/src/modules/model-condenser/routes/health.routes.js +10 -0
- package/template/backend/src/modules/model-condenser/routes/index.js +10 -0
- package/template/backend/src/modules/model-condenser/routes/modelCondenser.routes.js +44 -0
- package/template/backend/src/modules/model-condenser/services/health.service.js +8 -0
- package/template/backend/src/modules/model-condenser/services/modelCondenser.facade.js +58 -0
- package/template/backend/src/modules/model-condenser/services/modelCondenser.service.js +513 -0
- package/template/backend/src/modules/model-condenser/tests/integration/modelCondenser.routes.test.js +40 -0
- package/template/backend/src/modules/model-condenser/tests/unit/modelCondenser.service.test.js +31 -0
- package/template/backend/src/modules/model-condenser/utils/index.js +1 -0
- package/template/backend/src/shared/contracts/consolidatedExports.contract.js +19 -0
- package/template/backend/src/shared/contracts/prePushDevLog.contract.js +28 -0
- package/template/backend/src/shared/domain/case-filing/core-models.js +117 -0
- package/template/backend/src/shared/http/errors.js +8 -0
- package/template/backend/src/shared/utils/consolidatedExport.js +30 -0
- package/template/backend/src/shared/utils/formatExchangeTimestamp.js +47 -0
- package/template/backend/src/shared/utils/formatExchangeTimestamp.test.js +30 -0
- package/template/docs/API.md +42 -0
- package/template/docs/PUBLISHING.md +13 -1
- package/template/docs/README.md +4 -0
- package/template/docs/STARTER_PACK.md +4 -0
- package/template/docs/architecture/API_DOCUMENTATION_CONTRACT.md +112 -0
- package/template/docs/architecture/CONTRACTS_OVERVIEW.md +168 -0
- package/template/docs/architecture/MODULE_INTERNAL_CONTRACT.md +2 -0
- package/template/docs/architecture/PLATFORM_ARCHITECTURE.md +221 -0
- package/template/docs/architecture/REPO_ARTIFACT_LAYOUT.md +76 -0
- package/template/docs/architecture/contracts/apiDocumentationRegistry.contract.md +40 -0
- package/template/docs/architecture/contracts/changelog.jsonl +12 -0
- package/template/docs/architecture/contracts/consolidatedExports.contract.md +58 -0
- package/template/docs/architecture/contracts/fileExchange.contract.md +47 -0
- package/template/docs/architecture/contracts/manifest.json +56 -0
- package/template/docs/architecture/contracts/prePushDevLog.contract.md +69 -0
- package/template/docs/model-condenser/API.md +102 -0
- package/template/file-exchange/README.md +41 -0
- package/template/file-exchange/exports/.gitkeep +0 -0
- package/template/file-exchange/imports/.gitkeep +0 -0
- package/template/frontend/.env.example +2 -0
- package/template/frontend/package.json +1 -1
- package/template/frontend/src/index.css +311 -0
- package/template/frontend/src/modules/_reference/services/health-api.js +1 -1
- package/template/frontend/src/shared/api/client.js +67 -5
- package/template/models/.gitkeep +0 -0
- package/template/package.json +11 -4
- package/template/scripts/check-api-docs.mjs +183 -0
- package/template/scripts/condense-file-structure.mjs +44 -0
- package/template/scripts/condense-models.mjs +70 -0
- package/template/scripts/condense-prompts.mjs +161 -0
- package/template/scripts/consolidated-output.mjs +49 -0
- package/template/scripts/export-consolidated-models.mjs +11 -0
- package/template/scripts/git-hooks/pre-push.sample +15 -0
- package/template/scripts/import-to-file-exchange.mjs +43 -0
- package/template/scripts/lib/api-inventory.mjs +189 -0
- package/template/scripts/lib/dev-log-human-format.mjs +360 -0
- package/template/scripts/lib/git-snapshot.mjs +46 -0
- package/template/scripts/lib/module-scaffold.mjs +37 -1
- package/template/scripts/lib/repo-tree.mjs +127 -0
- package/template/scripts/lib/run-tests.mjs +60 -0
- package/template/scripts/lint-contracts.mjs +57 -0
- package/template/scripts/lint-repo-artifacts.mjs +37 -0
- package/template/scripts/new-module.mjs +7 -0
- package/template/scripts/resolve-import-stamp.mjs +50 -0
- package/template/scripts/verify-dev-log.mjs +50 -0
- package/template/scripts/write-pre-push-dev-log.mjs +220 -0
- package/template/work-log/INDEX.md +3 -0
- package/template/work-log/README.md +40 -0
- package/template/work-log/dev-logs/README.md +97 -0
- package/template/work-log/dev-logs/schemas/dev-log-agent.v1.schema.json +119 -0
- package/template/work-log/dev-logs/templates/dev-log-human.template.md +10 -0
- package/template/work-log/handoffs/README.md +36 -0
- package/template/work-log/study-docs/README.md +13 -0
- package/bin/create-modular-monolith.js +0 -132
- package/template/backend/package-lock.json +0 -882
- package/template/backend/src/modules/_reference/evals/README.md +0 -6
- package/template/backend/src/modules/_reference/evals/datasets/example.cases.json +0 -12
- package/template/backend/src/modules/_reference/evals/runners/example.eval.mjs +0 -25
- package/template/frontend/package-lock.json +0 -1724
- package/template/scripts/run-module-evals.mjs +0 -43
- package/template/scripts/sync-cli-template.mjs +0 -44
- /package/template/{frontend/src/modules → backend/db/migrations}/.gitkeep +0 -0
|
@@ -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,76 @@
|
|
|
1
|
+
# Repository artifact layout
|
|
2
|
+
|
|
3
|
+
Canonical paths for runtime data, golden fixtures, and human↔agent exchange.
|
|
4
|
+
|
|
5
|
+
## Roots
|
|
6
|
+
|
|
7
|
+
| Root | Env override | Writable at runtime |
|
|
8
|
+
|------|----------------|---------------------|
|
|
9
|
+
| `data/case-filing-ai/batches/` | `CASE_FILING_BATCH_DIR` | Yes (pipeline) |
|
|
10
|
+
| `evals/golden/{caseId}/` | `GOLDEN_DATASET_DIR` | No (fixtures) |
|
|
11
|
+
| `data/court-rules/fixtures/` | — | No |
|
|
12
|
+
| `eval-bundles/` | `EVAL_BUNDLE_ROOT_DIR` | Yes (export API) |
|
|
13
|
+
| `case-exports/` | `CASE_EXPORT_ROOT_DIR` | Yes (export API) |
|
|
14
|
+
| `file-exchange/imports\|exports/` | — | Yes (human triage) |
|
|
15
|
+
| `work-log/dev-logs/human\|agent/` | — | Yes (pre-push audit) |
|
|
16
|
+
| `models/consolidated-*.json` | — | Yes (condenser mirror) |
|
|
17
|
+
| `work-log/` | — | Yes (docs only) |
|
|
18
|
+
|
|
19
|
+
## Batch folder (`batches/batch-NNN/`)
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
uploads/
|
|
23
|
+
parsed-documents/doc-NNN/ # v2+ parsed cache
|
|
24
|
+
outputs/doc-NNN.json
|
|
25
|
+
evals/doc_NNN.eval-report.json
|
|
26
|
+
rule/
|
|
27
|
+
case-snapshot.json
|
|
28
|
+
processing-log.jsonl
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Golden (`evals/golden/case_001/`)
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
case_001.golden-dataset.json
|
|
35
|
+
doc_NNN.expected.json
|
|
36
|
+
parsed/doc-NNN/ # optional parse golden (v2)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## File exchange
|
|
40
|
+
|
|
41
|
+
Imports: `file-exchange/imports/{2026-05-23_15-59-43Z}/`
|
|
42
|
+
Session exports: `file-exchange/exports/{stamp}/`
|
|
43
|
+
Consolidated snapshots: `file-exchange/exports/consolidated-*.json`
|
|
44
|
+
|
|
45
|
+
See [file-exchange/README.md](../../file-exchange/README.md) and [contracts/fileExchange.contract.md](./contracts/fileExchange.contract.md).
|
|
46
|
+
|
|
47
|
+
## Pre-push dev logs
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
work-log/dev-logs/human/{NNN}_{date}_{time}_dev-log_{slug}.md
|
|
51
|
+
work-log/dev-logs/agent/{NNN}_{date}_{time}_dev-log-agent_{slug}.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`npm run dev-log:pre-push` — see [contracts/prePushDevLog.contract.md](./contracts/prePushDevLog.contract.md).
|
|
55
|
+
|
|
56
|
+
## Consolidated exports
|
|
57
|
+
|
|
58
|
+
`npm run condense:all` → [contracts/consolidatedExports.contract.md](./contracts/consolidatedExports.contract.md).
|
|
59
|
+
|
|
60
|
+
## Contracts
|
|
61
|
+
|
|
62
|
+
**Overview (start here):** [CONTRACTS_OVERVIEW.md](./CONTRACTS_OVERVIEW.md)
|
|
63
|
+
Manifest: [contracts/manifest.json](./contracts/manifest.json) · Changelog: [contracts/changelog.jsonl](./contracts/changelog.jsonl)
|
|
64
|
+
|
|
65
|
+
| Contract | Doc |
|
|
66
|
+
|----------|-----|
|
|
67
|
+
| File exchange | [fileExchange.contract.md](./contracts/fileExchange.contract.md) |
|
|
68
|
+
| Consolidated exports | [consolidatedExports.contract.md](./contracts/consolidatedExports.contract.md) |
|
|
69
|
+
| Pre-push dev log | [prePushDevLog.contract.md](./contracts/prePushDevLog.contract.md) |
|
|
70
|
+
| API registry | [apiDocumentationRegistry.contract.md](./contracts/apiDocumentationRegistry.contract.md) |
|
|
71
|
+
| Case filing storage | `backend/src/modules/case-filing-ai/contracts/storageLayout.contract.js` |
|
|
72
|
+
| Parsed artifacts | `parsedDocumentArtifacts.contract.js` |
|
|
73
|
+
| Pipeline versions | `pipelineVersions.js` |
|
|
74
|
+
| Rule authority | `court-rules/contracts/ruleAuthority.contract.js` |
|
|
75
|
+
|
|
76
|
+
Human storage doc: [docs/case-filing-ai/STORAGE.md](../case-filing-ai/STORAGE.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,56 @@
|
|
|
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
|
+
"caseFilingStorageLayout": {
|
|
40
|
+
"version": "v001",
|
|
41
|
+
"file": "backend/src/modules/case-filing-ai/contracts/storageLayout.contract.js"
|
|
42
|
+
},
|
|
43
|
+
"parsedDocumentArtifacts": {
|
|
44
|
+
"version": "v001",
|
|
45
|
+
"file": "backend/src/modules/case-filing-ai/contracts/parsedDocumentArtifacts.contract.js"
|
|
46
|
+
},
|
|
47
|
+
"pipelineVersions": {
|
|
48
|
+
"version": "v001",
|
|
49
|
+
"file": "backend/src/modules/case-filing-ai/contracts/pipelineVersions.js",
|
|
50
|
+
"promptVersions": "backend/src/modules/case-filing-ai/prompts/promptVersions.js"
|
|
51
|
+
},
|
|
52
|
+
"ruleAuthority": {
|
|
53
|
+
"version": "v001",
|
|
54
|
+
"file": "backend/src/modules/court-rules/contracts/ruleAuthority.contract.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -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`
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Model condenser — HTTP API
|
|
2
|
+
|
|
3
|
+
**Base path:** `/api/model-condenser`
|
|
4
|
+
|
|
5
|
+
Scans the repo and writes a **schema inventory** (`models/consolidated-models.json`). This is unrelated to case eval reports or `eval-bundles/`.
|
|
6
|
+
|
|
7
|
+
**Routes:** [`backend/src/modules/model-condenser/routes/modelCondenser.routes.js`](../../backend/src/modules/model-condenser/routes/modelCondenser.routes.js)
|
|
8
|
+
|
|
9
|
+
**Contract:** [API documentation contract](../architecture/API_DOCUMENTATION_CONTRACT.md)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Endpoint quick reference
|
|
14
|
+
|
|
15
|
+
| Method | Path | Description |
|
|
16
|
+
|--------|------|-------------|
|
|
17
|
+
| GET | `/health` | Module health |
|
|
18
|
+
| POST | `/condense` | Regenerate consolidated-models.json |
|
|
19
|
+
| GET | `/consolidated` | Read consolidated schema inventory |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Health
|
|
24
|
+
|
|
25
|
+
| Method | Path | Description |
|
|
26
|
+
|--------|------|-------------|
|
|
27
|
+
| GET | `/health` | Module health |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Condense
|
|
32
|
+
|
|
33
|
+
### `POST /condense`
|
|
34
|
+
|
|
35
|
+
Regenerate `models/consolidated-models.json` from repo sources.
|
|
36
|
+
|
|
37
|
+
**Body (JSON, optional):**
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{ "includePayload": false }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Field | Default | Description |
|
|
44
|
+
|-------|---------|-------------|
|
|
45
|
+
| `includePayload` | `false` | If `true`, include full consolidated document in response |
|
|
46
|
+
|
|
47
|
+
**Response 201:**
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"status": "written",
|
|
52
|
+
"outputPath": "/abs/path/models/consolidated-models.json",
|
|
53
|
+
"outputRelativePath": "models/consolidated-models.json",
|
|
54
|
+
"modelCount": 42,
|
|
55
|
+
"exampleInstanceCount": 10,
|
|
56
|
+
"generatedAt": "2026-05-23T..."
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**CLI equivalent:** `npm run condense-models` (from `backend/`)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Read consolidated file
|
|
65
|
+
|
|
66
|
+
### `GET /consolidated`
|
|
67
|
+
|
|
68
|
+
**Query:**
|
|
69
|
+
|
|
70
|
+
| Param | Description |
|
|
71
|
+
|-------|-------------|
|
|
72
|
+
| `includePayload=true` | Return full `consolidated` object in addition to summary |
|
|
73
|
+
|
|
74
|
+
**Response 200 (summary):**
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"status": "ready | missing",
|
|
79
|
+
"exists": true,
|
|
80
|
+
"outputPath": "...",
|
|
81
|
+
"outputRelativePath": "models/consolidated-models.json",
|
|
82
|
+
"generatedAt": "...",
|
|
83
|
+
"modelCount": 42
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**404** if file missing — run `POST /condense` first.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Environment variables
|
|
92
|
+
|
|
93
|
+
| Variable | Default | Purpose |
|
|
94
|
+
|----------|---------|---------|
|
|
95
|
+
| `MODEL_CONDENSER_OUTPUT_DIR` | `{repo}/models` | Output directory |
|
|
96
|
+
| `MODEL_CONDENSER_OUTPUT_FILE` | `consolidated-models.json` | Output filename |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Tests
|
|
101
|
+
|
|
102
|
+
`backend/src/modules/model-condenser/tests/integration/modelCondenser.routes.test.js`
|