@thedecipherist/mdd 1.5.5 → 1.5.6

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.
@@ -101,6 +101,40 @@ Manifest: .mdd/jobs/audit-<date>/MANIFEST.md
101
101
  - Clear context after every single file — no exceptions.
102
102
  - On every startup (including post-clear): follow STARTUP SEQUENCE below.
103
103
 
104
+ ## Standard Audit Criteria (apply to every file)
105
+
106
+ ### P1 Critical
107
+ - `eval()` used anywhere — only `vm.runInNewContext` is permitted
108
+ - Cloud metadata endpoints (169.254.169.254, 169.254.170.2, fd00:ec2::254, metadata.google.internal) reachable without block
109
+ - Secrets, API keys, or credentials hardcoded in source
110
+ - Security enforcement function exists in a dependency but is NOT called at this call site (check dependency docs for `integration_contracts`)
111
+ - "Immutable" rule arrays exported as plain mutable arrays — not `Object.freeze()` + `readonly`
112
+ - Untrusted MCP/API/CLI input used without validation or sanitization
113
+ - Data cached or stored without masking applied first
114
+ - `satisfies_contracts` entry is `status: pending` — contract was acknowledged but never wired
115
+
116
+ ### P2 High
117
+ - TypeScript `any` used — must use `unknown` with narrowing
118
+ - Missing `.js` extension on ESM imports in src/ files (NodeNext resolution)
119
+ - `console.log` in library code (should use logger)
120
+ - File exceeds 300 lines
121
+ - Function exceeds 50 lines
122
+ - Feature's `source_files` lists a file that does not exist on disk
123
+ - Transformation/substitution function handles some but not all AST/domain types (silent fallthrough for unhandled types)
124
+ - MCP-exposed function accepts untrusted params with no explicit validation
125
+
126
+ ### P3 Medium
127
+ - TypeScript strict mode not enabled in tsconfig
128
+ - Missing error handling at system/user-input boundaries
129
+ - Feature has `depends_on` entries with `integration_contracts` but `satisfies_contracts` is empty
130
+ - Security module's `integration_contracts` specifies a caller that has no `satisfies_contracts` entry
131
+ - Missing test cases for documented business rules
132
+
133
+ ### P4 Low
134
+ - Code style inconsistencies
135
+ - Dead code / unused imports
136
+ - Minor spec divergences
137
+
104
138
  ## Startup Sequence
105
139
  1. Read this config file
106
140
  2. Read shard-<N>.md to know your file list
@@ -185,6 +219,17 @@ Read ONLY `audits/notes-<date>.md` (NOT source code again). Produce `audits/repo
185
219
  3. Findings by severity (P1 Critical / P2 High / P3 Medium / P4 Low)
186
220
  4. Test coverage summary
187
221
  5. Fix plan with effort estimates and affected files per finding
222
+ 6. Root Cause Analysis — for each cluster of findings, explain WHY the code writer made the mistake (not just what is wrong). Common root causes: "security module built in isolation without integration contracts," "immutability described in spec but not enforced at the code level," "MCP tool written without a threat model," "node type added after transformation function was written."
223
+ 7. Prevention Rules — derive concrete, actionable rules that would have prevented each finding cluster. Format: "When implementing X, always Y. Never Z. Reasoning: [which finding caused this]." These rules are proposed for addition to CLAUDE.md at the end of the audit.
224
+
225
+ **Integration contract cross-check (in addition to per-file analysis):**
226
+ After per-file analysis is complete, read all `.mdd/docs/*.md` and:
227
+ - For each feature with `integration_contracts` entries: verify that every listed `caller_feature` has a matching `satisfies_contracts` entry referencing back to this feature
228
+ - For each feature with `satisfies_contracts` entries still `status: pending`: flag as P1 — the wiring was documented but never implemented
229
+ - 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
230
+ - 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
231
+
232
+ Report these as a separate "Contract Violations" section before the standard findings table.
188
233
 
189
234
  **Once `audits/report-<date>.md` is confirmed written and non-empty:**
190
235
  1. Copy `jobs/audit-<date>/MANIFEST.md` → `audits/MANIFEST-<date>.md`
@@ -193,6 +193,8 @@ phase: <last completed phase name, or "all" when fully built>
193
193
  mdd_version: <read from mdd.md frontmatter mdd_version field>
194
194
  tags: [<4-8 domain-concept keywords — systems touched, technology, feature names. NOT file paths>]
195
195
  path: <Area/Section>
196
+ integration_contracts: []
197
+ satisfies_contracts: []
196
198
  known_issues: []
197
199
  ---
198
200
 
@@ -226,6 +228,14 @@ known_issues: []
226
228
 
227
229
  <What this feature requires from other features. List by documentation ID.>
228
230
 
231
+ ## Security
232
+
233
+ <Only required when this feature: provides a security enforcement function, accepts external/user/MCP input, stores or caches data, spawns processes, or makes network calls. Leave empty otherwise.>
234
+
235
+ <For security enforcement features: list integration_contracts — which call sites must invoke which functions.>
236
+ <For input-accepting features: document trusted vs untrusted input boundary, sanitization requirements, and what a malicious caller could attempt.>
237
+ <For caching features: document what masking or sanitization runs before storage.>
238
+
229
239
  ## Known Issues
230
240
 
231
241
  <Empty for new features. Will be populated by future audits.>
@@ -235,6 +245,50 @@ known_issues: []
235
245
 
236
246
  **Always set `last_synced` to today's date** when writing or updating a feature doc. This is what SCAN MODE uses to detect drift. Set `status: draft` for new docs; update to `in_progress` when implementation begins, `complete` when Phase 7 is done.
237
247
 
248
+ #### Phase 3a — Integration Contract Resolution (mandatory when `depends_on` is non-empty)
249
+
250
+ After writing the feature doc, resolve integration obligations from dependencies:
251
+
252
+ 1. For each feature ID in `depends_on`, read its `.mdd/docs/*.md` file
253
+ 2. Check whether it has `integration_contracts` entries
254
+ 3. For each contract that applies to the current feature, add it to `satisfies_contracts` as a **placeholder** showing what must be wired:
255
+
256
+ ```yaml
257
+ satisfies_contracts:
258
+ - from: <dependency-feature-id>
259
+ function: <function-name>(<args>)
260
+ when: <condition — e.g. "before any file read in executeInclude">
261
+ status: pending ← change to "verified: <file>:<line>" during Phase 6
262
+ ```
263
+
264
+ **Leaving `satisfies_contracts` empty when a dependency has mandatory `integration_contracts` is a build error.** Do not proceed past Phase 3a until all applicable contracts are acknowledged.
265
+
266
+ **Cross-cutting concerns that always require contract resolution:**
267
+ - Any dependency tagged with `security`, `auth`, `masking`, `filesystem`, `audit`, `immutable` — its contracts are always mandatory
268
+ - Any dependency that provides a "check before X" or "enforce Y" function — that function must be in your `satisfies_contracts`
269
+
270
+ During Phase 6 implementation, update each `satisfies_contracts` entry from `status: pending` to `verified: <file>:<line>` as each call site is wired. Phase 7c will verify all entries are `verified` before marking the feature complete.
271
+
272
+ #### Phase 3b — Special Case Rules
273
+
274
+ These rules apply regardless of what the feature doc says. They are not optional.
275
+
276
+ **Immutability rule:** Any spec language describing values as "immutable," "cannot be overridden," "always enforced," or "built-in" requires both:
277
+ - `readonly string[]` (or `as const`) TypeScript typing
278
+ - `Object.freeze()` applied at definition
279
+
280
+ Using a plain `const` array is not sufficient and will fail audit.
281
+
282
+ **MCP and external-caller threat model:** Any feature that exposes functions to MCP clients, CLI users, API callers, or any untrusted external party must include a Security section in its doc that explicitly:
283
+ - Lists which inputs are untrusted
284
+ - States what a malicious caller could send
285
+ - Specifies validation/sanitization required before use
286
+ - States what the function is NOT permitted to expose (e.g., full `process.env`, raw credentials, unrestricted filesystem paths)
287
+
288
+ **Node substitution completeness rule:** Any function that transforms, substitutes, or dispatches across AST node types must handle ALL node types defined in `types.ts` — either explicitly or with a documented explicit-skip decision. An unhandled node type that silently falls through is a bug, not a design choice.
289
+
290
+ **Existence gate for source_files:** When marking `status: complete`, all files listed in `source_files` must exist on disk. Missing files block completion. Add missing files to `known_issues` with a TODO, or implement them before closing the feature.
291
+
238
292
  **Determine the `path` field** before writing the doc. Read the `path` values of all existing docs in `.mdd/docs/` to understand established product vocabulary and category names. Then ask: "What would a user navigate to in order to reach this feature?" — answer in their mental model of the product, not the code structure. Use 1–3 segments, Title Case, product vocabulary (e.g. `Auth/Login`, `E-commerce/Cart`, `Dashboard/Analytics`). Siblings must use identical parent spelling — if `Auth/Login` exists, use `Auth` not `Authentication`. If you can infer the path from context with confidence, set it and show the user. If genuinely ambiguous (feature could belong in 2+ places), ask: "Where does this feature live in the product? (e.g. `Auth/Login` or `Dashboard/Reports`)"
239
293
 
240
294
  **After writing the feature doc**, trigger the `.mdd/.startup.md` rebuild (same logic as in Status Mode — rebuild auto-generated zone, preserve Notes zone) so the Features list stays current.
@@ -604,7 +658,15 @@ where the agent patches the wrong thing because it accepted an external excuse t
604
658
 
605
659
  **If integration verified:**
606
660
 
607
- 1. **Update the feature doc frontmatter** — write these fields now, before displaying the signal:
661
+ 1. **Contract verification gate** — before marking complete, check the feature doc's `satisfies_contracts`:
662
+ - Any entry still `status: pending` means the integration was never wired
663
+ - For each pending entry: locate the call site in the implementation, verify it exists, update to `verified: <file>:<line>`
664
+ - If the call site is missing: implement it now (do not mark complete without it)
665
+ - **A feature with any `pending` contract cannot be marked `status: complete`**
666
+
667
+ Also check that all files in `source_files` exist on disk. Any missing file must be implemented or moved to `known_issues` with explicit documentation of why it was deferred.
668
+
669
+ 2. **Update the feature doc frontmatter** — write these fields now, before displaying the signal:
608
670
  - `status: complete`
609
671
  - `phase: all`
610
672
  - `last_synced: <today>`
package/commands/mdd.md CHANGED
@@ -3,7 +3,7 @@ description: "MDD workflow — Document → Audit → Fix → Verify. Build feat
3
3
  scope: project
4
4
  argument-hint: "<feature-description> or audit [section]"
5
5
  allowed-tools: Read, Write, Edit, Grep, Glob, Bash, AskUserQuestion, Agent
6
- mdd_version: 9
6
+ mdd_version: 10
7
7
  ---
8
8
 
9
9
  # MDD — Manual-Driven Development Workflow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedecipherist/mdd",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "MDD — Manual-Driven Development workflow for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {