musubix3 0.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.
Files changed (97) hide show
  1. package/.github/plugin/marketplace.json +16 -0
  2. package/.github/skills/sdd-change/SKILL.md +78 -0
  3. package/.github/skills/sdd-design/SKILL.md +26 -0
  4. package/.github/skills/sdd-formal-codegraph/SKILL.md +53 -0
  5. package/.github/skills/sdd-implementation/SKILL.md +54 -0
  6. package/.github/skills/sdd-knowledge/SKILL.md +24 -0
  7. package/.github/skills/sdd-quality/SKILL.md +69 -0
  8. package/.github/skills/sdd-requirements/SKILL.md +42 -0
  9. package/.github/skills/sdd-traceability/SKILL.md +28 -0
  10. package/CHANGELOG.md +152 -0
  11. package/LICENSE +21 -0
  12. package/README-ja.md +573 -0
  13. package/README.md +639 -0
  14. package/assets/ADR-0001.md +15 -0
  15. package/assets/constitution.md +17 -0
  16. package/assets/design.md +13 -0
  17. package/assets/requirements.md +15 -0
  18. package/dist/packages/analysis/src/adapters.d.ts +12 -0
  19. package/dist/packages/analysis/src/adapters.js +167 -0
  20. package/dist/packages/analysis/src/adapters.js.map +1 -0
  21. package/dist/packages/analysis/src/attestation.d.ts +50 -0
  22. package/dist/packages/analysis/src/attestation.js +474 -0
  23. package/dist/packages/analysis/src/attestation.js.map +1 -0
  24. package/dist/packages/analysis/src/change.d.ts +53 -0
  25. package/dist/packages/analysis/src/change.js +337 -0
  26. package/dist/packages/analysis/src/change.js.map +1 -0
  27. package/dist/packages/analysis/src/config.d.ts +104 -0
  28. package/dist/packages/analysis/src/config.js +456 -0
  29. package/dist/packages/analysis/src/config.js.map +1 -0
  30. package/dist/packages/analysis/src/files.d.ts +13 -0
  31. package/dist/packages/analysis/src/files.js +103 -0
  32. package/dist/packages/analysis/src/files.js.map +1 -0
  33. package/dist/packages/analysis/src/formal.d.ts +82 -0
  34. package/dist/packages/analysis/src/formal.js +579 -0
  35. package/dist/packages/analysis/src/formal.js.map +1 -0
  36. package/dist/packages/analysis/src/gate.d.ts +56 -0
  37. package/dist/packages/analysis/src/gate.js +484 -0
  38. package/dist/packages/analysis/src/gate.js.map +1 -0
  39. package/dist/packages/analysis/src/graph.d.ts +52 -0
  40. package/dist/packages/analysis/src/graph.js +737 -0
  41. package/dist/packages/analysis/src/graph.js.map +1 -0
  42. package/dist/packages/analysis/src/index.d.ts +17 -0
  43. package/dist/packages/analysis/src/index.js +18 -0
  44. package/dist/packages/analysis/src/index.js.map +1 -0
  45. package/dist/packages/analysis/src/knowledge.d.ts +29 -0
  46. package/dist/packages/analysis/src/knowledge.js +95 -0
  47. package/dist/packages/analysis/src/knowledge.js.map +1 -0
  48. package/dist/packages/analysis/src/model-correspondence.d.ts +45 -0
  49. package/dist/packages/analysis/src/model-correspondence.js +310 -0
  50. package/dist/packages/analysis/src/model-correspondence.js.map +1 -0
  51. package/dist/packages/analysis/src/mutation.d.ts +54 -0
  52. package/dist/packages/analysis/src/mutation.js +299 -0
  53. package/dist/packages/analysis/src/mutation.js.map +1 -0
  54. package/dist/packages/analysis/src/order.d.ts +23 -0
  55. package/dist/packages/analysis/src/order.js +89 -0
  56. package/dist/packages/analysis/src/order.js.map +1 -0
  57. package/dist/packages/analysis/src/performance.d.ts +65 -0
  58. package/dist/packages/analysis/src/performance.js +319 -0
  59. package/dist/packages/analysis/src/performance.js.map +1 -0
  60. package/dist/packages/analysis/src/process.d.ts +14 -0
  61. package/dist/packages/analysis/src/process.js +79 -0
  62. package/dist/packages/analysis/src/process.js.map +1 -0
  63. package/dist/packages/analysis/src/tdd.d.ts +65 -0
  64. package/dist/packages/analysis/src/tdd.js +353 -0
  65. package/dist/packages/analysis/src/tdd.js.map +1 -0
  66. package/dist/packages/analysis/src/trace.d.ts +45 -0
  67. package/dist/packages/analysis/src/trace.js +242 -0
  68. package/dist/packages/analysis/src/trace.js.map +1 -0
  69. package/dist/packages/analysis/src/workflow.d.ts +59 -0
  70. package/dist/packages/analysis/src/workflow.js +405 -0
  71. package/dist/packages/analysis/src/workflow.js.map +1 -0
  72. package/dist/packages/cli/src/install.d.ts +15 -0
  73. package/dist/packages/cli/src/install.js +71 -0
  74. package/dist/packages/cli/src/install.js.map +1 -0
  75. package/dist/packages/cli/src/main.d.ts +3 -0
  76. package/dist/packages/cli/src/main.js +364 -0
  77. package/dist/packages/cli/src/main.js.map +1 -0
  78. package/dist/packages/domain/src/constitution.d.ts +3 -0
  79. package/dist/packages/domain/src/constitution.js +46 -0
  80. package/dist/packages/domain/src/constitution.js.map +1 -0
  81. package/dist/packages/domain/src/design.d.ts +8 -0
  82. package/dist/packages/domain/src/design.js +59 -0
  83. package/dist/packages/domain/src/design.js.map +1 -0
  84. package/dist/packages/domain/src/index.d.ts +5 -0
  85. package/dist/packages/domain/src/index.js +6 -0
  86. package/dist/packages/domain/src/index.js.map +1 -0
  87. package/dist/packages/domain/src/markdown.d.ts +16 -0
  88. package/dist/packages/domain/src/markdown.js +72 -0
  89. package/dist/packages/domain/src/markdown.js.map +1 -0
  90. package/dist/packages/domain/src/requirements.d.ts +3 -0
  91. package/dist/packages/domain/src/requirements.js +195 -0
  92. package/dist/packages/domain/src/requirements.js.map +1 -0
  93. package/dist/packages/domain/src/types.d.ts +100 -0
  94. package/dist/packages/domain/src/types.js +14 -0
  95. package/dist/packages/domain/src/types.js.map +1 -0
  96. package/package.json +59 -0
  97. package/plugin.json +9 -0
package/README.md ADDED
@@ -0,0 +1,639 @@
1
+ # musubix3
2
+
3
+ **Release candidate · GitHub Copilot CLI only · Node.js ≥20 · TypeScript · MIT**
4
+
5
+ [日本語](README-ja.md)
6
+
7
+ Specification-driven development (SDD) skills backed by deterministic checks:
8
+ requirements → constitution → design/ADRs → implementation → traceability →
9
+ quality evidence. Optional formal consistency, compiler dependency analysis and
10
+ local knowledge retrieval support the workflow.
11
+
12
+ Learned from [musubix2](https://github.com/nahisaho/musubix2)'s concepts, rebuilt
13
+ cleanly in three workspaces. No artifact compatibility or migration is promised.
14
+ This repository does **not** guarantee correctness simply because IDs are linked
15
+ or requirements are satisfiable.
16
+
17
+ ## Quick start
18
+
19
+ The RC can be built and packed locally; registry commands below assume the
20
+ package has been published. No publication is performed by installation tests.
21
+
22
+ ```sh
23
+ git clone https://github.com/nahisaho/musubix3.git
24
+ cd musubix3
25
+ npm install
26
+ npm run build
27
+ node dist/packages/cli/src/main.js --help
28
+ node dist/packages/cli/src/main.js init --root ../your-project --dry-run
29
+ node dist/packages/cli/src/main.js init --root ../your-project
30
+ ```
31
+
32
+ Once available on npm, from your target project:
33
+
34
+ ```sh
35
+ npx musubix3 init --dry-run
36
+ npx musubix3 init
37
+ copilot
38
+ ```
39
+
40
+ Ask Copilot: “Use sdd-change to add this feature and propagate it through the
41
+ specification, implementation, traceability, and quality gate.”
42
+ All eight skills instruct Copilot to follow your input language (English/Japanese).
43
+
44
+ `init` (`install` alias) copies repository-local skills and creates starter SDD
45
+ artifacts. It preserves existing files, merges a cache ignore rule, and is
46
+ idempotent. `--force` replaces only named bundled/managed paths; it does not
47
+ delete unrelated files. Review its dry-run first. No Copilot global settings,
48
+ MCP, LSP, hooks, or project instructions are overwritten. Symbolic-link write
49
+ targets and paths escaping the project are refused.
50
+
51
+ The starter is deliberately **not release-ready**: replace its example, implement
52
+ and test it, and configure real check commands before expecting the gate to pass.
53
+
54
+ ## Distribution options
55
+
56
+ Choose one skill-loading route to avoid duplicate skill names.
57
+
58
+ ### Native plugin (direct)
59
+
60
+ ```sh
61
+ copilot plugin install ./musubix3 # built/local clone, from its parent
62
+ copilot plugin install nahisaho/musubix3 # published GitHub repository
63
+ ```
64
+
65
+ `plugin.json` at the repository root is the source of truth and references
66
+ `.github/skills/`. The plugin contains skills, not an agent runtime or background
67
+ services. Git installs do not compile/install the npm engine: build the clone or
68
+ install the npm package separately when running `npx musubix3` commands.
69
+
70
+ From an installed npm package, `npx musubix3 plugin-install` delegates directly to
71
+ `copilot plugin install <absolute-package-root>`. It does not edit Copilot
72
+ internals. For a durable local plugin path, prefer `npm install --save-dev musubix3`
73
+ and `npx --no-install musubix3 plugin-install` over an ephemeral npx cache.
74
+
75
+ ### Native marketplace
76
+
77
+ ```sh
78
+ copilot plugin marketplace add nahisaho/musubix3
79
+ copilot plugin install musubix3@musubix3-marketplace
80
+ # Local development:
81
+ copilot plugin marketplace add ./musubix3
82
+ ```
83
+
84
+ The catalog is `.github/plugin/marketplace.json`; its plugin source is `.`.
85
+ These flows use the [native plugin interface](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference).
86
+
87
+ ### Repository-local skills / npm installer
88
+
89
+ Run `npx musubix3 init` in the target repository, or copy `.github/skills/sdd-*`
90
+ there yourself. Start Copilot in that trusted project. `init --root <dir>` targets
91
+ another project; `--feature <slug>` changes the starter directory and ID prefix.
92
+ Installing another feature does not reset existing configuration.
93
+
94
+ ## Skills and native boundaries
95
+
96
+ | Skill | Purpose |
97
+ |---|---|
98
+ | `sdd-change` | End-to-end feature/change/fix propagation and completion gate |
99
+ | `sdd-requirements` | Six controlled EARS forms and measurable constitution |
100
+ | `sdd-design` | Explicit responsibilities/interfaces/constraints, ADRs, diagrams |
101
+ | `sdd-implementation` | Native editing with requirement-linked code and tests |
102
+ | `sdd-traceability` | Generated coverage, dangling links, bidirectional impact |
103
+ | `sdd-quality` | Actual verification commands, policy, readiness evidence |
104
+ | `sdd-knowledge` | Local artifact/Git retrieval, not conversational memory |
105
+ | `sdd-formal-codegraph` | Optional consistency checks, compiler graph, architecture |
106
+
107
+ Use **native Copilot** for planning, editing, research, review, security review,
108
+ memory, code navigation/LSP, MCP management, and subagent/fleet/task coordination.
109
+ musubix3 does not implement those services, generic code/test generation,
110
+ orchestration, a scheduler, MCP server, Claude support, an interactive REPL, or a
111
+ resident watcher. `status`, `query`, `impact` and `--changed` provide one-shot value.
112
+ Skills may combine neural proposals from Copilot with symbolic checks; there is
113
+ no separate “neurosymbolic AI” model or claims of learned verification.
114
+
115
+ ## Workflow
116
+
117
+ For normal feature additions, behavior changes and bug fixes, use `sdd-change`.
118
+ It coordinates the complete workflow below and refuses to call an
119
+ implementation-only change complete while required artifacts remain stale.
120
+
121
+ 1. Use native planning/research to establish intent and measurable acceptance.
122
+ 2. Record `change-record CHANGE-ID impact`, then edit/validate requirements and
123
+ record the `requirements` checkpoint.
124
+ 3. Design explicit components, record trade-offs in ADRs, then record `design`.
125
+ 4. Write an annotated behavior test, record a structured failing `tdd red`, then
126
+ record the change `red` checkpoint.
127
+ 5. Implement the minimum change, record `implementation`, run passing `tdd green`,
128
+ then record `green` and refactor.
129
+ 6. Add trace annotations, build graphs, inspect impact and fix missing coverage.
130
+ 7. Configure real checks, run `gate --changed`, use native review/security review,
131
+ and inspect status before release. Do not weaken policy simply to pass.
132
+
133
+ ```sh
134
+ npx musubix3 requirements validate .musubix/features/example/requirements.md --json
135
+ npx musubix3 constitution validate --json
136
+ npx musubix3 design validate .musubix/features/example/design.md --json
137
+ npx musubix3 design c4 .musubix/features/example/design.md
138
+ npx musubix3 change-record CHANGE-0001 design --requirement REQ-EXAMPLE-001
139
+ npx musubix3 tdd red TEST-EXAMPLE-001 --requirement REQ-EXAMPLE-001 --command test
140
+ # Implement the minimum behavior without changing the test.
141
+ npx musubix3 tdd green TEST-EXAMPLE-001 --requirement REQ-EXAMPLE-001 --command test
142
+ npx musubix3 tdd refactor TEST-EXAMPLE-001 --requirement REQ-EXAMPLE-001 --command test
143
+ npx musubix3 trace build
144
+ npx musubix3 trace check --strict --json
145
+ npx musubix3 graph index
146
+ npx musubix3 graph impact src/service.ts
147
+ npx musubix3 gate --changed --json
148
+ npx musubix3 status --json
149
+ ```
150
+
151
+ ## Command reference
152
+
153
+ All analysis commands accept `--root <directory>` and `--json`. Files resolve
154
+ relative to that root; access outside it is refused. `plugin-install` uses the
155
+ installed package root. Exit codes: **0** successful operation, **1** rejected
156
+ validation/gate or requested solver failure, **2** usage, I/O or malformed config.
157
+ `status` is informational (exit 0 even if not ready); inspect `gate.ready`.
158
+
159
+ | Command | Behavior |
160
+ |---|---|
161
+ | `init [--dry-run] [--force] [--feature slug]` | Preserve-first skills/artifacts installation; `install` alias |
162
+ | `plugin-install` | Invoke native Copilot installer (no internal config edits) |
163
+ | `requirements validate <file>` | IDs, priorities, declared/detected EARS pattern |
164
+ | `constitution validate [file]` | Versioned principles and measurable rule definitions |
165
+ | `design validate <file>` | Fields, global requirement IDs, existing ADR references |
166
+ | `design c4 <file>` | Mermaid component/dependency diagram from explicit fields |
167
+ | `trace build` | Generate global trace snapshot and feature copies |
168
+ | `trace check [--strict]` | Dangling IDs, stale inputs/paths, mandatory coverage |
169
+ | `trace impact <id-or-path>` | Bidirectional breadth-first traversal with explanation paths |
170
+ | `graph index [--changed]` | Compiler imports, declarations and best-effort call targets |
171
+ | `graph impact <symbol-or-path>` | Conservative reverse-import closure; `path#name` disambiguates |
172
+ | `graph cycles` | Strongly connected components; exit 1 when cycles exist |
173
+ | `graph gate` | Fresh index + architecture rule/cycle checks |
174
+ | `knowledge build` | Markdown and bounded Git evidence index |
175
+ | `knowledge query <text> [--limit 10]` | Deterministic TF-IDF/cosine results and staleness flag |
176
+ | `formal generate <file> [--format both\|smt2\|lean]` | Reproducible solver inputs with SHA-256 evidence |
177
+ | `formal doctor` | Probe Z3, Lean, and `lake env lean` availability and versions |
178
+ | `formal check <file> [--solver auto\|none\|z3\|lean]` | Check the explicit Boolean/conditional/numeric/temporal/transition model |
179
+ | `model-correspondence validate` | Revalidate Formal JSON → generated trace → authoritative passing test evidence |
180
+ | `mutation validate` | Revalidate requirement-scoped schema-v1 killed-mutant evidence |
181
+ | `tdd red\|green\|refactor <TEST-ID> --requirement <REQ-ID> --command <name>` | Execute and record a verified TDD phase |
182
+ | `workflow-record <skill> <phase> --status <status>` | Record a compact self-reported workflow declaration |
183
+ | `workflow-verify <copilot.jsonl> [--strict] [--session-id <uuid>]` | Reconcile Skill events; optionally require a complete successful session transcript |
184
+ | `attestation oidc-audience --key-id <id> [--public-key-file <pem>]` | Derive the GitHub custom audience that authorizes a signing key |
185
+ | `attestation payload --provider <name> --run-id <id> --key-id <id> [--public-key-file <pem>] [--github-oidc-token-file <jwt>]` | Emit canonical unsigned CI payload for external signing |
186
+ | `attestation verify` | Verify static-key or GitHub OIDC-authorized Ed25519 provenance |
187
+ | `change-record <CHANGE-ID> <phase> --requirement <REQ-ID...>` | Record ordered artifact/TDD fingerprints for a staged change |
188
+ | `gate [--changed]` | Fresh full checks plus actual configured commands; persist evidence |
189
+ | `status` | Artifact counts and readiness/staleness summary |
190
+
191
+ `--changed` reads staged, unstaged, untracked and renamed/deleted paths from Git.
192
+ It reports affected files but **conservatively recomputes all deterministic checks
193
+ and executes all configured commands**. This avoids unsafe incremental skips.
194
+ There is no daemon, polling loop or background service.
195
+ Workflow evidence automatically requires `workflow`. TDD evidence automatically
196
+ requires `tdd`; a `.musubix/changes/CHANGE-*.md` document additionally requires
197
+ `tdd`, `change-history`, and `change-completeness`, even when omitted from
198
+ `requiredChecks`.
199
+
200
+ ## Artifact schema (v1)
201
+
202
+ ```text
203
+ .github/skills/sdd-*/SKILL.md
204
+ .musubix/
205
+ config.json
206
+ constitution.md
207
+ features/<slug>/
208
+ requirements.md
209
+ design.md
210
+ trace.json # generated; never hand-edit
211
+ decisions/ADR-0001.md
212
+ evidence/
213
+ quality.json # actual gate report, initially skipped
214
+ workflow.json # declarations plus optional strict transcript/session evidence
215
+ tdd.json # append-only phase hash chain and TDD cycles
216
+ changes.json # staged change checkpoints
217
+ order.json # shared monotonic TDD/change chronology ledger
218
+ performance.json # deterministic operation-budget observations
219
+ model-correspondence.json # Formal model → trace → fresh passing test proof
220
+ mutation.json # fresh requirement-scoped mutation executions
221
+ attestation.json # optional externally signed CI provenance
222
+ cache/ # ignored; generated indexes and solver inputs
223
+ ```
224
+
225
+ ### Requirements and design
226
+
227
+ ```markdown
228
+ ---
229
+ schemaVersion: 1
230
+ feature: auth
231
+ ---
232
+ ## REQ-AUTH-001: Reject expired sessions
233
+ Priority: must
234
+ Type: functional
235
+ Pattern: event-driven
236
+ Statement: When a session expires, the system shall reject the request.
237
+ Acceptance: An expired-session request produces HTTP 401.
238
+ Formal: {"kind":"conditional","condition":"session.expired","consequence":"request.rejected"}
239
+
240
+ ## DES-AUTH-001: Session guard
241
+ Responsibilities: Reject requests whose session has expired.
242
+ Interfaces: guard(request) returns a principal or HTTP 401.
243
+ Constraints: Do not log session tokens.
244
+ Requirements: REQ-AUTH-001
245
+ ADRs: ADR-0001
246
+ Depends-On: DES-AUTH-002
247
+ ```
248
+
249
+ Put these entries in their respective `requirements.md` / `design.md`; declare
250
+ every dependency as another component. Each requirement has one controlled
251
+ statement. Accepted priorities are `must` (default), `should`, `may`.
252
+ Requirement types are `functional` (default) and `non-functional`.
253
+ `Formal:` is optional strict single-line JSON. Supported kinds are `conditional`,
254
+ `numeric` (integer comparison), `temporal` (`withinMs` plus optional nonnegative
255
+ `afterMs`), and `transition` (`from`/`event`/`to`). Numeric units `ms`/`s`/`min`
256
+ share an exact duration dimension, while `bytes`/`kib`/`mib` share an exact size
257
+ dimension. Other units and incompatible dimensions remain separate. It models
258
+ only the declared fields. A non-functional
259
+ requirement may also declare
260
+ `Performance: {"counter":"visitedNodes","max":100,"testId":"TEST-AUTH-002"}`;
261
+ the named passing test must report that integer operation counter.
262
+ IDs use uppercase `REQ-`, `DES-`, `CODE-`, `TEST-`, a feature prefix, and ≥3 digits.
263
+ ADRs use `ADR-` plus ≥4 digits. IDs must be globally unique.
264
+
265
+ Six EARS patterns: “The system shall …”; “When …, the system shall …”;
266
+ “While …, …”; “If …, then …”; “Where …, …”; combined distinct
267
+ Where/While/When clauses. Japanese controlled forms are documented in
268
+ [README-ja.md](README-ja.md). These are syntax checks, not natural-language
269
+ understanding; arbitrary prose is deliberately rejected.
270
+
271
+ Source/test trace annotations are read from comments in JS/TS, Rust, Python, Go,
272
+ Java/Kotlin, C/C++, C#, Ruby, PHP and Swift. JS/TS parsing excludes string
273
+ literals; other languages require line or block comments:
274
+
275
+ ```ts
276
+ /** @id CODE-AUTH-001
277
+ * @implements REQ-AUTH-001
278
+ * @design DES-AUTH-001
279
+ */
280
+ export function guard() { /* actual implementation */ }
281
+
282
+ /** @id TEST-AUTH-001
283
+ * @verifies REQ-AUTH-001
284
+ */
285
+ // Real behavior test follows.
286
+ ```
287
+
288
+ One block comment per entity; comma/space-separated targets. `@design` is optional.
289
+ Mandatory implementation coverage may be direct or through a linked design;
290
+ tests must directly verify a requirement. Links alone are not semantic proof.
291
+ Each feature's `trace.json` holds the complete repository snapshot, including
292
+ cross-feature edges and input SHA-256 fingerprints; copies intentionally agree.
293
+ The cache is preferred when present; feature snapshots support cache-free checks.
294
+ Rebuild when inputs change; stale impact queries are rejected.
295
+
296
+ ### Constitution and configuration
297
+
298
+ ```markdown
299
+ ---
300
+ version: 1.0.0
301
+ ---
302
+ ## PRINC-001: Evidence first
303
+ ### RULE-001: No missing trace coverage
304
+ Metric: trace.errors
305
+ Limit: 0
306
+ ```
307
+
308
+ Supported metrics are `requirements.errors`, `design.errors`, `trace.errors`,
309
+ `graph.violations`, `formal.errors`, `formal.modeledFraction`,
310
+ `tests.annotatedIds`, `tests.executedIds`, `commands.failures` and
311
+ `commands.skipped`. Every rule declares a nonnegative numeric upper bound.
312
+ `constitution validate` checks the definition; only `gate` measures it.
313
+ Unavailable evidence is skipped, never a measured zero.
314
+
315
+ Example `.musubix/config.json` (adapt command arguments to your own project):
316
+
317
+ ```json
318
+ {
319
+ "schemaVersion": 1,
320
+ "language": "auto",
321
+ "commands": [
322
+ { "name": "typecheck", "command": "npm", "args": ["run", "typecheck"], "required": true, "timeoutMs": 120000 },
323
+ {
324
+ "name": "test",
325
+ "command": "npm",
326
+ "args": ["test", "--"],
327
+ "adapter": "vitest",
328
+ "required": true,
329
+ "timeoutMs": 120000
330
+ }
331
+ ],
332
+ "requiredChecks": ["requirements", "design", "constitution", "trace", "graph", "commands"],
333
+ "thresholds": { "design": 1, "implementation": 1, "tests": 1 },
334
+ "formal": { "solver": "none", "minModeledFraction": 0, "timeoutMs": 12000 },
335
+ "mutation": { "mode": "compatible" },
336
+ "workflow": {
337
+ "mode": "compatible",
338
+ "maxAgeSeconds": 3600,
339
+ "maxFutureSkewSeconds": 60
340
+ },
341
+ "attestation": {
342
+ "mode": "local",
343
+ "maxAgeSeconds": 3600,
344
+ "maxFutureSkewSeconds": 60,
345
+ "trustedPublicKeys": [],
346
+ "githubOidc": { "mode": "off" }
347
+ },
348
+ "codeGraph": { "mode": "compatible" },
349
+ "architecture": {
350
+ "forbidCycles": true,
351
+ "rules": [
352
+ { "name": "domain-isolation", "from": "src/domain/**", "disallow": ["src/ui/**", "npm:express"] }
353
+ ]
354
+ }
355
+ }
356
+ ```
357
+
358
+ Config is validated strictly; misspelled keys, invalid bounds and duplicate
359
+ commands fail closed. Globs support `*`, `**`, `?`; external imports use `npm:`.
360
+ `codeGraph.mode` defaults to `compatible`, where unresolved computed
361
+ `import()`/`require()` calls remain warnings. Set it to `strict` to make those
362
+ diagnostics gate-blocking errors. A trusted strict policy baseline prevents
363
+ downgrading the project back to compatible mode.
364
+ Coverage bounds are fractions [0,1] of mandatory requirements. Bare `trace check
365
+ --strict` always requires full coverage; the aggregate gate uses config thresholds.
366
+ The reported value is **link coverage**, not proof; with zero mandatory
367
+ requirements it is `null` (not applicable). Add `test-identities` to
368
+ `requiredChecks` to require every annotated `TEST-*` ID to be reported `passed`
369
+ by a fresh structured report from a successful configured command.
370
+ Add `formal` to enforce the configured solver and minimum modeled fraction.
371
+ Every requirement containing explicit `Formal:` JSON automatically requires
372
+ `model-correspondence`: its current formal constraint and generated trace must
373
+ lead to at least one authoritative `TEST-*` that passed in a fresh structured
374
+ command report. Missing, changed, unlinked, or stale evidence fails closed.
375
+ Add `tdd` to require complete Red-Green cycles. Red must be an observed nonzero
376
+ test result; Green/Refactor must pass with the same configured command and
377
+ unchanged test file. Test names/output must contain their `TEST-*` ID.
378
+ `language` records project preference; skills follow input language. Machine
379
+ diagnostic codes are stable English; human status labels include Japanese.
380
+
381
+ `.musubix/policy-baseline.json` records minimum required checks, coverage,
382
+ architecture, formal policy, mutation mode, workflow strict/session/freshness settings,
383
+ CI-required attestation and strict OIDC identity/key binding, and required
384
+ command names. Weakening is rejected; changing the baseline in `gate --changed`
385
+ requires independent approval. Protect the baseline with review/CODEOWNERS.
386
+
387
+ **Only run trusted configuration**: gates execute its commands with inherited
388
+ environment, no shell interpretation and bounded time/output. Required command
389
+ failure or skip blocks readiness regardless of `requiredChecks.commands`.
390
+ Optional command failures are nonblocking unless a constitution rule rejects the
391
+ measured count. No configured commands is skipped, not passed.
392
+ TDD commands require either command-specific `tddArgs` plus a `tddReport`, or a
393
+ built-in `vitest`, `jest`, `pytest`, `go-test`, `cargo`, or `junit` adapter.
394
+ Explicit custom configuration takes precedence. Adapters derive targeted
395
+ arguments and normalize native JSON/JSONL/XML into `musubix-json`. Vitest/Jest
396
+ reports may contain unrelated skipped tests; targeted TDD selects only the
397
+ requested ID. pytest requires the JSON-report plugin and underscore-form test
398
+ names such as `test_TEST_APP_001`. Go uses a `TEST-*` subtest name, Cargo uses a
399
+ Rust identifier such as `test_app_001`. JUnit methods must carry an exact
400
+ `@Tag("TEST-APP-001")`; keep the underscore-form ID in the method name so it is
401
+ recoverable from the launcher's XML report. Before each phase, musubix3 deletes
402
+ the previous report, creates any required report parent directory, and requires a fresh
403
+ `musubix-json` document containing exactly the selected test. Its status must be
404
+ `failed` during Red and `passed` during Green/Refactor; `skipped`, `error`,
405
+ missing and malformed reports fail. A non-test project input must change before
406
+ Green. Identical phase output reused by different tests is rejected.
407
+ Every phase is also appended to a SHA-256-linked immutable record chain. TDD and
408
+ change checkpoints additionally share a persisted monotonic order ledger, which
409
+ is authoritative for Red/Green boundaries; wall-clock timestamps are
410
+ informational. Legacy chronology without order evidence fails with an explicit
411
+ migration diagnostic. Missing, reordered, altered or orphaned records invalidate
412
+ the evidence.
413
+
414
+ CI executes isolated native contracts for all six adapters: Vitest, Jest,
415
+ pytest with `pytest-json-report`, Go test, Cargo test, and the pinned JUnit
416
+ Platform Console. Each fixture contains an unrelated failing test, proving that
417
+ the generated selector executes only the requested identity and that the real
418
+ native report normalizes correctly. Jest is development-only; the Python,
419
+ Go/Rust, and Java/JUnit tooling is provisioned only in CI and is not shipped as
420
+ a package runtime dependency.
421
+
422
+ Change checkpoints fingerprint only implementation files linked to each changed
423
+ requirement, plus their Code Graph dependencies. An unrelated source change
424
+ cannot satisfy the implementation phase. The automatic `change-completeness`
425
+ gate checks each CHANGE-ID for classified functional/non-functional requirements,
426
+ measurable Acceptance criteria, concrete design responsibilities/interfaces/
427
+ constraints, an existing ADR, linked code, authoritative annotated tests,
428
+ bounded TDD and trace edges. Each CHANGE document must contain a `Requirements:`
429
+ line enumerating exactly the chronology's normative requirement IDs.
430
+
431
+ Structured test results may add
432
+ `"operations":{"visitedNodes":42}`. A declared deterministic performance budget
433
+ automatically requires the `performance` gate; elapsed time alone cannot satisfy it.
434
+ For every observation, `performance.json` records a gate-generated run identity
435
+ and SHA-256-linked provenance covering the configured command name, executable
436
+ and rendered arguments, report path/source, fresh report bytes, test ID/status,
437
+ counter/value, and process status/exit code. Validation re-reads persisted
438
+ file, directory, and captured stdout reports and rejects missing or altered
439
+ reports, record mutation, configuration drift, duplicate counter sources,
440
+ non-passing tests, and results not produced by a successful configured command.
441
+ The signed performance head hashes stable semantic fields while the JSON retains
442
+ run/execution IDs, timestamps, report hashes, and chained provenance, so an
443
+ equivalent gate can be rerun after signing without invalidating the signature.
444
+ This provenance also gates CHANGE completeness and status freshness.
445
+ Native runner reports do not expose application operation counters, so projects
446
+ with such budgets must also configure an instrumented `musubix-json` report.
447
+ Native adapters and custom reports can coexist; only the instrumented report that
448
+ actually emits the named operation counter can prove the performance budget.
449
+
450
+ Mutation evidence uses a configured command with
451
+ `"mutationReport":{"format":"musubix-mutation-json","path":"..."}`. Each fresh
452
+ schema-v1 mutant record carries a deterministic `MUT-<hash>` identity (derivable
453
+ with the exported `mutationIdentity` helper), must-functional requirement ID,
454
+ authoritative test ID, source/test paths and SHA-256 fingerprints, operator,
455
+ one-based line/column, and `killed|survived|skipped|error` status. The gate adds
456
+ command, rendered-argument, report, process, and exit provenance to
457
+ `mutation.json`. Supplied evidence must cover every must functional requirement
458
+ with a current linked killed mutant. Duplicate/conflicting, non-killed, stale,
459
+ unlinked, altered-report, and configuration-drift evidence is rejected.
460
+ `mutation.mode` defaults to `compatible` (absence is allowed); set it to
461
+ `strict` and protect it plus the mutation command in the policy baseline for
462
+ release. No mutation engine dependency is bundled. Mutation and model-
463
+ correspondence semantic heads are included in attestations and their underlying
464
+ provenance is revalidated.
465
+
466
+ Quality evidence records required flags, actual exits/output, metrics,
467
+ timestamps and input fingerprints. Changed-run paths, HEAD and impacts survive a
468
+ later full gate. `workflow-record` stores a self-reported Skill/phase/status and
469
+ optional command SHA-256 without storing command text. `workflow-verify` imports
470
+ only Skill invocation metadata from a Copilot JSONL log and binds every completed
471
+ declaration one-to-one, in order, to a distinct completed successful tool call.
472
+ Each Skill invocation must therefore record exactly one final workflow outcome;
473
+ multi-phase chronology belongs in `change-record`, not duplicate workflow events.
474
+ Incomplete, failed, reused, out-of-order and stale bindings fail.
475
+ Set `"workflow":{"mode":"strict"}` or pass `--strict` to additionally require
476
+ valid JSON on every nonempty line, valid event timestamps, consistent one-to-one
477
+ tool start/completion lifecycles, and exactly one final `result` with `exitCode: 0`.
478
+ The terminal `sessionId`, exit code, event count, terminal timestamp, raw source
479
+ hash and canonical transcript hash are persisted. `workflow.expectedSessionId`
480
+ or `--session-id` rejects substitution with a different caller-declared session.
481
+ Strict verification also bounds terminal transcript age and future clock skew
482
+ with `workflow.maxAgeSeconds` and `workflow.maxFutureSkewSeconds`.
483
+ Unrelated concurrent events may be emitted out of timestamp order, so strict mode
484
+ checks causal tool/result ordering rather than imposing a global timestamp sort.
485
+ Changes during a gate fail input stability; later source/config changes make
486
+ `status` stale. Attestations older than `maxAgeSeconds`, or issued farther in the
487
+ future than `maxFutureSkewSeconds`, fail. Local mode explicitly reports unsigned
488
+ evidence.
489
+
490
+ `ci-required` supports two deliberately distinct trust models:
491
+
492
+ - **Static trusted-key mode** (`githubOidc.mode: "off"`): `keyId` must select a
493
+ configured Ed25519 public key. The signature covers repository, Git HEAD, CI
494
+ provider/run ID, evidence heads, and the non-generated workspace snapshot.
495
+ - **GitHub OIDC strict mode**: configure `githubOidc.mode: "strict"` and a custom
496
+ audience base. The verifier discovers GitHub's issuer metadata and JWKS,
497
+ verifies the RS256 JWT, and checks issuer, bound audience, `exp`/`nbf`/`iat`,
498
+ repository, commit `sha`, and `run_id`, plus optional `workflow` and `ref`.
499
+ `keyBinding: "public-key"` authorizes an attestation-carried ephemeral
500
+ Ed25519 public key by its SPKI SHA-256 in the custom audience.
501
+ `keyBinding: "key-id"` instead adds OIDC authorization to a statically trusted
502
+ key ID. If metadata/JWKS cannot be fetched, strict verification fails closed.
503
+
504
+ Evidence heads also bind stable non-attestation quality verdicts and formal
505
+ solver status, total requirements, modeled count/fraction, consistency, and
506
+ artifact identity. Excluding the attestation check from the quality head avoids
507
+ a circular signature dependency. A missing `ci-required` attestation is reported
508
+ as a failed/missing check, never as skipped local evidence.
509
+
510
+ Example strict configuration:
511
+
512
+ ```json
513
+ {
514
+ "attestation": {
515
+ "mode": "ci-required",
516
+ "repository": "owner/repository",
517
+ "maxAgeSeconds": 600,
518
+ "maxFutureSkewSeconds": 30,
519
+ "trustedPublicKeys": [],
520
+ "githubOidc": {
521
+ "mode": "strict",
522
+ "audience": "https://example.invalid/musubix3",
523
+ "keyBinding": "public-key",
524
+ "workflow": "release.yml",
525
+ "ref": "refs/heads/main"
526
+ }
527
+ }
528
+ }
529
+ ```
530
+
531
+ Generate an Ed25519 key outside musubix3, pass only its public PEM to
532
+ `attestation oidc-audience`, request the GitHub Actions OIDC token with that exact
533
+ audience, then pass the public PEM and JWT files to `attestation payload` and sign
534
+ the emitted payload externally. musubix3 never reads or stores a private key.
535
+ The short-lived JWT is included in the signed attestation and is intentionally
536
+ checked for current expiration, so verification must occur within its validity
537
+ window. This establishes that GitHub's OIDC identity authorized the signing key
538
+ and stated claims; it does not prove arbitrary runner behavior or the semantic
539
+ correctness of the workflow. The workflow evidence head separately binds
540
+ transcript/session fields into the Ed25519 signature.
541
+
542
+ ## Formal methods, codegraph and retrieval limitations
543
+
544
+ - Deterministic formal checking works without external solvers. Controlled
545
+ unconditional English/Japanese obligations retain the Boolean abstraction;
546
+ strict `Formal:` JSON additionally models branch-scoped conditional truth,
547
+ exact integer bounds with documented compatible units, intersected
548
+ `afterMs`/`withinMs` response-delay intervals, and deterministic
549
+ from-state/event targets. Arbitrary natural language, synonyms, scheduling,
550
+ liveness, undocumented unit conversions, domain axioms and implementation
551
+ behavior are not proven.
552
+ - `consistent` means the **modeled subset** is consistent; inspect `unsupported`.
553
+ An empty subset reports `unknown` and exits nonzero. `valid` only indicates a
554
+ nonempty modeled subset with no detected violation or requested execution error,
555
+ **not** comprehensive proof. `none` skips solver
556
+ execution; `auto` probes installed Z3 then Lean and tolerates missing tools.
557
+ Explicit missing Z3/Lean, unknown, timeout or tool error returns nonzero.
558
+ - `formal generate` writes reproducible SMT-LIB2 and Lean inputs with SHA-256
559
+ metadata without requiring either tool. `formal doctor` reports executable,
560
+ version, timeout, missing and error states.
561
+ - Z3 receives actual QF_UFLIA SMT-LIB with named assertions and `check-sat`.
562
+ Lean checks satisfiability or contradiction theorems over translated Boolean,
563
+ integer, temporal, conditional-scenario and transition propositions. It is
564
+ **not** a general SMT solver or proof of
565
+ application correctness. `auto` also detects `lake env lean`. Use `--z3-command`,
566
+ `--lean-command`, `MUSUBIX3_Z3`, or `MUSUBIX3_LEAN` for nonstandard paths.
567
+ Generated inputs stay in the ignored cache.
568
+ - CI pins Lean through `lean-toolchain` and runs both native Z3 and Lean
569
+ integrations, including consistent and inconsistent mixed models. Generated
570
+ Lean satisfiability proofs provide explicit witnesses rather than searching
571
+ Boolean assignments. Local installations may use another compatible version, but
572
+ their exact version is retained in each solver report.
573
+ - The JS/TS compiler graph handles imports, re-exports, import-equals, literal
574
+ `require`/dynamic imports, package manifest entrypoints, safe local URL/template
575
+ cache-busting imports, and nearest `tsconfig.json` resolution. Calls are
576
+ best-effort; symbol impact conservatively expands at **file** level. Nonliteral
577
+ loading is a compatibility warning unless `codeGraph.mode` is `strict`, when
578
+ it blocks graph gates; unresolved external packages remain warnings and
579
+ unresolved local imports are errors. Bundler-specific resolution, reflection and other
580
+ Rust, Python, Go, Java, C/C++, C#, PHP, R and Julia have conservative native
581
+ adapters for local imports/modules/includes, declarations and direct calls.
582
+ Other languages are reported as unsupported. Ignored
583
+ build/cache/dependency directories and
584
+ symlinks are not indexed; custom `.gitignore` rules are not a scan filter.
585
+ - Trace annotations support all languages listed above. Do not create JS/TS
586
+ proxy files for another language.
587
+ - Knowledge ranking is **TF-IDF/cosine, not GraphRAG** or semantic reasoning.
588
+ Japanese uses character bigrams. Git co-change and author-directory counts
589
+ cover at most 100 commits/30 files per commit; they indicate correlation and
590
+ contribution, not causality or expertise. No Git history is explicitly skipped.
591
+ Indexing is local; nothing is sent to a service.
592
+ - Core CI covers Node 22 on Linux, Windows, and macOS, with additional Node 20
593
+ and Node 24 Linux compatibility checks. Native adapters and formal solvers run
594
+ once on Linux with pinned toolchains.
595
+ No formatting/lint framework is bundled; strict TypeScript and tests are used.
596
+
597
+ ## Development and release checks
598
+
599
+ ```sh
600
+ npm install
601
+ npm run typecheck
602
+ npm run build
603
+ npm test
604
+ npm pack --dry-run
605
+ npm run pack:check
606
+ npm run pack:smoke
607
+ ```
608
+
609
+ Workspaces: `packages/domain` (pure validators), `packages/analysis` (evidence,
610
+ compiler and filesystem services), `packages/cli` (thin command/installation layer).
611
+ One build emits `dist/packages/**`. Published contents explicitly include hidden
612
+ skills, native manifests, built CLI/modules and assets. CI checks Node 20/24;
613
+ tests cover unit behavior, CLI exits, installer preservation and packaging.
614
+ `pack:smoke` installs the real tarball into an isolated `.test-work/` consumer,
615
+ checks its executable, ESM exports and installer, then removes the fixture.
616
+ Attestation APIs are available from both `musubix3/analysis` and the focused
617
+ `musubix3/attestation` export.
618
+
619
+ Tags matching `v*` run `.github/workflows/release.yml`. The workflow requires
620
+ the tag to equal `v` plus the package/plugin versions, runs the full Linux
621
+ native/formal suite, creates the npm tarball, CycloneDX `npm sbom`, SHA256SUMS,
622
+ and a GitHub Release. A separate protected `npm-publish` environment gates
623
+ `npm publish --provenance --access public`; npm Trusted Publishing is preferred,
624
+ while an optional `NPM_TOKEN` environment secret remains supported. A pending or
625
+ failed npm publish does not prevent creation of the GitHub Release.
626
+ For manual dispatch, select the release tag as the workflow ref and provide the
627
+ same value as `release_tag`; the workflow rejects tags that do not point to the
628
+ OIDC-bound `GITHUB_SHA`.
629
+
630
+ The release attestation uses a real GitHub Actions OIDC token whose custom
631
+ audience binds an ephemeral Ed25519 public key. Its signature covers repository,
632
+ Git commit, run ID, workflow/ref identity, current workspace snapshot, and any
633
+ musubix evidence heads present in the release runner. It verifies those bindings
634
+ and GitHub's live issuer/JWKS before upload; it does not claim that the signature
635
+ alone proves test semantics. Tests and solver checks are enforced separately by
636
+ the prerequisite release-validation job. The private key exists only under the
637
+ ignored `.test-work` directory for signing and is deleted before verification;
638
+ only the signed attestation is uploaded.
639
+ See [CONTRIBUTING.md](CONTRIBUTING.md) and [CHANGELOG.md](CHANGELOG.md).
@@ -0,0 +1,15 @@
1
+ ---
2
+ status: accepted
3
+ ---
4
+ # ADR-0001: Copilot-native specification development
5
+
6
+ ## Context / 背景
7
+ Use musubix3 only for deterministic specification artifacts and evidence.
8
+
9
+ ## Decision / 決定
10
+ Delegate planning, editing, research, reviews, security review, memory and subagents
11
+ to GitHub Copilot CLI. Do not introduce parallel agent runtimes.
12
+
13
+ ## Consequences / 結果
14
+ Maintain explicit requirement/design/code/test IDs. Configure real verification
15
+ commands. Formal consistency is never proof of implementation correctness.
@@ -0,0 +1,17 @@
1
+ ---
2
+ version: 1.0.0
3
+ ---
4
+ # Project constitution / プロジェクト憲章
5
+
6
+ ## PRINC-001: Evidence before claims / 主張には根拠を
7
+ ### RULE-001: Trace mandatory requirements / 必須要求を追跡する
8
+ Metric: trace.errors
9
+ Limit: 0
10
+
11
+ ## PRINC-002: Run real checks / 実際に検証する
12
+ ### RULE-002: No failed verification commands / 検証失敗を許可しない
13
+ Metric: commands.failures
14
+ Limit: 0
15
+ ### RULE-003: Do not pass skipped checks / 未実行を成功扱いしない
16
+ Metric: commands.skipped
17
+ Limit: 0