@thedecipherist/mdd 1.6.7 → 1.6.9

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.
@@ -25,6 +25,17 @@ Triggered when arguments start with `audit`.
25
25
  - If "manual": exit and let the user create docs per feature
26
26
  3. Resolve every source file referenced across all feature docs. Deduplicate (same file may appear in multiple feature docs).
27
27
 
28
+ **Feature doc cross-checks (run in Phase A1, before any agents are spawned):**
29
+
30
+ These checks require comparing feature docs to each other and to disk. They cannot be done by per-file agents and must be done here:
31
+
32
+ - For each feature, verify every path in `source_files` exists on disk. Missing files = P2 finding.
33
+ - For each feature with `depends_on` that includes a feature with `integration_contracts`: verify this feature's `satisfies_contracts` is not empty. Missing acknowledgment = P2 finding.
34
+ - For each feature with `satisfies_contracts` entries where `status: pending`: flag every pending entry as P1 — contract was documented but never wired.
35
+ - For each feature with `integration_contracts`: verify every listed `caller_feature` exists as a feature doc. Non-existent caller referenced = P3 finding.
36
+
37
+ Record all findings from this step in a dedicated `audits/doc-findings-<date>.md` file. These are merged into the final report in Phase A5 as a separate "Feature Doc Issues" section.
38
+
28
39
  **Incremental vs full (only when a previous completed audit exists):**
29
40
  ```
30
41
  A completed audit exists from <date>.
@@ -89,6 +100,32 @@ Main writes a shard file and config file for each agent into the job folder **be
89
100
 
90
101
  **`shard-N.md`** — flat list of files assigned to this agent, extracted from the manifest. The agent uses this to know its scope without parsing the full manifest.
91
102
 
103
+ **`integration-context.md`** — built once by main from all `.mdd/docs/*.md` files and written to the job folder. Every agent reads this at startup. Format:
104
+
105
+ ```markdown
106
+ # Integration Context
107
+ # Job: audit-<date>
108
+
109
+ ## Feature Source Files
110
+ <!-- Maps source files back to the feature that owns them -->
111
+ <feature-name>: src/foo.ts, src/bar.ts
112
+ <feature-name>: src/baz.ts
113
+
114
+ ## Integration Contracts
115
+ <!-- What each security/shared feature requires ALL callers to implement -->
116
+ ### <feature-name>
117
+ - Contract: <description of what caller must call/implement>
118
+ Caller features: <featureA>, <featureB>
119
+ Caller source files: src/a.ts, src/b.ts, src/c.ts
120
+
121
+ ## Satisfied Contracts
122
+ <!-- What each feature has acknowledged and wired -->
123
+ ### <feature-name>
124
+ - Satisfies: <other-feature> contract — status: <done|pending>
125
+ ```
126
+
127
+ If no feature has `integration_contracts`, write an empty file with `# No integration contracts defined`. This file is always created — agents must not fail if it is empty.
128
+
92
129
  **`agent-N-config.md`** format:
93
130
 
94
131
  ```markdown
@@ -99,9 +136,10 @@ You are Audit Agent <N> of <total>.
99
136
  Job: audit-<date>
100
137
 
101
138
  ## Paths (relative to project root)
102
- Shard file: .mdd/jobs/audit-<date>/shard-<N>.md
103
- Notes file: .mdd/jobs/audit-<date>/agent-<N>-notes.md
104
- Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
139
+ Shard file: .mdd/jobs/audit-<date>/shard-<N>.md
140
+ Notes file: .mdd/jobs/audit-<date>/agent-<N>-notes.md
141
+ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
142
+ Integration context: .mdd/jobs/audit-<date>/integration-context.md
105
143
 
106
144
  ## Rules
107
145
  - Write findings to your notes file ONLY. Never touch another agent's file.
@@ -115,11 +153,12 @@ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
115
153
  - `eval()` used anywhere — only `vm.runInNewContext` is permitted
116
154
  - Cloud metadata endpoints (169.254.169.254, 169.254.170.2, fd00:ec2::254, metadata.google.internal) reachable without block
117
155
  - Secrets, API keys, or credentials hardcoded in source
118
- - Security enforcement function exists in a dependency but is NOT called at this call site (check dependency docs for `integration_contracts`)
156
+ - Security enforcement function exists in a dependency but is NOT called at this call site check `integration-context.md` under "Integration Contracts" for the contract that applies to this file's feature, then verify the required call is present in this file
119
157
  - "Immutable" rule arrays exported as plain mutable arrays — not `Object.freeze()` + `readonly`
120
158
  - Untrusted MCP/API/CLI input used without validation or sanitization
121
159
  - Data cached or stored without masking applied first
122
- - `satisfies_contracts` entry is `status: pending` — contract was acknowledged but never wired
160
+
161
+ **Note:** `satisfies_contracts status: pending` is checked by main in Phase A1, not here — agents cannot read feature docs.
123
162
 
124
163
  ### P2 High
125
164
  - TypeScript `any` used — must use `unknown` with narrowing
@@ -127,21 +166,20 @@ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
127
166
  - `console.log` in library code (should use logger)
128
167
  - File exceeds 300 lines
129
168
  - Function exceeds 50 lines
130
- - Feature's `source_files` lists a file that does not exist on disk
131
169
  - Transformation/substitution function handles some but not all AST/domain types (silent fallthrough for unhandled types)
132
170
  - MCP-exposed function accepts untrusted params with no explicit validation
133
171
 
134
172
  ### P3 Medium
135
173
  - TypeScript strict mode not enabled in tsconfig
136
174
  - Missing error handling at system/user-input boundaries
137
- - Feature has `depends_on` entries with `integration_contracts` but `satisfies_contracts` is empty
138
- - Security module's `integration_contracts` specifies a caller that has no `satisfies_contracts` entry
139
175
  - Missing test cases for documented business rules
140
176
  - CLI command missing any of the universal flags (--env, --cwd, --verbose, --strict, --silent) — check all commands against the CLI feature doc's universal flags requirement
141
177
  - `file.*` filesystem helpers or path-resolving functions accept arbitrary paths without confinement to a documented jailRoot
142
178
  - Silent error swallow: catch block returns empty/undefined without pushing to warnings array
143
179
  - Template/substitution function matches `{{varname}}` without spaces but not `{{ varname }}` with spaces — spec uses spaced form; use regex `\s*` not exact string
144
180
 
181
+ **Note:** Feature-doc cross-checks (source_files on disk, integration_contracts vs satisfies_contracts) are handled by main in Phase A1 — not by per-file agents. Do not duplicate those checks here.
182
+
145
183
  ### P4 Low
146
184
  - Code style inconsistencies
147
185
  - Dead code / unused imports
@@ -152,7 +190,8 @@ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
152
190
  2. Read shard-<N>.md to know your file list
153
191
  3. Read MANIFEST.md — find the first [ ] entry in Shard <N>
154
192
  4. Read the last 20 lines of agent-<N>-notes.md for continuity
155
- 5. Begin the per-file loop at that first [ ] entry
193
+ 5. Read integration-context.md — load this into working memory. Use it when checking P1 (integration contract not called at call site): cross-reference the source file's feature against the contracts defined for its dependencies.
194
+ 6. Begin the per-file loop at that first [ ] entry
156
195
  ```
157
196
 
158
197
  This config file contains no source code or findings — only paths and instructions. It is the only thing an agent needs to resume correctly after a context clear.
@@ -171,7 +210,8 @@ STARTUP (run on every fresh start and after every context clear):
171
210
  2. Read shard-N.md
172
211
  3. Read MANIFEST.md — find first [ ] in own shard
173
212
  4. Read last 20 lines of agent-N-notes.md for continuity
174
- 5. Begin per-file loop
213
+ 5. Read integration-context.md — holds feature ownership map and all integration contracts
214
+ 6. Begin per-file loop
175
215
 
176
216
  PER-FILE LOOP:
177
217
  1. Mark file as [~] in MANIFEST.md ← write to disk first
@@ -180,9 +220,17 @@ PER-FILE LOOP:
180
220
  4. Append to agent-N-notes.md:
181
221
  ## src/handlers/auth.ts
182
222
  <findings, or "No issues found">
223
+ Contracts: <explicit result for every contract that applies to this file>
224
+ - [feature-name] contract: SATISFIED — [function name] called at line N
225
+ - [feature-name] contract: VIOLATION — required call absent (P1)
226
+ - (none) — no contracts apply to this file per integration-context.md
183
227
  5. Mark file as [x] or [!] in MANIFEST.md ← [!] = has findings
184
228
  6. Clear context ← every file, no exceptions
185
229
  7. On restart: run STARTUP above
230
+
231
+ The Contracts line is mandatory for every file. It allows Phase A6 to distinguish
232
+ "agent checked and confirmed satisfied" from "agent never checked." If integration-context.md
233
+ shows no contracts apply to this file, write "(none)" — never omit the line entirely.
186
234
  ```
187
235
 
188
236
  **Hard rules:**
@@ -216,7 +264,8 @@ Main merges all agent notes into the canonical output file:
216
264
  1. Read `MANIFEST.md` to get canonical file order
217
265
  2. For each file in manifest order, locate its `## <filepath>` section in the correct agent notes file
218
266
  3. Append to `audits/notes-<date>.md` in that order
219
- 4. Verify entry count in `audits/notes-<date>.md` matches manifest file count
267
+ 4. If `audits/doc-findings-<date>.md` exists and is non-empty, append its contents to `audits/notes-<date>.md` under a `## Feature Doc Issues` header
268
+ 5. Verify entry count in `audits/notes-<date>.md` matches manifest file count (doc findings are supplemental — they don't affect the per-file count)
220
269
 
221
270
  Merge is in manifest order, not agent completion order. The job folder is not touched during or after merge — all temp files remain until the report is confirmed in Phase A6.
222
271
 
@@ -224,7 +273,9 @@ Merge is in manifest order, not agent completion order. The job folder is not to
224
273
 
225
274
  ### Phase A6 — Analyze
226
275
 
227
- Read ONLY `audits/notes-<date>.md` (NOT source code again). Produce `audits/report-<date>.md` — include `mdd_version: <current from mdd.md frontmatter>` as the first line of frontmatter:
276
+ Read `audits/notes-<date>.md` as the primary source. Produce `audits/report-<date>.md` — include `mdd_version: <current from mdd.md frontmatter>` as the first line of frontmatter.
277
+
278
+ **Source code access in this phase:** Standard synthesis (items 1-8 below) uses only the notes file. The integration contract verification step that follows may re-read specific source files — that is the only exception, and it is mandatory.
228
279
 
229
280
  1. Executive summary
230
281
  2. Feature completeness matrix
@@ -240,14 +291,24 @@ Read ONLY `audits/notes-<date>.md` (NOT source code again). Produce `audits/repo
240
291
  - `[doc-field-gap]` — a new feature doc frontmatter field would have surfaced this earlier; suggest the field name and schema
241
292
  For each item, name the exact MDD file and section that needs changing.
242
293
 
243
- **Integration contract cross-check (in addition to per-file analysis):**
244
- After per-file analysis is complete, read all `.mdd/docs/*.md` and:
245
- - For each feature with `integration_contracts` entries: verify that every listed `caller_feature` has a matching `satisfies_contracts` entry referencing back to this feature
246
- - For each feature with `satisfies_contracts` entries still `status: pending`: flag as P1 — the wiring was documented but never implemented
247
- - For each feature doc where `satisfies_contracts` is empty but `depends_on` includes a feature with `integration_contracts`: flag as P2 — missing acknowledgment of mandatory contracts
248
- - For each source file flagged `[!]` where the finding is "security function not called at call site": cross-reference against `integration_contracts` of dependencies — these are contract violations, not just code quality issues
294
+ **Integration contract verification (proactive does not depend on what agents flagged):**
249
295
 
250
- Report these as a separate "Contract Violations" section before the standard findings table.
296
+ This step runs independently of agent findings. It uses `integration-context.md` from the job folder (already built in Phase A2) and re-reads specific source files as needed. The "Read ONLY notes" constraint applies to standard synthesis only — this step may re-read source files.
297
+
298
+ For each contract in `integration-context.md`:
299
+ 1. Identify all source files listed under "Caller source files" for that contract
300
+ 2. For each such source file, find its `## <filepath>` entry in `audits/notes-<date>.md` and read the `Contracts:` line:
301
+ - `SATISFIED` — agent confirmed the call is present. No action.
302
+ - `VIOLATION` — agent flagged it. Include as P1 in Contract Violations section.
303
+ - `(none)` written but this file IS a caller per integration-context.md — agent made an error. **Re-read that source file now** and check independently.
304
+ - `Contracts:` line is missing entirely — agent ran before this version of the workflow. **Re-read that source file now** and check independently.
305
+ 3. Report each confirmed gap as P1. Note whether it was caught by the agent or discovered by Phase A6.
306
+
307
+ Additionally read all `.mdd/docs/*.md` to catch any cases the Phase A1 doc cross-check might have missed (e.g., docs added after Phase A1 ran, or pending contracts that weren't flagged):
308
+ - Any `satisfies_contracts` with `status: pending` not already in doc-findings = P1
309
+ - Any `depends_on` with `integration_contracts` and empty `satisfies_contracts` not already in doc-findings = P2
310
+
311
+ Report all findings from this step as a "Contract Violations" section before the standard findings table.
251
312
 
252
313
  **Once `audits/report-<date>.md` is confirmed written and non-empty:**
253
314
  1. Copy `jobs/audit-<date>/MANIFEST.md` → `audits/MANIFEST-<date>.md`
@@ -377,4 +438,6 @@ After the issue is opened, update the `Status` field of each logged entry in `md
377
438
 
378
439
  When running `/mdd audit <section>` with fewer than 10 resolved files, skip the shard/config/agent system. Main conversation runs the per-file loop directly — context clear between each file, writing to a single `agent-1-notes.md` in the job folder. The job folder structure and completion sequence are otherwise identical.
379
440
 
441
+ **Integration context still applies in this mode.** Before starting the per-file loop, build `integration-context.md` into the job folder using the same logic as Phase A2 (read all `.mdd/docs/*.md`, extract contracts and feature-to-file mappings). Read `integration-context.md` at the start of the per-file loop and after every context clear — identical to the multi-agent startup sequence. The mandatory `Contracts:` line in notes applies here too.
442
+
380
443
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedecipherist/mdd",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "MDD — Manual-Driven Development workflow for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {