phasegate 0.229.0 → 0.254.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/CHANGELOG.md +51 -1
- package/README.ja.md +28 -1
- package/README.md +27 -0
- package/docs/ADR/031-world-model-ownership-and-corpus-lifecycle.md +155 -0
- package/docs/ADR/032-world-node-identity.md +198 -0
- package/docs/ADR/033-world-snapshot-canonicalization.md +246 -0
- package/docs/ADR/034-world-constraint-semantics.md +218 -0
- package/docs/ADR/035-world-adoption-baseline-and-waiver.md +341 -0
- package/docs/ADR/036-world-model-and-doc-freshness.md +169 -0
- package/docs/ADR/037-world-cli-and-output-contract.md +398 -0
- package/docs/contracts/requirement-test-matrix.schema.json +15 -0
- package/docs/contracts/world-baseline.schema.json +35 -0
- package/docs/contracts/world-constraints.schema.json +56 -0
- package/docs/contracts/world-debts.schema.json +32 -0
- package/docs/contracts/world-obligation-report.schema.json +259 -0
- package/docs/contracts/world-waivers.schema.json +32 -0
- package/docs/guide/cli-reference.md +34 -0
- package/package.json +1 -1
- package/scripts/harness/attestation/application/ports/sha256-capability.ts +25 -0
- package/scripts/harness/attestation/composition-root.ts +14 -4
- package/scripts/harness/attestation/index.ts +6 -1
- package/scripts/harness/attestation/infrastructure/adapters/node-crypto-content-hasher-adapter.ts +6 -6
- package/scripts/harness/attestation/infrastructure/adapters/node-crypto-sha256-capability.ts +19 -0
- package/scripts/harness/harness-api/domain/value-objects/known-harness-commands.ts +4 -1
- package/scripts/harness/main.ts +107 -1
- package/scripts/harness/nyquist-validation/application/dto/generate-matrix-output.ts +11 -0
- package/scripts/harness/nyquist-validation/application/usecases/check-ac-coverage-gate-usecase.ts +6 -0
- package/scripts/harness/nyquist-validation/application/usecases/generate-requirement-test-matrix-usecase.ts +8 -4
- package/scripts/harness/nyquist-validation/domain/entities/story-mapping.ts +29 -2
- package/scripts/harness/nyquist-validation/domain/services/ac-coverage-gate-policy.ts +28 -0
- package/scripts/harness/nyquist-validation/infrastructure/adapters/markdown-requirement-source-adapter.ts +71 -4
- package/scripts/harness/nyquist-validation/infrastructure/schema/matrix-schema-loader.ts +4 -0
- package/scripts/harness/traceability-model/application/dto/traceability-world-read-dto.ts +67 -0
- package/scripts/harness/traceability-model/application/facades/traceability-world-read-facade.ts +372 -0
- package/scripts/harness/traceability-model/application/ports/traceability-world-read-source-port.ts +61 -0
- package/scripts/harness/traceability-model/composition-root.ts +21 -5
- package/scripts/harness/traceability-model/index.ts +17 -6
- package/scripts/harness/traceability-model/infrastructure/adapters/file-system-traceability-world-read-adapter.ts +223 -0
- package/scripts/harness/traceability-model/infrastructure/parsers/story-catalog-parser.ts +86 -8
- package/scripts/harness/world-model/application/dto/world-inspection-dto.ts +43 -0
- package/scripts/harness/world-model/application/dto/world-obligation-report-dto.ts +54 -0
- package/scripts/harness/world-model/application/dto/world-resolved-config-input.ts +62 -0
- package/scripts/harness/world-model/application/ports/obligation-report-writer-port.ts +7 -0
- package/scripts/harness/world-model/application/ports/world-control-declaration-repository-port.ts +57 -0
- package/scripts/harness/world-model/application/ports/world-fact-source-port.ts +17 -0
- package/scripts/harness/world-model/application/usecases/build-snapshot-use-case.ts +111 -0
- package/scripts/harness/world-model/application/usecases/derive-obligations-use-case.ts +155 -0
- package/scripts/harness/world-model/application/usecases/derive-world-obligations-use-case.ts +144 -0
- package/scripts/harness/world-model/application/usecases/inspect-world-use-case.ts +74 -0
- package/scripts/harness/world-model/application/usecases/pin-constraint-endpoint-use-case.ts +139 -0
- package/scripts/harness/world-model/composition-root.ts +218 -0
- package/scripts/harness/world-model/domain/entities/constraint-record.ts +148 -0
- package/scripts/harness/world-model/domain/entities/control-declarations.ts +274 -0
- package/scripts/harness/world-model/domain/entities/edge.ts +41 -0
- package/scripts/harness/world-model/domain/entities/extraction-diagnostic.ts +60 -0
- package/scripts/harness/world-model/domain/entities/snapshot.ts +75 -0
- package/scripts/harness/world-model/domain/entities/world-node.ts +210 -0
- package/scripts/harness/world-model/domain/ports/world-hashing-port.ts +8 -0
- package/scripts/harness/world-model/domain/services/canonical-json-serializer.ts +113 -0
- package/scripts/harness/world-model/domain/services/constraint-evaluator.ts +486 -0
- package/scripts/harness/world-model/domain/services/obligation-derivation-service.ts +199 -0
- package/scripts/harness/world-model/domain/services/policy-inputs-digest-deriver.ts +66 -0
- package/scripts/harness/world-model/domain/services/snapshot-root-deriver.ts +218 -0
- package/scripts/harness/world-model/domain/services/text-content-normalizer.ts +30 -0
- package/scripts/harness/world-model/domain/services/violation-fingerprint-deriver.ts +183 -0
- package/scripts/harness/world-model/domain/value-objects/artifact-kind.ts +58 -0
- package/scripts/harness/world-model/domain/value-objects/change-provenance.ts +137 -0
- package/scripts/harness/world-model/domain/value-objects/corpus-role.ts +57 -0
- package/scripts/harness/world-model/domain/value-objects/declared-key.ts +35 -0
- package/scripts/harness/world-model/domain/value-objects/evaluation-id.ts +41 -0
- package/scripts/harness/world-model/domain/value-objects/explicit-constraint-relation.ts +53 -0
- package/scripts/harness/world-model/domain/value-objects/explicit-node-alias.ts +30 -0
- package/scripts/harness/world-model/domain/value-objects/node-pin.ts +34 -0
- package/scripts/harness/world-model/domain/value-objects/path-key.ts +103 -0
- package/scripts/harness/world-model/domain/value-objects/sha256-digest.ts +39 -0
- package/scripts/harness/world-model/domain/value-objects/violation-fingerprint.ts +36 -0
- package/scripts/harness/world-model/domain/value-objects/wcr-rule-id.ts +59 -0
- package/scripts/harness/world-model/domain/value-objects/world-node-id.ts +222 -0
- package/scripts/harness/world-model/index.ts +22 -0
- package/scripts/harness/world-model/infrastructure/adapters/adr-fact-extractor.ts +27 -0
- package/scripts/harness/world-model/infrastructure/adapters/assembled-world-fact-source.ts +17 -0
- package/scripts/harness/world-model/infrastructure/adapters/attestation-fact-extractor.ts +288 -0
- package/scripts/harness/world-model/infrastructure/adapters/attestation-sha256-world-hashing-adapter.ts +15 -0
- package/scripts/harness/world-model/infrastructure/adapters/composite-design-fact-source.ts +23 -0
- package/scripts/harness/world-model/infrastructure/adapters/design-corpus-fact-extractor.ts +285 -0
- package/scripts/harness/world-model/infrastructure/adapters/design-fact-extraction.ts +63 -0
- package/scripts/harness/world-model/infrastructure/adapters/file-system-obligation-report-writer-adapter.ts +37 -0
- package/scripts/harness/world-model/infrastructure/adapters/file-system-world-control-repository-adapters.ts +330 -0
- package/scripts/harness/world-model/infrastructure/adapters/integrity-manifest-fact-extractor.ts +101 -0
- package/scripts/harness/world-model/infrastructure/adapters/json-fact-extractor-support.ts +151 -0
- package/scripts/harness/world-model/infrastructure/adapters/markdown-design-fact-extractor.ts +493 -0
- package/scripts/harness/world-model/infrastructure/adapters/matrix-fact-extractor.ts +283 -0
- package/scripts/harness/world-model/infrastructure/adapters/product-fact-extractor.ts +29 -0
- package/scripts/harness/world-model/infrastructure/adapters/proposal-fact-extractor.ts +29 -0
- package/scripts/harness/world-model/infrastructure/adapters/runtime-fact-extraction.ts +19 -0
- package/scripts/harness/world-model/infrastructure/adapters/source-metadata-fact-extractor.ts +22 -0
- package/scripts/harness/world-model/infrastructure/adapters/test-reference-source-fact-extractor.ts +22 -0
- package/scripts/harness/world-model/infrastructure/adapters/traceability-design-fact-adapter.ts +112 -0
- package/scripts/harness/world-model/infrastructure/adapters/traceability-world-read-facade-merger.ts +38 -0
- package/scripts/harness/world-model/infrastructure/adapters/type-script-source-fact-extractor.ts +236 -0
- package/scripts/harness/world-model/infrastructure/adapters/unit-fact-extractor.ts +71 -0
- package/scripts/harness/world-model/infrastructure/adapters/world-control-declaration-mapper.ts +383 -0
- package/scripts/harness/world-model/presentation/cli/world-command-support.ts +60 -0
- package/scripts/harness/world-model/presentation/cli/world-derive-command-handler.ts +105 -0
- package/scripts/harness/world-model/presentation/cli/world-inspect-command-handler.ts +194 -0
- package/scripts/harness/world-model/presentation/cli/world-pin-command-handler.ts +100 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
---
|
|
2
|
+
adr_id: "037"
|
|
3
|
+
title: "World CLI と output/persistence contract"
|
|
4
|
+
status: Proposed
|
|
5
|
+
date: 2026-07-16
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# World CLI と output/persistence contract
|
|
9
|
+
|
|
10
|
+
<!-- @work-item-id WI-284 -->
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
World Modelはread-only inventory、constraint pin更新、obligation導出という異なる副作用境界を持つ。command名、output、exit code、control file、generated reportを先に固定しないと、CLI実装ごとに暗黙writeや別schemaが生まれ、ADR-031のartifact lifecycleとADR-035の「report手編集は判定を変えない」が崩れる。
|
|
15
|
+
|
|
16
|
+
既存CLIは`main.ts`のtop-level `switch`と、sorted `KNOWN_HARNESS_COMMANDS`の集合一致をconformance testで強制する。capability namespaceには`phasegate:*`, `p2:*`, `ci:*`, `integrity:*`, `regression:*`があり、`p2:check-freshness`等は独立top-level commandである。validation commandは概ね0=pass、1=domain / gate failure、2=usage / config / execution failureを使い、`--json`をmachine-readable outputに使う。
|
|
17
|
+
|
|
18
|
+
既存generated artifactの配置は二系統ある。
|
|
19
|
+
|
|
20
|
+
- `.harness/requirement-test-matrix.json`, `.harness/attestation.json`, `.harness/lesson-artifacts/**`等、machine consumer向け再生成物は`.harness/`。
|
|
21
|
+
- phase / regression等のhuman reportはresolved `reporting.outputDir`または`reports/`。
|
|
22
|
+
|
|
23
|
+
`.gitignore`は`.harness/`と`reports/`の両方を除外する。World obligation reportはtooling / operator向けのmachine-readable derived cacheであり、review対象のcontrol inputではないため、matrix / attestation側の慣行に合わせる。
|
|
24
|
+
|
|
25
|
+
config-foundationは`phasegate.config.json`をAJV schemaで検証し、presetとsource documentをdeep mergeしたresolved configをconsumerへ渡す。schemaはtop-level `additionalProperties: false`である。root control fileには`phasegate.config.json`, `phasegate.integrity.json`という`phasegate.<capability>.json`慣行がある。
|
|
26
|
+
|
|
27
|
+
本ADRはADR-031〜036のcontractをCLI / persistenceへ写像し、Phase 0のWorld意思決定を完結させる。
|
|
28
|
+
|
|
29
|
+
## Decision
|
|
30
|
+
|
|
31
|
+
### 1. 三つの`world:*` top-level commandを固定する
|
|
32
|
+
|
|
33
|
+
次をcanonical public commandとする。
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
world:inspect
|
|
37
|
+
world:pin
|
|
38
|
+
world:derive
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`phasegate world inspect`のようなnested subcommandや`phasegate:world:*` aliasは作らない。既存colon namespaceと同様、実際の呼び出しは`phasegate world:inspect`等になる。
|
|
42
|
+
|
|
43
|
+
実装時は三commandを同じWIで次へ追加し、集合一致を保つ。
|
|
44
|
+
|
|
45
|
+
- `scripts/harness/main.ts` help / switch dispatch
|
|
46
|
+
- `scripts/harness/harness-api/domain/value-objects/known-harness-commands.ts`
|
|
47
|
+
- known-command conformance / help / E2E tests
|
|
48
|
+
|
|
49
|
+
#### `world:inspect`
|
|
50
|
+
|
|
51
|
+
corpusを読み取り、World snapshot、node / edge count、corpus role / artifact kind、extraction diagnostics、`corpusRoot`を表示するread-only command。
|
|
52
|
+
|
|
53
|
+
- control declarationやreportを書かない。
|
|
54
|
+
- explicit constraintがなくても実行できる。
|
|
55
|
+
- hard extraction diagnosticがなければexit 0。
|
|
56
|
+
- snapshotを生成できたがduplicate ID等のhard diagnosticがあればexit 1。
|
|
57
|
+
- config / schema / I/O / hashing failureでsnapshotを生成できなければexit 2。
|
|
58
|
+
|
|
59
|
+
#### `world:pin`
|
|
60
|
+
|
|
61
|
+
一意に解決したconstraint endpointのcurrent digestから、ConstraintRecord pin candidateを作るcommand。
|
|
62
|
+
|
|
63
|
+
- defaultはpreview-onlyで、candidate / diffをstdoutへ出す。
|
|
64
|
+
- `--apply`を明示した場合だけ`phasegate.world-constraints.json`をatomic updateする。
|
|
65
|
+
- missing / duplicate / ambiguous alias endpoint、malformed declarationではwriteせずexit 1。
|
|
66
|
+
- unknown schema、invalid config、I/O / hashing failureはexit 2。
|
|
67
|
+
- baseline、waiver、semantic debt、obligation reportを更新しない。
|
|
68
|
+
- Git add / commitやbaseline adoptionを自動実行しない。
|
|
69
|
+
|
|
70
|
+
`--apply`はreview対象external declarationへのmutationであり、`--write` report modeとは区別する。
|
|
71
|
+
|
|
72
|
+
#### `world:derive`
|
|
73
|
+
|
|
74
|
+
current snapshotとexternal declarationsからWCR evaluation、fingerprint、policy classification、obligation reportを再導出するcommand。
|
|
75
|
+
|
|
76
|
+
- defaultはpure/read-only。stdoutへ結果を出すだけでfilesystemを変更しない。
|
|
77
|
+
- `--write`を明示した場合だけraw obligation report JSONをpersistする。
|
|
78
|
+
- `--out <project-relative-path>`は`--write`と同時指定する。`--out`単独はusage error exit 2。
|
|
79
|
+
- default write targetは`.harness/world-obligations.json`。
|
|
80
|
+
- reportはtemp file + atomic renameで置換し、partial fileを残さない。
|
|
81
|
+
- current blocking obligation / cleanup-required policy findingがなければexit 0。
|
|
82
|
+
- derive成功かつblocking resultがあればexit 1。
|
|
83
|
+
- unknown schema、invalid config / policy input、canonicalization / hashing / I/O failureでtrustworthyなevaluationを作れなければexit 2。
|
|
84
|
+
|
|
85
|
+
adopted legacy / active waiver / declared semantic debtが存在するだけではexit 1にしない。ADR-035のblocking mappingをvalidator-system adapterが適用する。
|
|
86
|
+
|
|
87
|
+
### 2. Human / JSON output contractを統一する
|
|
88
|
+
|
|
89
|
+
三commandは次を受理する。
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
--format human|json
|
|
93
|
+
--json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`--json`は`--format json`のalias。両方を矛盾する値で指定した場合はexit 2とする。defaultはTTY / non-TTYに依存させず`human`。
|
|
97
|
+
|
|
98
|
+
#### stdout
|
|
99
|
+
|
|
100
|
+
- primary resultだけを出す。
|
|
101
|
+
- human modeは固定section順・stable ID順でsummary / findings / next actionを表示する。
|
|
102
|
+
- JSON modeは一つのJSON documentだけを出し、progress、ANSI color、warning proseを混ぜない。
|
|
103
|
+
- exit 1のdomain / gate resultもstdoutへ完全なresultを出す。
|
|
104
|
+
- `world:derive --write`のstdoutはderive resultとwritten pathを返すが、persist fileはCLI envelopeでなくraw obligation reportとする。
|
|
105
|
+
|
|
106
|
+
JSON envelope:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
{
|
|
110
|
+
schemaVersion: "phasegate-world-cli/v1",
|
|
111
|
+
command: "world:inspect" | "world:pin" | "world:derive",
|
|
112
|
+
ok: boolean,
|
|
113
|
+
exitCode: 0 | 1 | 2,
|
|
114
|
+
data: command-specific DTO | null,
|
|
115
|
+
diagnostics: sorted diagnostic DTOs
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`generatedAt`を入れない。diagnosticsはcode、stable subject ID、PathKey、line、canonical payloadでsortする。
|
|
120
|
+
|
|
121
|
+
#### stderr
|
|
122
|
+
|
|
123
|
+
- human modeのusage error、invalid flag、unknown / unsupported schema、unexpected execution failureを出す。
|
|
124
|
+
- optional progress / verbose logを将来追加する場合もstderrだけを使う。
|
|
125
|
+
- expected WCR finding、adopted debt、waiver、semantic debtをstderrへ重複出力しない。
|
|
126
|
+
- JSON modeのexpected errorはJSON envelopeをstdoutへ出す。stderrはJSON parserを必要としないunexpected process-level failureの一行だけに限定する。
|
|
127
|
+
|
|
128
|
+
exit code:
|
|
129
|
+
|
|
130
|
+
| code | meaning |
|
|
131
|
+
|---|---|
|
|
132
|
+
| 0 | command completed and no blocking / hard diagnostic condition |
|
|
133
|
+
| 1 | command completed enough to report a domain, structural, or policy failure |
|
|
134
|
+
| 2 | invocation、config、schema、I/O、canonicalization、hashing等によりtrustworthyなresultを作れない |
|
|
135
|
+
|
|
136
|
+
process signal等のplatform exitはこの表の外とする。
|
|
137
|
+
|
|
138
|
+
### 3. Control declarationの正式file nameを固定する
|
|
139
|
+
|
|
140
|
+
project rootのGit-tracked external declarationとして次を採用する。
|
|
141
|
+
|
|
142
|
+
| purpose | canonical file | schemaVersion |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| constraints / pins / aliases / explicit claims | `phasegate.world-constraints.json` | `phasegate-world-constraints/v1` |
|
|
145
|
+
| adoption baseline | `phasegate.world-baseline.json` | `phasegate-world-adoption-baseline/v1` |
|
|
146
|
+
| waivers | `phasegate.world-waivers.json` | `phasegate-world-waivers/v1` |
|
|
147
|
+
| explicit semantic debts | `phasegate.world-debts.json` | `phasegate-world-debts/v1` |
|
|
148
|
+
|
|
149
|
+
`phasegate.<capability>.json`というroot control file慣行に従い、既存`.phasegate/baseline.json`との衝突を`world-` qualifierで避ける。
|
|
150
|
+
|
|
151
|
+
- constraints file不在はempty explicit declaration set。global ID uniqueness等のimplicit WCRは引き続き評価する。
|
|
152
|
+
- baseline / waiver / debt file不在はそれぞれcanonical empty policy input。
|
|
153
|
+
- fileが存在する場合、`schemaVersion`は必須。
|
|
154
|
+
- unknown / unsupported schemaVersionはemptyとして扱わずfail-closed exit 2。
|
|
155
|
+
- supported schema内のmalformed constraintはADR-034 `WCR-001`としてexit 1。document envelope自体を解釈できない場合はexit 2。
|
|
156
|
+
- duplicate record ID / fingerprintでwinnerを選ばない。
|
|
157
|
+
- input array orderやJSON formattingはsemantic identityに使わない。
|
|
158
|
+
|
|
159
|
+
schemaは実装WIで次へ配置する。
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
docs/contracts/world-constraints.schema.json
|
|
163
|
+
docs/contracts/world-baseline.schema.json
|
|
164
|
+
docs/contracts/world-waivers.schema.json
|
|
165
|
+
docs/contracts/world-debts.schema.json
|
|
166
|
+
docs/contracts/world-obligation-report.schema.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
schemaはpublished packageの`docs/contracts/` contractとして扱う。ADR-037ではschema fileをまだ作成せず、constraint / policy schemaはWM-13、report schemaはWM-14、debt schemaは必要に応じてWM-17のimplementation scopeに残す。
|
|
170
|
+
|
|
171
|
+
### 4. Obligation reportは`.harness/`へ非追跡で保存する
|
|
172
|
+
|
|
173
|
+
canonical default path:
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
.harness/world-obligations.json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
schemaVersion:
|
|
180
|
+
|
|
181
|
+
```text
|
|
182
|
+
phasegate-world-obligation-report/v1
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
理由:
|
|
186
|
+
|
|
187
|
+
- matrix / attestation等のmachine-consumed regenerated artifactと同じlifecycle。
|
|
188
|
+
- repositoryの`.gitignore`が`.harness/`を既に除外する。
|
|
189
|
+
- `reports/`のhuman-oriented reporting outputとreview対象のroot declarationsから分離できる。
|
|
190
|
+
- local toolingが固定defaultで発見できる。
|
|
191
|
+
|
|
192
|
+
Git tracking policy:
|
|
193
|
+
|
|
194
|
+
- default reportをcommitしない。
|
|
195
|
+
- `world:derive --write`は`.gitignore`やGit indexを変更しない。
|
|
196
|
+
- persisted reportはcache / inspection convenienceであり、L2 / L3 / attestation / session-startが正本として信頼しない。
|
|
197
|
+
- L3はclean corpusとcontrol declarationsから再導出する。
|
|
198
|
+
- report削除・改竄は次のderive result / gateを変えない。
|
|
199
|
+
- humanが`reports/`へ必要なら`--write --out reports/<name>.json`を明示できるが、generated artifact semanticsと非追跡方針は変わらない。
|
|
200
|
+
|
|
201
|
+
report path、JSON whitespace、written path、mtimeを`corpusRoot`, `constraintRoot`, `evaluationId`, `violationFingerprint`へ含めない。
|
|
202
|
+
|
|
203
|
+
### 5. `world:derive`のpure modeとwrite modeを分離する
|
|
204
|
+
|
|
205
|
+
| mode | invocation | filesystem effect | intended use |
|
|
206
|
+
|---|---|---|---|
|
|
207
|
+
| pure | `world:derive` | none | local review、L2/L3 authoritative re-derivation、CI |
|
|
208
|
+
| write default | `world:derive --write` | atomic write to `.harness/world-obligations.json` | local cache、non-authoritative inspection |
|
|
209
|
+
| write explicit | `world:derive --write --out <path>` | atomic write to explicit project-relative path | diagnostic export |
|
|
210
|
+
|
|
211
|
+
pure modeとwrite modeは同じdomain use case / canonical serializerを使う。同一inputsならraw obligation report bytesは同じでなければならない。write modeだけでfinding、classification、exit codeが変化してはならない。
|
|
212
|
+
|
|
213
|
+
report repositoryをevaluation input portへ接続せず、read-after-writeで判定しない。`--write`失敗はexit 2とし、stdout / previous complete reportを成功扱いしない。
|
|
214
|
+
|
|
215
|
+
### 6. Top-level config keyを`world`とする
|
|
216
|
+
|
|
217
|
+
config-foundation v2 / v3 schemaへ、lower camelCaseの既存top-level慣行に合わせて`world`を追加する。`worldModel`、`world-model`、`worldConstraints` aliasは作らない。
|
|
218
|
+
|
|
219
|
+
resolved contract:
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
world: {
|
|
223
|
+
enabled: boolean
|
|
224
|
+
corpus: {
|
|
225
|
+
productRoots: string[]
|
|
226
|
+
inceptionRoots: string[]
|
|
227
|
+
adrRoots: string[]
|
|
228
|
+
sourceRoots: string[]
|
|
229
|
+
include: string[]
|
|
230
|
+
exclude: string[]
|
|
231
|
+
}
|
|
232
|
+
inputs: {
|
|
233
|
+
matrixPath: string
|
|
234
|
+
attestationPath: string
|
|
235
|
+
integrityManifestPath: string
|
|
236
|
+
}
|
|
237
|
+
declarations: {
|
|
238
|
+
constraintsPath: string
|
|
239
|
+
baselinePath: string
|
|
240
|
+
waiversPath: string
|
|
241
|
+
debtsPath: string
|
|
242
|
+
}
|
|
243
|
+
output: {
|
|
244
|
+
obligationReportPath: string
|
|
245
|
+
}
|
|
246
|
+
sessionStart: {
|
|
247
|
+
enabled: boolean
|
|
248
|
+
maxItems: integer
|
|
249
|
+
maxChars: integer
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
全pathはproject-relative POSIX path。absolute、backslash、`..`をrejectする。root role overlap、同一pathの複数corpus role、case-fold collisionはsilent mergeせずconfig / extraction diagnosticにする。
|
|
255
|
+
|
|
256
|
+
`world.enabled`はautomatic validator / hook integrationを制御し、Phase C rolloutのbackward compatibilityのためdefault `false`。explicit `world:*` commandはL4 explicit executionと同様、`enabled: false`でも実行する。
|
|
257
|
+
|
|
258
|
+
### 7. Config不在時もcanonical defaultsで明示commandを実行する
|
|
259
|
+
|
|
260
|
+
`phasegate.config.json`が見つからない場合、explicit `world:*` commandは次のresolved defaultsを使う。
|
|
261
|
+
|
|
262
|
+
```text
|
|
263
|
+
world.enabled = false
|
|
264
|
+
world.corpus.productRoots = ["docs/product"]
|
|
265
|
+
world.corpus.inceptionRoots = ["docs/inception"]
|
|
266
|
+
world.corpus.adrRoots = ["docs/ADR"]
|
|
267
|
+
world.corpus.sourceRoots = ["scripts/harness"]
|
|
268
|
+
world.corpus.include = ["**/*"]
|
|
269
|
+
world.corpus.exclude = []
|
|
270
|
+
world.inputs.matrixPath = ".harness/requirement-test-matrix.json"
|
|
271
|
+
world.inputs.attestationPath = ".harness/attestation.json"
|
|
272
|
+
world.inputs.integrityManifestPath = "phasegate.integrity.json"
|
|
273
|
+
world.declarations.constraintsPath = "phasegate.world-constraints.json"
|
|
274
|
+
world.declarations.baselinePath = "phasegate.world-baseline.json"
|
|
275
|
+
world.declarations.waiversPath = "phasegate.world-waivers.json"
|
|
276
|
+
world.declarations.debtsPath = "phasegate.world-debts.json"
|
|
277
|
+
world.output.obligationReportPath = ".harness/world-obligations.json"
|
|
278
|
+
world.sessionStart.enabled = true
|
|
279
|
+
world.sessionStart.maxItems = 5
|
|
280
|
+
world.sessionStart.maxChars = 2000
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
defaultでarchiveやlegacy文書をsilent除外しない。extractorがsupported artifactを分類し、unsupported fileはversioned selection rule / diagnosticで扱う。
|
|
284
|
+
|
|
285
|
+
matrix / attestation / integrity manifestはoptional provider inputである。default pathにfileが存在しないことだけでconfig failureにせず、`not-present` observation / diagnosticとして保持する。存在するfileがowner schemaに反する場合はsilent omissionせずhard diagnosticとし、そのendpointを要求するconstraintはmissing / invalid evidenceとして評価する。
|
|
286
|
+
|
|
287
|
+
configが存在する場合はraw JSONを各commandが直接読むのではなく、config-foundation `LoadResolvedConfigUseCase`とWorld mapperを通す。
|
|
288
|
+
|
|
289
|
+
- `world` source sectionをpreset / defaultとmergeし、resolved DTOをWorldへ渡す。
|
|
290
|
+
- existing resolved `paths.inceptionDocs`を、explicit `world.corpus.inceptionRoots`がない場合のinception rootとして使う。
|
|
291
|
+
- existing resolved `paths.designDocs`がdefault product root外なら、explicit product design rootとして追加し、product corpus roleを保つ。
|
|
292
|
+
- existing resolved `layers.L3.requirementMatrixPath`を、explicit `world.inputs.matrixPath`がない場合に使う。
|
|
293
|
+
- output format / session limitはcorpus / constraint config digestへ混ぜず、ADR-033のscope別relevant config digestへ振り分ける。
|
|
294
|
+
|
|
295
|
+
config fileが存在するのにinvalid、unknown top-level / field、type mismatch、unsupported config schemaである場合、defaultsへfallbackしない。exit 2でfail-closedにする。
|
|
296
|
+
|
|
297
|
+
### 8. Phase C validator IDを予約する
|
|
298
|
+
|
|
299
|
+
現在未使用の次のID / nameを予約する。
|
|
300
|
+
|
|
301
|
+
| Phase C WI | validator ID | canonical name | responsibility |
|
|
302
|
+
|---|---|---|---|
|
|
303
|
+
| WM-19 | `L2-017` | `world-constraint-admission` | changed / new claim・pin・constraint declarationのfast-path、WCR-001、unresolved new endpointをfail-closed |
|
|
304
|
+
| WM-20 | `L3-008` | `world-constraint-rederivation` | clean corpus / declarationsからauthoritative deriveし、baseline / waiver policyを適用 |
|
|
305
|
+
|
|
306
|
+
`WCR-NNN`はWorld内部rule IDであり、`L2-017` / `L3-008`はvalidator-system execution identityである。一つのvalidator resultに複数WCR findingを含められる。
|
|
307
|
+
|
|
308
|
+
本ADRではreservationだけを行う。`ValidatorId`, registry、RunL2 / RunL3、composition-root、presetへの実登録はそれぞれWM-19 / WM-20で行い、登録前の現行runtimeがこれらをrejectする挙動を変更しない。
|
|
309
|
+
|
|
310
|
+
`world.enabled: false`ではautomatic L2-017 / L3-008 integrationをskipする。explicit `world:derive`は実行できる。default enablementを変更するPhase C rolloutはconfig / preset migrationと同じWIでreviewする。
|
|
311
|
+
|
|
312
|
+
### 9. SessionStart summaryを5件・2000文字に制限する
|
|
313
|
+
|
|
314
|
+
WM-21のWorld obligation sectionは、resolved config defaultで次のhard capを持つ。
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
maxItems = 5
|
|
318
|
+
maxChars = 2000
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
- maxItemsは表示するobligation / policy diagnostic entry数。
|
|
322
|
+
- maxCharsはWorld section全体のUnicode scalar value数で、header、summary、omission lineを含む。
|
|
323
|
+
- blockingを先、次にcleanup-required、adopted / waivedの順とし、同順位はrule ID、constraint ID、fingerprintでsortする。
|
|
324
|
+
- char capを超えるentryは途中切断せずentry単位で省略する。
|
|
325
|
+
- 省略時は`... <N> more; run phasegate world:derive`を末尾へ入れる。このlineもmaxChars内。
|
|
326
|
+
- constraint prose、waiver reason、semantic debt free text、full obligation reportをpromptへ注入しない。stable ID、rule ID、PathKey、classification、countだけを使う。
|
|
327
|
+
- repository由来文字列を含める場合は既存untrusted-data fence / neutralizationを使う。
|
|
328
|
+
- summaryはcurrent World query / in-process deriveから作り、persisted obligation reportだけを読んで生成しない。cacheが存在してもcurrent deriveと独立照合できない場合は無視する。
|
|
329
|
+
|
|
330
|
+
`maxItems` / `maxChars`はconfigでより小さくできる。schema上限をそれぞれ20件 / 8000文字とし、0 / negative / over-limitはinvalid configとしてfail-closedする。session hook自体は既存どおりwarn-only / exit 0で、World summary取得失敗はsessionをblockせず短いunavailable lineを出す。authoritative blockingはL2 / L3が所有する。
|
|
331
|
+
|
|
332
|
+
### 10. Attestation v2 contractはWM-23へ委譲する
|
|
333
|
+
|
|
334
|
+
attestation v2の`schemaVersion`, `predicateType`, v1 coexistence periodは本ADRで決めない。WM-23がattestation ownerのdomain / schema / backward compatibility testとともに決定する。
|
|
335
|
+
|
|
336
|
+
本ADRが固定するのは、attestation input default pathと、将来top-level compositionがplain `worldSnapshotRoot`を注入するCLI / config側の境界だけである。attestation v2 schemaをWorld config / obligation reportへ複製しない。
|
|
337
|
+
|
|
338
|
+
### 11. §10未決事項のdispositionを完結する
|
|
339
|
+
|
|
340
|
+
| §10 item | disposition |
|
|
341
|
+
|---|---|
|
|
342
|
+
| fragment ID notation | ADR-032で`@world-fragment-id`に確定 |
|
|
343
|
+
| legacy whole-file migration | ADR-032でmixed-mode ratchetに確定 |
|
|
344
|
+
| raw prose Unicode normalization | ADR-033で非適用に確定 |
|
|
345
|
+
| hashing capability owner | ADR-033でattestation public facadeに確定 |
|
|
346
|
+
| World declaration file names | 本ADR §3で確定 |
|
|
347
|
+
| obligation report path | 本ADR §4で`.harness/world-obligations.json`に確定 |
|
|
348
|
+
| world config key / validator ID | 本ADR §6 / §8で`world`, `L2-017`, `L3-008`に確定 / 予約 |
|
|
349
|
+
| initial structural fingerprint count | ADR-031どおりWM-17実測。推測値を置かない |
|
|
350
|
+
| semantic debt ID / coverage annotation | ADR-035で確定 |
|
|
351
|
+
| attestation v2 schema / coexistence | 本ADR §10どおりWM-23へ明示委譲 |
|
|
352
|
+
| session-start limit | 本ADR §9で5件 / 2000文字に確定 |
|
|
353
|
+
|
|
354
|
+
## Consequences
|
|
355
|
+
|
|
356
|
+
### Positive
|
|
357
|
+
|
|
358
|
+
- read-only、reviewed control mutation、generated report writeの副作用境界が明確になる。
|
|
359
|
+
- Git-tracked declarationsとignored derived reportを物理的に分離できる。
|
|
360
|
+
- JSON stdoutをCI / agentが安定してparseできる。
|
|
361
|
+
- config不在の明示inspectionを可能にしつつ、存在するinvalid config / schemaはfail-closedにできる。
|
|
362
|
+
- WCR rule IDとvalidator execution IDを混同せずPhase Cへ予約できる。
|
|
363
|
+
- session-startへreport全文やfree textを注入せずprompt budgetを制限できる。
|
|
364
|
+
|
|
365
|
+
### Negative / Trade-off
|
|
366
|
+
|
|
367
|
+
- rootに4つのWorld control JSON fileが増える。
|
|
368
|
+
- `world:pin --apply`と`world:derive --write`で異なるmutation flagを覚える必要がある。
|
|
369
|
+
- persisted reportはGit管理されないため、historical comparisonはevaluation IDs / CI artifactsを別途保存する必要がある。
|
|
370
|
+
- `world.enabled: false`でも明示commandが動くため、automatic integrationとの違いをdocumentする必要がある。
|
|
371
|
+
- reserved validator IDはPhase C実装までcurrent registryではinvalidである。
|
|
372
|
+
|
|
373
|
+
## Alternatives
|
|
374
|
+
|
|
375
|
+
- **`phasegate world <subcommand>`にする** — current canonical command registryがtop-level case集合を正本とし、他capabilityがcolon namespaceを使うため不採用。
|
|
376
|
+
- **`phasegate:world:*`にする** — `phasegate:*` core harness-api namespaceへWorld capabilityを二重nestするため不採用。
|
|
377
|
+
- **deriveをdefault writeにする** — inspection / CIで意図しないworktree mutationを起こすため不採用。
|
|
378
|
+
- **obligation reportを`reports/`へ出す** — human reportとmachine cacheを混在させ、matrix / attestationの`.harness/`慣行から外れるため不採用。
|
|
379
|
+
- **obligation reportをGit trackする** —手編集 / stale outputをcontrol inputと誤認させ、ADR-035に反するため不採用。
|
|
380
|
+
- **既存`.phasegate/baseline.json`をWorld file名として再利用する** — path / SHA-1 hook grandfatherとfingerprint adoptionを混同するため不採用。
|
|
381
|
+
- **validator IDをWCR IDと同一にする** — gate executionとindividual structural ruleのidentityを混同するため不採用。
|
|
382
|
+
- **session-startへ全obligationを注入する** — prompt budget、free-text injection、stale report依存を生むため不採用。
|
|
383
|
+
|
|
384
|
+
## 関連要件・文書
|
|
385
|
+
|
|
386
|
+
- `docs/inception/_cross/WI-280/delivery_plan.md` §1, §3 WM-04, §7 ADR-037, §10
|
|
387
|
+
- `docs/inception/_cross/WI-284/description.md`
|
|
388
|
+
- `docs/inception/_cross/WI-284/logical_design.md`
|
|
389
|
+
- ADR-031(ownership / artifact lifecycle)
|
|
390
|
+
- ADR-032(identity / fragment / alias)
|
|
391
|
+
- ADR-033(canonical roots / relevant config)
|
|
392
|
+
- ADR-034(WCR semantics)
|
|
393
|
+
- ADR-035(obligation / baseline / waiver / semantic debt)
|
|
394
|
+
- ADR-036(L4-004 coexistence)
|
|
395
|
+
- `scripts/harness/harness-api/domain/value-objects/known-harness-commands.ts`
|
|
396
|
+
- `scripts/harness/config-foundation/infrastructure/schemas/harness-config-v2.schema.json`
|
|
397
|
+
- `scripts/harness/config-foundation/infrastructure/schemas/harness-config-v3.schema.json`
|
|
398
|
+
- `docs/contracts/`
|
|
@@ -20,6 +20,21 @@
|
|
|
20
20
|
"type": "string",
|
|
21
21
|
"pattern": "^H(?:F\\d+|\\d{2})-\\d{2}$"
|
|
22
22
|
},
|
|
23
|
+
"coverageStatus": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"enum": ["planned", "required"],
|
|
26
|
+
"description": "WI-292 (schema 1.2): Story coverage gate lifecycle の現在値。省略時は required として扱う(1.0/1.1 後方互換)。"
|
|
27
|
+
},
|
|
28
|
+
"coverageLifecycle": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"minItems": 1,
|
|
31
|
+
"maxItems": 2,
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["planned", "required"]
|
|
35
|
+
},
|
|
36
|
+
"description": "WI-292 (schema 1.2): Git 管理された順方向遷移履歴。有効系列と status 終端一致は L3-004 が fail-closed で検査する。"
|
|
37
|
+
},
|
|
23
38
|
"storyMappings": {
|
|
24
39
|
"type": "array",
|
|
25
40
|
"items": {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://phasegate.dev/contracts/world-baseline.schema.json",
|
|
4
|
+
"title": "PhaseGate World adoption baseline",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schemaVersion", "rulesetVersion", "sourceEvaluationId", "sourceCorpusRoot", "sourceConstraintRoot", "adoptedByWorkItemId", "adoptionReason", "entries"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schemaVersion": { "const": "phasegate-world-adoption-baseline/v1" },
|
|
10
|
+
"rulesetVersion": { "type": "string", "minLength": 1 },
|
|
11
|
+
"sourceEvaluationId": { "type": "string", "pattern": "^pgw:v1:evaluation:sha256:[0-9a-f]{64}$" },
|
|
12
|
+
"sourceCorpusRoot": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
|
|
13
|
+
"sourceConstraintRoot": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
|
|
14
|
+
"adoptedByWorkItemId": { "type": "string", "pattern": "^WI-[0-9]+$" },
|
|
15
|
+
"adoptionReason": { "type": "string", "minLength": 1 },
|
|
16
|
+
"entries": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"required": ["violationFingerprint", "ruleId", "constraintId"],
|
|
22
|
+
"properties": {
|
|
23
|
+
"violationFingerprint": { "type": "string", "pattern": "^pgw:v1:violation-fingerprint:sha256:[0-9a-f]{64}$" },
|
|
24
|
+
"ruleId": { "enum": ["WCR-002", "WCR-003", "WCR-004", "WCR-005", "WCR-006", "WCR-007", "WCR-008"] },
|
|
25
|
+
"constraintId": {
|
|
26
|
+
"oneOf": [
|
|
27
|
+
{ "type": "null" },
|
|
28
|
+
{ "type": "string", "pattern": "^pgw:v1:constraint:[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$" }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://phasegate.dev/contracts/world-constraints.schema.json",
|
|
4
|
+
"title": "PhaseGate World constraint declarations",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schemaVersion", "constraints", "aliases"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schemaVersion": { "const": "phasegate-world-constraints/v1" },
|
|
10
|
+
"constraints": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": { "$ref": "#/$defs/constraintRecord" }
|
|
13
|
+
},
|
|
14
|
+
"aliases": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": { "$ref": "#/$defs/aliasRecord" }
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"$defs": {
|
|
20
|
+
"nodePin": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"required": ["nodeId", "contentDigest"],
|
|
24
|
+
"properties": {
|
|
25
|
+
"nodeId": { "type": "string", "pattern": "^pgw:v1:.+" },
|
|
26
|
+
"contentDigest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"constraintRecord": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"additionalProperties": false,
|
|
32
|
+
"required": ["constraintId", "factType", "claimant", "premise", "applicableRuleIds"],
|
|
33
|
+
"properties": {
|
|
34
|
+
"constraintId": { "type": "string", "pattern": "^pgw:v1:constraint:[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$" },
|
|
35
|
+
"factType": { "enum": ["references", "depends-on", "refines", "content-equals"] },
|
|
36
|
+
"claimant": { "$ref": "#/$defs/nodePin" },
|
|
37
|
+
"premise": { "$ref": "#/$defs/nodePin" },
|
|
38
|
+
"applicableRuleIds": {
|
|
39
|
+
"type": "array",
|
|
40
|
+
"minItems": 1,
|
|
41
|
+
"uniqueItems": true,
|
|
42
|
+
"items": { "enum": ["WCR-002", "WCR-003", "WCR-004", "WCR-005", "WCR-006", "WCR-007", "WCR-008"] }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"aliasRecord": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"required": ["from", "to"],
|
|
50
|
+
"properties": {
|
|
51
|
+
"from": { "type": "string", "pattern": "^pgw:v1:.+" },
|
|
52
|
+
"to": { "type": "string", "pattern": "^pgw:v1:.+" }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://phasegate.dev/contracts/world-debts.schema.json",
|
|
4
|
+
"title": "PhaseGate World semantic debt declarations",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["schemaVersion", "debts"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"schemaVersion": { "const": "phasegate-world-debts/v1" },
|
|
10
|
+
"debts": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"required": ["debtId", "kind", "title", "reason", "ownerUnit", "introducedByWorkItemId", "references"],
|
|
16
|
+
"properties": {
|
|
17
|
+
"debtId": { "type": "string", "pattern": "^pgw:v1:semantic-debt:[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$" },
|
|
18
|
+
"kind": { "const": "semantic" },
|
|
19
|
+
"title": { "type": "string", "minLength": 1 },
|
|
20
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
21
|
+
"ownerUnit": { "type": "string", "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$" },
|
|
22
|
+
"introducedByWorkItemId": { "type": "string", "pattern": "^WI-[0-9]+$" },
|
|
23
|
+
"references": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"uniqueItems": true,
|
|
26
|
+
"items": { "type": "string", "pattern": "^pgw:v1:.+" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|