ops-wiki-agent-kit 0.1.0 → 0.1.1
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/.github/agents/docs-target-catalog.agent.md +8 -20
- package/.github/agents/docs-target-queue-from-catalog.agent.md +5 -4
- package/.github/agents/source-code-to-spec-documenter.agent.md +1 -0
- package/.github/agents/source-code-to-spec-reviewer.agent.md +7 -5
- package/.github/agents/source-code-to-system-ops-overview.agent.md +1 -0
- package/.github/prompts/00-discover-target-baseline.prompt.md +37 -0
- package/.github/prompts/00-generate-target-all-spec.prompt.md +10 -10
- package/.github/prompts/01-generate-target-foundation-spec.prompt.md +13 -9
- package/.github/prompts/02-generate-target-architecture-spec.prompt.md +11 -7
- package/.github/prompts/03-generate-target-ops-spec.prompt.md +11 -7
- package/.github/prompts/docs-target-catalog.prompt.md +1 -3
- package/.github/prompts/docs-target-queue-from-catalog.prompt.md +6 -6
- package/.github/prompts/generate-docs-index.prompt.md +77 -0
- package/.github/prompts/generate-system-ops-overview.prompt.md +3 -2
- package/.github/skills/database-query/SKILL.md +8 -6
- package/.github/skills/database-query/references/client-commands.md +9 -1
- package/.github/skills/database-query/scripts/find_db_config.py +1 -1
- package/.github/skills/docs-target-queue-from-catalog/SKILL.md +43 -213
- package/.github/skills/docs-target-queue-from-catalog/references/docs-target-queue-contract.md +60 -13
- package/.github/skills/docs-target-queue-from-catalog/references/metadata-acquisition-patterns.md +104 -9
- package/.github/skills/docs-target-queue-from-catalog/scripts/write_documentation_target_queue.py +20 -3
- package/.github/skills/source-code-to-ops-spec-guidelines/SKILL.md +3 -25
- package/.github/skills/source-code-to-ops-spec-guidelines/references/01-system-overview-and-business-scenarios-guideline.md +0 -8
- package/.github/skills/source-code-to-ops-spec-guidelines/references/02-core-architecture-flow-data-logic-guideline.md +230 -171
- package/.github/skills/source-code-to-ops-spec-guidelines/references/03-error-ops-scenario-coverage-guideline.md +20 -2
- package/.github/skills/source-code-to-ops-spec-guidelines/references/supporting-output-format-diagram-and-example-reference.md +145 -143
- package/.github/skills/source-code-to-spec-documenter/SKILL.md +35 -6
- package/.github/skills/source-code-to-spec-documenter/references/generation-handoff-contract.md +43 -132
- package/.github/skills/source-code-to-spec-documenter/references/generation-workflow.md +100 -48
- package/.github/skills/source-code-to-spec-documenter/references/handoff-initial-template.json +76 -0
- package/.github/skills/source-code-to-spec-documenter/references/source-tracing-rules.md +61 -15
- package/.github/skills/source-code-to-spec-documenter/references/target-queue-contract.md +24 -7
- package/.github/skills/source-code-to-spec-documenter/scripts/handoff_update.py +310 -0
- package/.github/skills/source-code-to-spec-documenter/scripts/spec_queue.py +31 -2
- package/.github/skills/source-code-to-spec-tools/SKILL.md +11 -0
- package/.github/skills/source-code-to-spec-tools/references/repository-artifact-contract.md +61 -51
- package/.github/skills/source-code-to-spec-tools/references/target-queue-schema-contract.md +13 -1
- package/.github/skills/source-code-to-spec-tools/references/terminology-contract.md +2 -2
- package/.github/skills/source-code-to-spec-tools/scripts/catalog_query.py +43 -2
- package/.github/skills/source-code-to-spec-tools/scripts/queue_contract.py +3 -0
- package/.github/skills/source-code-to-spec-tools/scripts/target_query.py +3 -0
- package/.github/skills/source-code-to-system-ops-overview/SKILL.md +2 -1
- package/.github/skills/source-code-to-system-ops-overview/references/system-operations-overview-guideline.md +36 -5
- package/package.json +1 -1
package/.github/skills/source-code-to-spec-documenter/references/generation-handoff-contract.md
CHANGED
|
@@ -1,155 +1,66 @@
|
|
|
1
1
|
# Generation Handoff Contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
每一次 baseline / generation run 都必須寫出 handoff。非 baseline generation run 在進入 review 前,必須先寫出或刷新 handoff;baseline run 只建立或刷新 discovery ledger,不觸發 review。Handoff 是 compact machine-readable ledger,不是 target SPEC 摘要、長篇追蹤報告或跨 scope history dump。Handoff 只寫入 durable workflow artifact path:
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
|
-
|
|
6
|
+
.github/artifacts/source-code-to-spec/<target_id>/handoff.json
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Initial Template
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"target_id": "F10",
|
|
15
|
-
"source_type": "Function",
|
|
16
|
-
"group": "{business_group}",
|
|
17
|
-
"name": "{target_name}",
|
|
18
|
-
"entrypoint": "{entrypoint}",
|
|
19
|
-
"document_root": "docs/feature/{business_group}/{target_name}",
|
|
20
|
-
"generation_scope": "all",
|
|
21
|
-
"doc_profile": "standard",
|
|
22
|
-
"selected_coverage_views": [],
|
|
23
|
-
"generation_entrypoint": "all-generation",
|
|
24
|
-
"review_entrypoint": "review-workflow",
|
|
25
|
-
"queue_path": "docs/docs-target-queue.md",
|
|
26
|
-
"doc_file_plan": {
|
|
27
|
-
"selected_output_files": [
|
|
28
|
-
"docs/feature/{business_group}/{target_name}/{target_name}-01-document-foundation-and-business.md",
|
|
29
|
-
"docs/feature/{business_group}/{target_name}/{target_name}-02-core-architecture-flow-data-logic.md",
|
|
30
|
-
"docs/feature/{business_group}/{target_name}/{target_name}-03-error-ops-scenario-coverage.md"
|
|
31
|
-
],
|
|
32
|
-
"guideline_reference_set": [
|
|
33
|
-
".github/skills/source-code-to-ops-spec-guidelines/references/supporting-output-format-diagram-and-example-reference.md",
|
|
34
|
-
".github/skills/source-code-to-ops-spec-guidelines/references/01-system-overview-and-business-scenarios-guideline.md",
|
|
35
|
-
".github/skills/source-code-to-ops-spec-guidelines/references/02-core-architecture-flow-data-logic-guideline.md",
|
|
36
|
-
".github/skills/source-code-to-ops-spec-guidelines/references/03-error-ops-scenario-coverage-guideline.md"
|
|
37
|
-
],
|
|
38
|
-
"omitted_docs": []
|
|
39
|
-
},
|
|
40
|
-
"knowledge_map_preflight": {
|
|
41
|
-
"queue_status": "loaded",
|
|
42
|
-
"catalog_status": "loaded",
|
|
43
|
-
"source_map": [],
|
|
44
|
-
"known_gaps": [],
|
|
45
|
-
"reader_facing_name_map": [
|
|
46
|
-
{
|
|
47
|
-
"id": "{target_id}",
|
|
48
|
-
"name": "{target_name}",
|
|
49
|
-
"entrypoint": "{entrypoint}",
|
|
50
|
-
"relation": "selected_target",
|
|
51
|
-
"display_label": "{target_name}"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"id": "{related_target_id}",
|
|
55
|
-
"name": "{related_target_name}",
|
|
56
|
-
"entrypoint": "{related_entrypoint}",
|
|
57
|
-
"relation": "handoff_edge",
|
|
58
|
-
"display_label": "{related_target_name}"
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
"related_rows": [
|
|
62
|
-
{
|
|
63
|
-
"id": "{related_target_id}",
|
|
64
|
-
"name": "{related_target_name}",
|
|
65
|
-
"entrypoint": "{related_entrypoint}",
|
|
66
|
-
"relation": "handoff_edge",
|
|
67
|
-
"reason": "{short source-backed handoff reason}",
|
|
68
|
-
"correlation_key": "{correlation_key}",
|
|
69
|
-
"source_evidence_refs": []
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
"relation_candidates": [],
|
|
73
|
-
"coverage_hints": [],
|
|
74
|
-
"trace_hypotheses": [],
|
|
75
|
-
"search_priority": []
|
|
76
|
-
},
|
|
77
|
-
"code_verification": {
|
|
78
|
-
"entrypoint_verified": false,
|
|
79
|
-
"verified_assumptions": [],
|
|
80
|
-
"source_backed_facts": [],
|
|
81
|
-
"expansion_search_performed": false,
|
|
82
|
-
"unmapped_behaviors_found": []
|
|
83
|
-
},
|
|
84
|
-
"map_drift": {
|
|
85
|
-
"status": "none",
|
|
86
|
-
"items": [],
|
|
87
|
-
"map_corrections": []
|
|
88
|
-
},
|
|
89
|
-
"artifact_drift": {
|
|
90
|
-
"status": "none",
|
|
91
|
-
"items": []
|
|
92
|
-
},
|
|
93
|
-
"generated_files": [],
|
|
94
|
-
"file_actions": [],
|
|
95
|
-
"change_justification": [],
|
|
96
|
-
"evidence_checked": [],
|
|
97
|
-
"not_checked": [],
|
|
98
|
-
"source_evidence": [
|
|
99
|
-
{
|
|
100
|
-
"path": "src/main/java/com/example/OrderController.java",
|
|
101
|
-
"line": 42,
|
|
102
|
-
"symbol": "OrderController.importOrders()",
|
|
103
|
-
"kind": "method"
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
"coverage_gaps": [],
|
|
107
|
-
"unresolved_items": [],
|
|
108
|
-
"status": "generated"
|
|
109
|
-
}
|
|
110
|
-
```
|
|
11
|
+
初始 handoff skeleton 由 `references/handoff-initial-template.json` 擁有。該檔只在建立新 baseline 或修復 missing / legacy baseline 時載入;一般 `01` / `02` / `03` scoped generation 若既有 durable handoff 有有效 `baseline`,不得為了更新 `current_run` 而讀取或重套初始 template。
|
|
12
|
+
|
|
13
|
+
`generation-handoff-contract.md` 只維護欄位規則、compact update 與 write discipline;不要在本檔複製完整 JSON skeleton。
|
|
111
14
|
|
|
112
15
|
## Field Rules
|
|
113
16
|
|
|
114
|
-
- `target_id`、`entrypoint`、`document_root`、`generation_scope`、`doc_profile`、`queue_path` 與 `
|
|
115
|
-
- `generation_scope` 必須是 `all`、`foundation`、`architecture` 或 `ops`;`doc_profile` 必須是 `lite`、`standard` 或 `full`。兩者各自維持獨立欄位語意。
|
|
17
|
+
- `target_id`、`entrypoint`、`document_root`、`generation_scope`、`doc_profile`、`queue_path`、`handoff_path`、`baseline`、`current_run`、`map_drift`、`artifact_drift` 與 `status` 為必填欄位。
|
|
18
|
+
- `generation_scope` 必須是 `baseline`、`all`、`foundation`、`architecture` 或 `ops`;`doc_profile` 必須是 `lite`、`standard` 或 `full`。兩者各自維持獨立欄位語意。
|
|
19
|
+
- Patch JSON 的 root `generation_scope` 與 `current_run.scope` 必須等於本次 invocation scope,也必須與 `handoff_update.py --scope` 完全一致。不得重用其他 scope 的 patch JSON,也不得用 baseline patch 更新非 baseline scope。
|
|
116
20
|
- `generation_entrypoint` 與 `review_entrypoint` 用來記錄本次 workflow 的 stable entrypoint;可以是 prompt path、slash command、agent handoff label 或其他 invoker-specific identifier。
|
|
117
|
-
- `doc_file_plan`
|
|
118
|
-
- `doc_file_plan
|
|
21
|
+
- `baseline.doc_file_plan` 記錄 durable discovery baseline 與後續預期文件;`current_run.doc_file_plan` 才是本次 run 的 target-facing output allowlist。Allowlist 語意由 `generation-workflow.md` 的 `Strict Output Boundary` 擁有。
|
|
22
|
+
- `current_run.doc_file_plan` 必須列出本次 selected output files、guideline reference set、scope 外或整份不適用的 omitted docs 與 completion impact。Selected output filename 必須符合 `generation-workflow.md` 的 File Naming Contract:以 selected row `name` / 功能名稱為開頭,不使用 target row `id`。
|
|
23
|
+
- `baseline` scope 的 `current_run.doc_file_plan.selected_output_files` 必須是空陣列;可用 `baseline.doc_file_plan.planned_output_files` 記錄後續 `foundation`、`architecture`、`ops` 預期輸出,但 planned files 不是本次 run 的寫入 allowlist。
|
|
119
24
|
- `omitted_docs` 只用於記錄本次 `generation_scope` 未選取的整份文件,或整份 target doc 已確認不適用的情況。Selected output file 內沒有資料、不適用或來源不足的章節,必須保留章節標題並在文件中寫入簡短 `N/A` / `無法由目前來源確認` / `Unresolved` 原因。若省略整份文件或章節缺口會影響 completion,必須同步寫入 `coverage_gaps` 或 `unresolved_items`。
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `reader_facing_name_map` 用於 generation / review 檢查 selected output files 的 reader-facing label;`related_rows` 維持 relation classification,final SPEC metadata 由 guideline contract 擁有。
|
|
25
|
+
- `baseline` 必須記錄 generation 前已讀取的 queue/catalog 狀態、相關 rows、known gaps、coverage hints、trace hypotheses 與 search priority。它作為假設與搜尋索引;行為事實來源由 `direct_evidence_refs` 與各 scope delta 的 `source_evidence` 承接。
|
|
26
|
+
- `baseline.reader_facing_name_map` 必須記錄 selected row 與本次可能寫入 final SPEC / handoff summary 的 related rows、confirmed `handoff_edge` rows、relation candidates 或 catalog handoff rows。每筆至少包含 `id`、`name`、`entrypoint`、`relation` 與 `display_label`。`id` 是 machine-readable lookup handle;`display_label` 是 final SPEC 可使用的 reader-facing label,必須優先使用 row `name` / 功能名稱,其次使用 source-backed job / API / handler / batch name。若只有 row `id` 而無法確認可讀 label,`display_label` 必須填 `Unresolved`,final SPEC 使用 `Unresolved` 作為可讀缺口標示。
|
|
27
|
+
- `reader_facing_name_map` 用於 generation / review 檢查 selected output files 的 reader-facing label;`baseline.related_rows` 維持 relation classification,final SPEC metadata 由 guideline contract 擁有。
|
|
123
28
|
- 任何 generation run、rerun 或 handoff reuse 若發現 handoff 缺少 `reader_facing_name_map`、map 中缺少 `display_label`,或 `display_label` 等於 raw row `id`,該 handoff 對 reader-facing naming 視為 legacy / incomplete。Documenter 必須用 current queue / catalog / source evidence 重建 map 後再產生 selected output file;無法解析者填 `display_label=Unresolved`,並在 `unresolved_items` 或 `map_drift.items` 記錄缺口。
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
-
|
|
127
|
-
- `
|
|
29
|
+
- `baseline.related_rows` 只保存依 `source-tracing-rules.md` 判定成立的 compact `handoff_edge`。共用資料表、報表查詢、audit/log、lookup、join 或只有 keyword/group/resource 相同的候選關係,依影響寫入 `baseline.relation_candidates`、`current_run.coverage_gaps` 或 `current_run.unresolved_items`。
|
|
30
|
+
- `baseline.relation_candidates` 可短暫保留尚未確認的候選關係;形成 `handoff_edge` 後才升級成 related row。候選關係只應保留 id、name、candidate reason 與 unresolved reason。
|
|
31
|
+
- `baseline` scope 必須保留 visible subfunctions、direct links、form actions、popup、AJAX、include、downstream candidate 與 unmapped behaviors 的索引;若尚未符合 `handoff_edge` 條件,不得丟棄,應放入 `baseline.relation_candidates`、`baseline.unmapped_behaviors_found`、`baseline.coverage_gaps`、`baseline.unresolved_items`、`current_run.coverage_gaps` 或 `current_run.unresolved_items`。
|
|
32
|
+
- 每筆 `baseline.related_rows[]` 必須包含 `id`、`name`、`entrypoint`、`relation=handoff_edge`、`reason`、`correlation_key` 與可回查的 `source_evidence_refs` 或 source location。Handoff 中的 downstream target 關係維持 compact summary。
|
|
128
33
|
- `map_drift` 必須記錄 queue/catalog 與 code evidence 的差異;沒有差異時使用 `status=none`,有差異時使用 `status=found` 並填入 `items` 與 `map_corrections`。
|
|
129
34
|
- `artifact_drift` 必須記錄 queue status、`document_path`、三份 target SPEC 或 `last_handoff` 與實際檔案存在性的差異;沒有差異時使用 `status=none`,有差異時使用 `status=found` 並填入 `items`。每個 item 應至少包含 `path`、`expected_state`、`actual_state`、`impact` 與 `action_taken`。
|
|
130
|
-
- 若 `docs/docs-target-catalog.md` 缺失或無法對應 selected row,`
|
|
131
|
-
- `
|
|
132
|
-
- `
|
|
133
|
-
- `
|
|
134
|
-
- `
|
|
135
|
-
- `
|
|
136
|
-
- `
|
|
35
|
+
- 若 `docs/docs-target-catalog.md` 缺失或無法對應 selected row,`baseline.catalog_status` 必須標記為 `missing`、`not_applicable` 或 `unmatched`,並在 `current_run.unresolved_items` 說明影響。
|
|
36
|
+
- `handoff_path` 必須是 `.github/artifacts/source-code-to-spec/<target_id>/handoff.json`。不得指向 `target/**`、`docs/**` 或其他 scratch / reader-facing path。
|
|
37
|
+
- `current_run.generated_files` 必須填入相對於 repository root 的路徑,且必須是 `current_run.doc_file_plan.selected_output_files` 的子集合;`baseline` scope 必須填空陣列。`handoff.json` 由 `handoff_path` 承接,不列入 `generated_files`。
|
|
38
|
+
- `current_run.file_actions` 必須逐檔記錄 file action;action 判定規則由 `source-tracing-rules.md` 擁有。
|
|
39
|
+
- `current_run.change_justification` 必須逐檔或逐章節記錄 action、reason 與 evidence;action 判定規則由 `source-tracing-rules.md` 擁有。
|
|
40
|
+
- `current_run.evidence_checked` 必須列出本次實際檢查過的 source path、runtime metadata、DB object、SQL、config、existing doc 或 external contract。
|
|
41
|
+
- `current_run.not_checked` 必須列出依 target 型態與 selected scope 應追蹤但尚未確認的 evidence,並說明原因;若無則填空陣列。
|
|
42
|
+
- `current_run.source_evidence` 必須是本次 scope 新增或修正的 `EvidenceRef[]`;每個物件都包含 `path`、`line`、`symbol`、`kind`。Repo file evidence 必須使用 1-based `line`;只有 DB metadata、runtime export、external contract 或 generated doc 無可用行號時才可填 `null`。
|
|
137
43
|
- `source_evidence[].kind` 必須使用穩定英文值,例如 `entrypoint`、`route`、`handler`、`class`、`method`、`SQL`、`table`、`config`、`job`、`procedure`、`routine`、`file`、`test`、`runtime_metadata`、`generated_doc`、`external_contract` 或 `other`。
|
|
138
|
-
- `coverage_gaps`
|
|
139
|
-
- `unresolved_items` 應明確且可執行。
|
|
140
|
-
- `
|
|
44
|
+
- `current_run.coverage_gaps` 應列出本次 scope 發現或仍影響完整性的缺失 evidence,例如 DB metadata、runtime config、generated registry、production seed data、credentials 或 external contract,並描述 impact 與最小下一步。
|
|
45
|
+
- `current_run.unresolved_items` 應明確且可執行。
|
|
46
|
+
- `scope_deltas` 保存必要的 prior scope deltas。每個 delta 只保留 scope、status、generated_files、file_actions、新增或修正的 `source_evidence`、仍需後續處理的 `not_checked`、`coverage_gaps`、`unresolved_items` 與更新時間;不得保存整段 prose summary、完整文件摘錄或重複 baseline 中已有的 map。
|
|
47
|
+
- `status` 應為 `baseline_ready`、`generated`、`partial`、`blocked` 或 `failed`,並與 queue workflow 的 completion 判斷一致。`baseline_ready` 只可用於 `baseline` scope,表示 entrypoint、reader-facing name map、direct evidence 與 follow-up ledger 已建立;若主要 source path 尚未追完或 `not_checked` 仍包含 completion-critical evidence,使用 `partial`、`blocked` 或 `failed` 表示目前狀態。
|
|
141
48
|
|
|
142
49
|
## Write Discipline
|
|
143
50
|
|
|
144
|
-
`handoff.json` 是 generation
|
|
51
|
+
`handoff.json` 是 baseline / generation / review 之間的 machine-readable workflow artifact。Documenter 寫入 handoff 時必須遵守:
|
|
145
52
|
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
- 若
|
|
151
|
-
- `
|
|
53
|
+
- 每次 handoff 寫入都必須寫到 durable path:`.github/artifacts/source-code-to-spec/<target_id>/handoff.json`。
|
|
54
|
+
- Handoff 寫入必須透過 `python -B .github/skills/source-code-to-spec-documenter/scripts/handoff_update.py update --handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json --target-id <target_id> --scope <generation_scope> --patch <patch-json>`。Documenter 只準備本次 patch JSON,不手動讀寫或重組整份 `handoff.json`。
|
|
55
|
+
- Patch JSON 必須包含 `current_run`;root `generation_scope`、`current_run.scope` 與 CLI `--scope` 必須表示同一個 invocation scope。若 handoff 檔案不存在或既有 handoff 缺少 `baseline`,才載入 `references/handoff-initial-template.json`,並在 patch 內包含 compact `baseline`。Patch 可包含要更新的 root metadata、`map_drift`、`artifact_drift` 與 `status`。
|
|
56
|
+
- `foundation`、`architecture`、`ops` 與 `all` 都遵守同一個 helper merge 規則;不得直接編輯 durable `handoff.json`。
|
|
57
|
+
- 若 workspace 中存在尚未合併的 patch JSON,必須以 patch 自身的 `generation_scope` / `current_run.scope` 呼叫 `handoff_update.py`;不得用目前 invocation scope 強制套用其他 scope 的 patch,也不得手動轉寫 patch 內容。
|
|
58
|
+
- `handoff_update.py` 負責建立 parent directory、讀取既有 handoff、保留仍有效的 `baseline` 與 prior `scope_deltas`、覆寫 `current_run`、新增或取代同一 scope 的 compact delta,並以 UTF-8 no BOM atomic replace 寫回。不得為了格式、語氣、排序或重新生成偏好重寫整包 history。
|
|
59
|
+
- Queue `last_handoff` 必須更新為 durable path:`.github/artifacts/source-code-to-spec/<target_id>/handoff.json`。若 `generation_scope=baseline`,也必須依 handoff `status` 更新 queue `baseline_status`:`baseline_ready`、`partial`、`blocked` 或 `failed`。
|
|
60
|
+
- 若 selected row `last_handoff` 指向不存在的檔案,該狀況記錄於 `artifact_drift.items`;本次 run 依固定 durable path 重新建立 handoff。
|
|
61
|
+
- `handoff.json` 由 `handoff_path` 欄位記錄;selected output file 的 `CREATED` / `UPDATED` / `UNCHANGED` 判定依 `current_run.doc_file_plan.selected_output_files` 執行。
|
|
62
|
+
- Legacy handoff 若仍使用舊版 top-level `knowledge_map_preflight`、`code_verification`、`source_evidence`、`coverage_gaps` 或 `unresolved_items`,本次 run 只抽取可回查的 evidence、reader-facing map、gap 與 unresolved context 轉入 compact shape;不得把舊版長篇 prose 或重複 history 原樣搬入 `scope_deltas`。
|
|
152
63
|
|
|
153
64
|
## Review Use
|
|
154
65
|
|
|
155
|
-
Handoff 作為 generation-to-review 的 evidence / status ledger。Review target resolution、selected row `document_path` 掃描、expected files subset、handoff drift 與 missing selected output 判定,統一由 `source-code-to-spec-reviewer.agent.md` 的 review contract 擁有。
|
|
66
|
+
Handoff 作為 baseline-to-generation 與 generation-to-review 的 evidence / status ledger。Review target resolution、selected row `document_path` 掃描、expected files subset、handoff drift 與 missing selected output 判定,統一由 `source-code-to-spec-reviewer.agent.md` 的 review contract 擁有。
|
|
@@ -14,7 +14,7 @@ description: 定義 source-code-to-spec-documenter 依 docs-target-queue 產生
|
|
|
14
14
|
|
|
15
15
|
- `docs/docs-target-queue.md`:target queue。
|
|
16
16
|
- `id`:選配;若提供,只處理指定 target row。
|
|
17
|
-
- `scope`:`all`、`foundation`、`architecture` 或 `ops`。
|
|
17
|
+
- `scope`:`baseline`、`all`、`foundation`、`architecture` 或 `ops`。
|
|
18
18
|
- `doc_profile`:取自 selected row;可用值與語意由 `source-code-to-spec-tools/references/target-queue-schema-contract.md` 擁有。
|
|
19
19
|
- `source-code-to-spec-tools` public CLI:用於 target lookup、catalog lookup 與 source evidence lookup。
|
|
20
20
|
- `$source-code-to-ops-spec-guidelines`:三份 ops SPEC 文件的 content contract 與 quality gate。
|
|
@@ -23,28 +23,33 @@ description: 定義 source-code-to-spec-documenter 依 docs-target-queue 產生
|
|
|
23
23
|
|
|
24
24
|
Target SPEC 文件一律寫入 selected row 的 `document_path`。檔名必須以 selected row `name` / 功能名稱作為開頭,不使用 target row `id`,格式如下:
|
|
25
25
|
|
|
26
|
-
| scope
|
|
27
|
-
|
|
|
28
|
-
| `
|
|
26
|
+
| scope | selected output file |
|
|
27
|
+
| -------------- | ---------------------------------------------------------------- |
|
|
28
|
+
| `baseline` | 不產生 target-facing SPEC 文件;只建立或刷新 durable handoff |
|
|
29
|
+
| `foundation` | `{document_path}/{name}-01-document-foundation-and-business.md` |
|
|
29
30
|
| `architecture` | `{document_path}/{name}-02-core-architecture-flow-data-logic.md` |
|
|
30
|
-
| `ops`
|
|
31
|
+
| `ops` | `{document_path}/{name}-03-error-ops-scenario-coverage.md` |
|
|
31
32
|
|
|
32
|
-
`all` scope
|
|
33
|
+
`all` scope 必須規劃以上三份 target-facing 文件。`baseline` scope 的 `current_run.doc_file_plan.selected_output_files` 必須是空陣列,並可在 `baseline.doc_file_plan.planned_output_files` 記錄後續 `01` / `02` / `03` 預期輸出。若 queue row 的 `name` 與 `id` 或 source index id 不一致,target-facing filename 仍以 `name` / 功能名稱為準,差異只記錄在 handoff、review note 或 unresolved items。
|
|
33
34
|
|
|
34
35
|
## Strict Output Boundary
|
|
35
36
|
|
|
36
|
-
Generation run 只允許寫入 `doc_file_plan.selected_output_files` 列出的 target-facing SPEC 文件,以及 workflow-required
|
|
37
|
+
Generation run 只允許寫入 `current_run.doc_file_plan.selected_output_files` 列出的 target-facing SPEC 文件,以及 workflow-required durable handoff:
|
|
38
|
+
|
|
39
|
+
- `.github/artifacts/source-code-to-spec/<target_id>/handoff.json`
|
|
40
|
+
|
|
41
|
+
`baseline` scope 不允許寫入任何 target-facing `docs/**/*.md` 檔案。不得因 `## Obsidian Links`、sibling links、catalog links、system overview links、group name、target name、queue row name 或 final response 需要,而額外建立 index note、landing note、folder note、link placeholder、catalog summary 或任何未列入 `current_run.doc_file_plan.selected_output_files` 的 `docs/**/*.md` 檔案。
|
|
37
42
|
|
|
38
43
|
若發現需要補充導覽文件、system overview、catalog、queue 或相關 note,僅在 generated SPEC 的 `## Obsidian Links`、handoff `unresolved_items` 或 final response 中記錄建議;該 generation run 不得順手建立。Reference guideline 只作為規則套用,不輸出成 target-facing doc。
|
|
39
44
|
|
|
40
45
|
## Artifact Consistency Preflight
|
|
41
46
|
|
|
42
|
-
在建立 `doc_file_plan` 前,必須檢查 selected row 的 artifact state,並把 queue status 與實際檔案存在性分開處理:
|
|
47
|
+
在建立 `current_run.doc_file_plan` 前,必須檢查 selected row 的 artifact state,並把 queue status 與實際檔案存在性分開處理:
|
|
43
48
|
|
|
44
49
|
- 檢查 selected row `document_path` 是否存在,以及三份 target SPEC 檔案是否存在。
|
|
45
|
-
- 檢查 selected row `last_handoff`
|
|
46
|
-
- 若 queue 顯示某份 doc status 為 `generated`,但對應 selected output file 不存在,記錄為 `artifact_drift`,本次以實際檔案狀態建立 `doc_file_plan` 與 file action,不以 stale status 通過 completion gate。
|
|
47
|
-
- 若 `last_handoff` 指向不存在的路徑,記錄為 `artifact_drift` 或 `unresolved_items`,並依 `generation-handoff-contract.md` 的 `Write Discipline` 建立新的最小 handoff baseline。
|
|
50
|
+
- 檢查 selected row `last_handoff` 是否為可讀檔案;`last_handoff` 應指向 `.github/artifacts/source-code-to-spec/<target_id>/handoff.json` durable handoff。若 queue 指向的 `last_handoff` 不存在,不得把它當成可刪除或可復用的 baseline。
|
|
51
|
+
- 若 queue 顯示某份 doc status 為 `generated`,但對應 selected output file 不存在,記錄為 `artifact_drift`,本次以實際檔案狀態建立 `current_run.doc_file_plan` 與 file action,不以 stale status 通過 completion gate。
|
|
52
|
+
- 若 `last_handoff` 指向不存在的路徑,記錄為 `artifact_drift` 或 `unresolved_items`,並依 `generation-handoff-contract.md` 的 `Initial Template` / `Write Discipline` 建立新的最小 handoff baseline。
|
|
48
53
|
- 若現有 artifact state 與 queue status 不一致,但 selected output file 可由目前 source evidence 重新建立或更新,繼續 generation;若不一致阻擋 target boundary 或 source tracing,將 handoff `status` 設為 `blocked` 或 `partial`,並同步更新 queue status。
|
|
49
54
|
|
|
50
55
|
## Reader-Facing Naming Gate
|
|
@@ -55,7 +60,7 @@ Target row `id` 只可用於 queue selection、handoff path / JSON、review note
|
|
|
55
60
|
|
|
56
61
|
### Reader-Facing Name Resolution
|
|
57
62
|
|
|
58
|
-
在 `Knowledge Map Preflight` 完成後、建立或更新 selected output file 前,必須從 selected row、candidate related rows、confirmed `handoff_edge` rows、既有 handoff 與 catalog handoff 建立 `reader_facing_name_map`。此 map 只用來防止 final SPEC 誤用 queue lookup id;它不是新的 reader-facing metadata。
|
|
63
|
+
在 `Knowledge Map Preflight` 完成後、建立或更新 selected output file 前,必須從 selected row、candidate related rows、confirmed `handoff_edge` rows、既有 handoff 的 compact baseline 與 catalog handoff 建立 `reader_facing_name_map`。此 map 只用來防止 final SPEC 誤用 queue lookup id;它不是新的 reader-facing metadata。
|
|
59
64
|
|
|
60
65
|
`reader_facing_name_map` 至少包含:
|
|
61
66
|
|
|
@@ -63,54 +68,100 @@ Target row `id` 只可用於 queue selection、handoff path / JSON、review note
|
|
|
63
68
|
- 每筆被寫入文件或 handoff summary 的 related row / downstream target 的 `id`、`name`、`entrypoint`、`relation` 與 `display_label`。
|
|
64
69
|
- 若只知道 row `id` 而無法確認 `name`、source-backed job/API/handler/batch name 或其他可讀 label,`display_label` 必須是 `Unresolved`,final SPEC 不得輸出該 row `id` 代稱功能。
|
|
65
70
|
|
|
66
|
-
任何 generation run、rerun 或 handoff reuse 都必須先做 Reader-Facing Name Normalization,再開始撰寫 selected output file。既有 handoff
|
|
71
|
+
任何 generation run、rerun 或 handoff reuse 都必須先做 Reader-Facing Name Normalization,再開始撰寫 selected output file。既有 handoff 的 `baseline.related_rows`、`baseline.relation_candidates`、prior `scope_deltas`、review note 或舊版 handoff summary 中的 `id` 只能作為 lookup key;documenter 必須用 current queue / catalog / source evidence 重新對齊 `reader_facing_name_map.display_label`。若既有 handoff 缺少 `reader_facing_name_map`、某筆 related row 沒有 `name` / `display_label`,或舊資料只剩 raw row `id`,該 baseline 對 reader-facing wording 視為不完整:先補 map、標示 `Unresolved`,或把缺口寫入 handoff,不得直接把 raw `id` 寫入 selected output file。
|
|
67
72
|
|
|
68
|
-
寫作時應建立 render-only context:每個 selected row、related row、downstream target、Mermaid participant、sibling reference 與 cross-reference 都先用 `id` 查 `reader_facing_name_map`,再輸出 `display_label` 或 source-backed technical identifier。禁止把 `related_rows[].id`、`relation_candidates[].id`、`last_handoff` path segment 或 target folder name 當成可顯示名稱。
|
|
73
|
+
寫作時應建立 render-only context:每個 selected row、related row、downstream target、Mermaid participant、sibling reference 與 cross-reference 都先用 `id` 查 `reader_facing_name_map`,再輸出 `display_label` 或 source-backed technical identifier。禁止把 `baseline.related_rows[].id`、`baseline.relation_candidates[].id`、prior `scope_deltas[].id`、`last_handoff` path segment 或 target folder name 當成可顯示名稱。
|
|
69
74
|
|
|
70
75
|
寫入 selected output file 時,所有自然語言主語、cross-reference、sibling 文件關係、Mermaid participant alias、ERD 補充表、圖表文字說明、狀態 mapping、維護注意事項、監控指標與 troubleshooting 敘述,必須使用 `reader_facing_name_map.display_label` 或 source-backed technical identifier。不得把 `F1`、`F2`、`J2` 這類 queue row `id` 當成 display label;`MENU_ID:555`、`REQUEST_HEADER_ID`、`DPK_ID`、SQL ID、API path、table / column name、job class name 等 technical identifiers 只有在對應章節具維運用途時才可保留。
|
|
71
76
|
|
|
72
|
-
寫入 handoff 前必須重新掃描本次 `doc_file_plan.selected_output_files` 的 reader-facing content。若發現 known queue row `id` 仍以功能、job、target、participant、狀態主語或 cross-reference label 出現,必須先修正 selected output file;不得把對應 file action 回報為 `UNCHANGED`,也不得將對應 doc status 設為 `generated`。
|
|
77
|
+
寫入 handoff 前必須重新掃描本次 `current_run.doc_file_plan.selected_output_files` 的 reader-facing content。若發現 known queue row `id` 仍以功能、job、target、participant、狀態主語或 cross-reference label 出現,必須先修正 selected output file;不得把對應 file action 回報為 `UNCHANGED`,也不得將對應 doc status 設為 `generated`。
|
|
73
78
|
|
|
74
79
|
## Scope Roles
|
|
75
80
|
|
|
76
81
|
各 generation prompt 的角色如下:
|
|
77
82
|
|
|
78
|
-
| prompt
|
|
79
|
-
|
|
|
80
|
-
| `00-
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
83
|
+
| prompt | role |
|
|
84
|
+
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `00-discover-target-baseline.prompt.md` | `baseline discovery only`;建立或刷新 shared handoff,登記 entrypoint evidence、visible subfunctions、relation candidates、unmapped behaviors、coverage gaps 與 `not_checked`,不產生 target-facing SPEC 文件。 |
|
|
86
|
+
| `00-generate-target-all-spec.prompt.md` | `foundation + discovery baseline + architecture + ops`;一次產生或更新三份文件,並建立或刷新完整 shared durable handoff。 |
|
|
87
|
+
| `01-generate-target-foundation-spec.prompt.md` | `foundation + consume/update discovery baseline`;優先復用 `00-discover-target-baseline` 的 shared handoff,產生第 1 份文件。若 baseline 不存在,只建立最小 baseline 並揭露 `not_checked` / unresolved items。 |
|
|
88
|
+
| `02-generate-target-architecture-spec.prompt.md` | `architecture + reuse/update handoff`;復用既有 baseline,再針對 architecture evidence 做增量追蹤與更新。 |
|
|
89
|
+
| `03-generate-target-ops-spec.prompt.md` | `ops + reuse/update handoff`;復用既有 baseline,再針對 error / ops / scenario coverage 做增量追蹤與更新。 |
|
|
84
90
|
|
|
85
|
-
`00`
|
|
91
|
+
`00-discover-target-baseline` 是 rate-limited 或大型 target 的建議前置,但不是每個 target 的必跑前置。成本敏感或 target 邊界已足夠明確時,可以直接從 `01` 開始,再執行 `02` / `03`。只有建立新 baseline 或修復 missing / legacy baseline 時,才載入 `references/handoff-initial-template.json`。若 `01`、`02` 或 `03` 發現缺少 handoff,必須用該 template 建立最小 discovery baseline 並記錄 limitation,不得只因 baseline 不存在就跳過 source tracing。
|
|
86
92
|
|
|
87
93
|
## Handoff Baseline Contract
|
|
88
94
|
|
|
89
|
-
Shared handoff 是 scoped generation
|
|
95
|
+
Shared handoff 是 scoped generation 之間的 compact evidence ledger,不是最終文件內容,也不是 source tracing completion proof。`00-discover-target-baseline` 只建立或刷新 baseline;`00-generate-target-all-spec` 建立 baseline 並把三份文件的成果寫入 scope deltas;`01` 優先復用 baseline 並產 foundation,必要時建立最小 baseline;`02` 與 `03` 必須復用 baseline,並只針對本次 scope 新增或修正 delta。
|
|
90
96
|
|
|
91
97
|
Baseline 至少包含:
|
|
92
98
|
|
|
93
|
-
- selected target row、`entrypoint`、`generation_scope`、`doc_profile` 與 `doc_file_plan`。
|
|
94
|
-
- `
|
|
95
|
-
- 可重讀的 `
|
|
96
|
-
- downstream relation classification
|
|
97
|
-
|
|
99
|
+
- selected target row、`entrypoint`、`generation_scope`、`doc_profile` 與 `baseline.doc_file_plan`。
|
|
100
|
+
- `reader_facing_name_map`、依 `source-tracing-rules.md` 判定成立的 compact `handoff_edge` related rows、coverage hints、target boundary decision 與 search priority。
|
|
101
|
+
- 可重讀的 direct `EvidenceRef[]`,只保留定位 entrypoint、source map 與 relation classification 所需的最小 evidence。
|
|
102
|
+
- downstream relation classification、unmapped behavior index、baseline-level `coverage_gaps` 與 `unresolved_items`。
|
|
103
|
+
|
|
104
|
+
Scope delta 至少包含:
|
|
105
|
+
|
|
106
|
+
- 本次 `generation_scope`、`status`、`current_run.doc_file_plan.selected_output_files`、`generated_files`、`file_actions` 與 `change_justification`。
|
|
107
|
+
- 本次實際檢查的 `evidence_checked`、新增或修正的 `source_evidence: EvidenceRef[]`、仍需後續追蹤的 `not_checked`、`coverage_gaps` 與 `unresolved_items`。
|
|
108
|
+
- 必要時保存本次發現的 `map_drift` / `artifact_drift` reference,但不要複製整份 baseline map。
|
|
109
|
+
|
|
110
|
+
`baseline` scope 的 handoff 必須額外遵守:
|
|
98
111
|
|
|
99
|
-
|
|
112
|
+
- `current_run.doc_file_plan.selected_output_files=[]`,不得建立或更新 target-facing SPEC 文件。
|
|
113
|
+
- `generated_files=[]`、`file_actions=[]`,除非未來 contract 另行定義 baseline-specific action。
|
|
114
|
+
- `status` 使用 `baseline_ready`、`partial`、`blocked` 或 `failed`;若主要 entrypoint 尚未驗證或仍有 completion-critical `not_checked`,不得使用 `baseline_ready`。
|
|
115
|
+
- queue 只可更新 `baseline_status` 與 `last_handoff`;`last_handoff` 必須是 durable path `.github/artifacts/source-code-to-spec/<target_id>/handoff.json`。不得更新 `foundation_doc_status`、`architecture_doc_status`、`ops_doc_status`、`review_status` 或 `document_completed_flag(Y/N)`。
|
|
116
|
+
- visible subfunctions、direct links、form actions、popup、AJAX、include、downstream candidate 或 unmapped behavior 不得因 bounded tracing 被丟棄;必須寫入 `relation_candidates`、`unmapped_behaviors_found`、`coverage_gaps` 或 `unresolved_items`。
|
|
100
117
|
|
|
101
|
-
|
|
118
|
+
`01` 產出的 foundation delta 若因 rate limit 或 bounded tracing 未追完,不得把缺少的 downstream、DAO、SQL、error / ops evidence 寫成已確認不存在。這些項目必須保留在 `current_run.not_checked`、`current_run.coverage_gaps` 或 `current_run.unresolved_items`,供 `02` / `03` 強制 follow-up。
|
|
119
|
+
|
|
120
|
+
若復用的 baseline 來自舊版 workflow 或缺少 `reader_facing_name_map`,只能抽取可回查的 evidence 與 unresolved/gap context;不得復用其中的 reader-facing label,也不得把舊版 prose/history 原樣搬入新版 `scope_deltas`。任何 selected output file 寫入前,都必須用 current queue row、catalog handoff 與必要的 `target_query.py related` 重新建立 map。
|
|
121
|
+
|
|
122
|
+
Scoped prompt 更新 handoff 時,應保留 baseline 中仍符合 source evidence 的 compact index,只追加或修正本次 scope delta 的 evidence、file action、gap 與 unresolved item;不得為了風格、排序、摘要或重新生成偏好覆蓋整份 handoff。後續 scope 只需要讀取 baseline、current scope 所需的 prior deltas、以及仍 open 的 `not_checked` / `coverage_gaps` / `unresolved_items`,不得把所有歷史 delta 當作寫作材料。
|
|
102
123
|
|
|
103
124
|
Handoff 寫入語意由 `generation-handoff-contract.md` 的 `Write Discipline` 擁有;本 workflow 只負責在正確流程點觸發 handoff create-or-update,並將 artifact drift、file actions、evidence 與 unresolved items 交給 handoff contract 序列化。
|
|
104
125
|
|
|
126
|
+
## Handoff Patch And Queue Sync Gate
|
|
127
|
+
|
|
128
|
+
每次 baseline / generation run 都只更新同一份 durable handoff:`.github/artifacts/source-code-to-spec/<target_id>/handoff.json`。本次 run 準備的是 patch JSON,不是另一份正式 handoff。Patch JSON 的 root `generation_scope` 與 `current_run.scope` 必須等於本次 invocation scope,並與 `handoff_update.py --scope` 完全一致;不得重用其他 scope 的 patch JSON。
|
|
129
|
+
|
|
130
|
+
Handoff update 成功後,必須立即同步 selected row 的 queue status。Queue sync 是 handoff 寫入後的 required gate,不是 final response 的建議事項;若 queue update 或 reselect 驗證失敗,本次 run 不得宣告 `docs/docs-target-queue.md` 已更新。
|
|
131
|
+
|
|
132
|
+
進入目前 scope 前,若發現同一 target 已有前序或本次 pending patch JSON,但 durable `handoff.json` 尚未包含該 patch 對應的 scope delta / `current_run` 狀態,必須先依 patch 內的 root `generation_scope` 或 `current_run.scope` 執行 `handoff_update.py`。不得把該 patch 內容手動複製進 `handoff.json`,也不得在未 merge 的狀態下讓後續 scope 依 stale handoff 繼續。前序 patch merge 成功後,也必須依該 patch scope 執行 queue sync / reselect;再回到目前 invocation scope。
|
|
133
|
+
|
|
134
|
+
Baseline scope 使用:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/handoff_update.py update --handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json --target-id <target_id> --scope baseline --patch <patch-json>
|
|
138
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py update --queue docs/docs-target-queue.md --id <target_id> --baseline <baseline_ready|partial|blocked|failed> --last-handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json
|
|
139
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py select --queue docs/docs-target-queue.md --id <target_id> --scope baseline
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Non-baseline scope 使用同一個 durable handoff path,並只更新本次 scope 擁有的 doc status。`<doc_status>` 依 `target-queue-contract.md` 使用 `generated`、`n/a`、`partial`、`blocked` 或 `failed`;`<completed_flag>` 必須由 selected row `document_path` 下三份 target SPEC 文件的實際存在性決定。下列 `--foundation`、`--architecture`、`--ops` queue update commands 是依本次 scope 擇一執行,不是同一 scoped run 全部執行。
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/handoff_update.py update --handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json --target-id <target_id> --scope <foundation|architecture|ops> --patch <patch-json>
|
|
146
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py update --queue docs/docs-target-queue.md --id <target_id> --foundation <doc_status> --review <pending|blocked> --completed <Y|N> --last-handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json
|
|
147
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py update --queue docs/docs-target-queue.md --id <target_id> --architecture <doc_status> --review <pending|blocked> --completed <Y|N> --last-handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json
|
|
148
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py update --queue docs/docs-target-queue.md --id <target_id> --ops <doc_status> --review <pending|blocked> --completed <Y|N> --last-handoff .github/artifacts/source-code-to-spec/<target_id>/handoff.json
|
|
149
|
+
python -B .github/skills/source-code-to-spec-documenter/scripts/spec_queue.py select --queue docs/docs-target-queue.md --id <target_id> --scope <foundation|architecture|ops>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`all` scope 仍只寫同一份 durable handoff,但 queue sync 必須同時更新 `--foundation`、`--architecture` 與 `--ops` 的狀態,並用同一個 reselect 驗證 selected row。Final response 必須回報 reselect 後的 queue status;不得只回報 handoff update 結果。
|
|
153
|
+
|
|
154
|
+
Documenter 不得直接編輯 durable `handoff.json` 來替代 `handoff_update.py` merge。若 patch JSON 已準備完成但 helper 尚未成功執行,本次 scope 的 handoff update 視為未完成;不得只靠手動修改、final response 或 queue status 宣告已同步。
|
|
155
|
+
|
|
105
156
|
## Output Action Contract
|
|
106
157
|
|
|
107
|
-
`doc_file_plan` 內的 selected output file 使用 create-or-update 語意:
|
|
158
|
+
`current_run.doc_file_plan` 內的 selected output file 使用 create-or-update 語意:
|
|
108
159
|
|
|
109
160
|
- 若 selected output file 尚未存在,先完成 source tracing 與 guideline gate,再新增該文件。
|
|
110
161
|
- 若 selected output file 已存在,必須先依 `source-tracing-rules.md` 執行 Existing Output Reconciliation、Idempotent Update Gate 與 Code Verification Pass,比對目前 source code、queue / catalog handoff、related rows、既有 handoff 與本次 scope。
|
|
111
162
|
- 只有當既有文件與目前 source evidence 不符、缺少本次 `doc_profile` / `generation_scope` 必要內容,或結構錯誤影響可審查性時,才補充修正。若沒有 material difference,保留既有內容並回報 `UNCHANGED`。
|
|
112
163
|
- 修改既有文件時,只 patch 受影響章節;不要為了風格、語氣或同義改寫重建整份文件。
|
|
113
|
-
- 任何不在 `doc_file_plan.selected_output_files` 的 `docs/**/*.md` 檔案都不是本次 generation 的合法 create-or-update target;若已被錯誤建立,必須回報為 contract violation,不得寫入 `generated_files` 或用它通過 completion gate。
|
|
164
|
+
- 任何不在 `current_run.doc_file_plan.selected_output_files` 的 `docs/**/*.md` 檔案都不是本次 generation 的合法 create-or-update target;若已被錯誤建立,必須回報為 contract violation,不得寫入 `generated_files` 或用它通過 completion gate。
|
|
114
165
|
|
|
115
166
|
## Detail And Summary Contract
|
|
116
167
|
|
|
@@ -124,10 +175,10 @@ Target SPEC generation 的內容優先順序是完整、準確、source-backed
|
|
|
124
175
|
|
|
125
176
|
`00-generate-target-all-spec.prompt.md` / `generation_scope=all` 必須對三份 selected output file 分別通過 full-depth gate。`foundation`、`architecture` 與 `ops` 是 sibling docs,不可用其中一份的詳細章節、handoff summary、Final Response 或 reviewer note 代替另一份文件在本 scope 內應保留的 source-backed detail。
|
|
126
177
|
|
|
127
|
-
對 `doc_file_plan` 內每一份 selected output file,將對應 doc status 設為 `generated`,或將 file action 回報為 `UPDATED` / `UNCHANGED` 前必須確認:
|
|
178
|
+
對 `current_run.doc_file_plan` 內每一份 selected output file,將對應 doc status 設為 `generated`,或將 file action 回報為 `UPDATED` / `UNCHANGED` 前必須確認:
|
|
128
179
|
|
|
129
180
|
- 本次 `Knowledge Map Preflight`、`Code Verification Pass` 與 `Expansion Search` 已發現、且屬於該文件正式 scope 的 source-backed behavior、SQL、DAO / Repository / Mapper mapping、table / status / field mapping、request / response / file / external payload mapping、branch、transaction、rollback、retry/rerun、log、error 與 operations detail,已寫入該 selected output file 的正式章節。
|
|
130
|
-
- 若 `Code Verification Pass` 或 `Expansion Search` 發現 File I/O / Report evidence,且 architecture selected output file 在本次 `doc_file_plan` 內,full-depth gate 必須確認 `02` 的 `6.5 檔案 I/O 規格` 已依 `$source-code-to-ops-spec-guidelines` 產出欄位規格、驗證規則與錯誤輸出;有匯出 / 報表 evidence 時也必須保留資料來源與欄位對應。只在 `6.3`、`03`、summary 或 final response 提及 File I/O 不算通過。
|
|
181
|
+
- 若 `Code Verification Pass` 或 `Expansion Search` 發現 File I/O / Report evidence,且 architecture selected output file 在本次 `current_run.doc_file_plan` 內,full-depth gate 必須確認 `02` 的 `6.5 檔案 I/O 規格` 已依 `$source-code-to-ops-spec-guidelines` 產出欄位規格、驗證規則與錯誤輸出;有匯出 / 報表 evidence 時也必須保留資料來源與欄位對應。只在 `6.3`、`03`、summary 或 final response 提及 File I/O 不算通過。
|
|
131
182
|
- 若 detail 屬於另一份 sibling doc 的正式 scope,該 detail 寫入正確 sibling doc;目前文件只保留必要 cross-reference 或 handoff cue,不複製 sibling doc 的正式章節。
|
|
132
183
|
- 若 detail 屬於具獨立 activation evidence 的 downstream target 內部規格,目前文件完整寫清本 target 的交付資料、狀態與 correlation key;downstream 內部規格只寫 handoff summary 與 cross-reference,完整 `EvidenceRef[]` 保留在 handoff。
|
|
133
184
|
- 若 source evidence 不存在、目前來源不足或已確認不適用,該章節保留標題並以 `N/A`、`無法由目前來源確認` 或 `Unresolved` 說明原因;completion-impacting 缺口同步寫入 handoff `coverage_gaps` 或 `unresolved_items`。
|
|
@@ -139,7 +190,7 @@ Target SPEC generation 的內容優先順序是完整、準確、source-backed
|
|
|
139
190
|
|
|
140
191
|
- 保留可從 source 讀取的完整 SQL excerpt;若 SQL 由條件式或字串組合產生,改以 source-backed pseudo SQL 呈現完整查詢意圖、條件、join、排序、狀態過濾與參數來源。
|
|
141
192
|
- 明確列出 DAO / Repository / Mapper method 到 SQL、table、status column、DB object、stored routine、file resource 或 external resource 的 mapping。
|
|
142
|
-
- 保留 handler / controller / job / service
|
|
193
|
+
- 保留 handler / controller / job / service / template / custom tag / script / procedure / trigger / workflow task / message consumer 到資料存取、外部資源或狀態異動節點的 source-backed flow,包含與維運判斷相關的 branch、transaction、rollback、retry/rerun、log、error message 與 status transition。
|
|
143
194
|
- 若存在 request / response、file column、DB column、status 或 external payload mapping,必須以表格或結構化段落保留欄位對應與轉換規則。
|
|
144
195
|
- 若存在 File I/O / Report 行為,architecture selected output file 的 `6.5` 擁有欄位主規格;ops selected output file 只補維運覆蓋、troubleshooting 與 coverage gaps,不得取代 `02` 的欄位表。
|
|
145
196
|
|
|
@@ -148,31 +199,32 @@ Target SPEC generation 的內容優先順序是完整、準確、source-backed
|
|
|
148
199
|
## 執行流程
|
|
149
200
|
|
|
150
201
|
1. 檢查 repo 狀態並定位 `docs/docs-target-queue.md`。
|
|
151
|
-
2. 使用 `
|
|
202
|
+
2. 使用 `$source-code-to-spec-documenter` Queue Helper 選取 target row;使用 `target_query.py preflight` 取得 selected row、queue summary、coverage 與 related rows。只有 preflight 缺少 related candidates、需要不同 `--limit` / `--include-self`,或需要重新查證 related rows 時,才另外呼叫 `target_query.py related`,並在 handoff 記錄補查目的。
|
|
152
203
|
3. 執行 `Artifact Consistency Preflight`:檢查 selected row `document_path`、三份 target SPEC、`last_handoff` 與實際檔案存在性;若 queue status 與 artifact state 不一致,記錄 `artifact_drift`,並以實際檔案狀態決定 create-or-update,不把 stale `last_handoff` 當成可刪除 baseline。
|
|
153
|
-
4. 執行 `Knowledge Map Preflight`:讀取 selected row、queue supporting tables、catalog handoff、related rows、既有 handoff / docs / review note,整理 source map、known gaps、related rows、coverage hints、trace hypotheses、search priority 與 `reader_facing_name_map
|
|
154
|
-
5. 解析 `generation_scope` 與 `doc_profile`,建立 `doc_file_plan`:
|
|
204
|
+
4. 執行 `Knowledge Map Preflight`:讀取 selected row、queue supporting tables、catalog handoff、related rows、既有 handoff 的 `baseline` / open deltas、既有 docs / review note,整理 source map、known gaps、related rows、coverage hints、trace hypotheses、search priority 與 `reader_facing_name_map`;若 handoff 不存在、缺少 `baseline` 或屬於 legacy shape,才載入 `references/handoff-initial-template.json` 建立最小 baseline patch。若既有 handoff 可用,只讀取 baseline、current scope 所需的 prior deltas 與仍 open 的 gap,不讀 template、不重套 skeleton。若既有 handoff 缺少或污染 reader-facing label,依 Reader-Facing Name Normalization 先重建 map。不要把 prior `scope_deltas` 全量展開成寫作材料,只取本次 scope 需要的 open gaps、related rows 與 evidence refs。
|
|
205
|
+
5. 解析 `generation_scope` 與 `doc_profile`,建立 `current_run.doc_file_plan`:
|
|
206
|
+
- `baseline`:不規劃 target-facing selected output file;`current_run.doc_file_plan.selected_output_files=[]`,只規劃 handoff。
|
|
155
207
|
- `all`:規劃三份文件。
|
|
156
208
|
- `foundation`:只規劃 File Naming Contract 中的 foundation 文件。
|
|
157
209
|
- `architecture`:只規劃 File Naming Contract 中的 architecture 文件。
|
|
158
210
|
- `ops`:只規劃 File Naming Contract 中的 ops 文件。
|
|
159
|
-
- `generation_scope` 只限制 selected output file 與本次 run
|
|
211
|
+
- `generation_scope` 只限制 selected output file 與本次 run 擁有的正式章節,不降低本 scope 內已確認結論的 evidence standard。`baseline` 與 bounded `foundation` 可將深層 source tracing 轉成 `not_checked` / follow-up ledger,但不得把未查項目寫成不存在或不適用;若 downstream job、status transition、staging table 或 external integration 可能接手目前 target 建立的 work item,必須檢查足夠 evidence 或明確登記為 follow-up,並依 `source-tracing-rules.md` 的 `Functional Boundary And Handoff Edges` 分類。若 downstream 有獨立 activation evidence,目前文件完整寫清本 target 的交付資料、狀態與 correlation key,downstream 內部規格只寫 handoff summary 與 cross-reference;完整 `EvidenceRef[]` 保留在 handoff。
|
|
160
212
|
- 本次 scope 內的正式章節應保留章節標題;若章節沒有來源資料、已確認不適用,或目前來源不足以填寫,不產生空表格、空圖表或推測內容,只輸出簡短 `N/A` / `無法由目前來源確認` / `Unresolved` 原因。若該缺口影響 completion,必須寫入 `coverage_gaps` 或 `unresolved_items`。
|
|
161
|
-
6. 讀取 `doc_file_plan` 指定的 existing output、既有 handoff 與 reviewer note,依 `source-tracing-rules.md` 建立 reconciliation context;缺少的 selected output file 標記為待新增,不以空白文件代替 evidence。
|
|
162
|
-
7. 在產生文件前,將本次 scope 對應 status 設為 `in_progress
|
|
163
|
-
8. 執行 `Code Verification Pass` 與 `Expansion Search
|
|
213
|
+
6. 讀取 `current_run.doc_file_plan` 指定的 existing output、既有 handoff baseline / relevant scope deltas 與 reviewer note,依 `source-tracing-rules.md` 建立 reconciliation context;缺少的 selected output file 標記為待新增,不以空白文件代替 evidence。
|
|
214
|
+
7. 在產生文件前,將本次 scope 對應 status 設為 `in_progress`;`baseline` scope 只更新 `baseline_status`,不得更新任何 target-facing doc status。
|
|
215
|
+
8. 執行 `Code Verification Pass` 與 `Expansion Search`:`baseline` scope 只執行 bounded verification,確認 selected row `entrypoint`、direct evidence、visible subfunctions 與 follow-up ledger,不展開完整 target SPEC detail;非 baseline scope 從 selected row 的 `entrypoint` 實際追蹤 handler、flow、data resource、error / security / observability、operation behavior 與 coverage evidence,不得停在高階摘要,必須依 `doc_profile` 保留可審查的 source-backed detail。
|
|
164
216
|
9. 執行 `Map Drift Handling`:若 queue / catalog 與 code evidence 不一致,文件以 source evidence 為準,並在 handoff 記錄 drift、corrections 或需要後續 catalog / queue 修正的 items。
|
|
165
|
-
10. 依 `doc_file_plan`、Output Action Contract、Strict Output Boundary、Reader-Facing Name Normalization 與 `$source-code-to-ops-spec-guidelines` 的必要 reference guideline,新增缺少的 selected output file,或只補充修正與目前 source evidence
|
|
217
|
+
10. 依 `current_run.doc_file_plan`、Output Action Contract、Strict Output Boundary、Reader-Facing Name Normalization 與 `$source-code-to-ops-spec-guidelines` 的必要 reference guideline,新增缺少的 selected output file,或只補充修正與目前 source evidence 不符的既有文件。`baseline` scope 跳過 target-facing writing,只寫 handoff evidence ledger。Reference guideline 只作為規則套用,不輸出成 target-facing doc;writing context 只能使用 `reader_facing_name_map.display_label` 或 source-backed technical identifier,不直接渲染 handoff raw `id`。
|
|
166
218
|
11. 若 `doc_profile=full`,依 Full-Depth Gate 逐檔檢查 selected output file;未通過 gate 的文件不得將對應 doc status 設為 `generated`,也不得回報無缺口的 `UPDATED` / `UNCHANGED`。
|
|
167
219
|
12. 依 `$source-code-to-ops-spec-guidelines` 的 Metadata / naming contract 與本 workflow 的 `Reader-Facing Name Resolution` 檢查 selected output files;未通過時必須修正後才可進入 handoff / queue status 更新。
|
|
168
|
-
13. 依 `source-tracing-rules.md`
|
|
169
|
-
14. 依 `generation-handoff-contract.md` 的 `Write Discipline`
|
|
170
|
-
15. 依 `target-queue-contract.md` 的 generation entrypoint / scope status mapping 更新本次 scope owned doc status
|
|
171
|
-
16. 將結果交給 review workflow;review workflow 只負責後續 `review_status`、findings 與必要 notes
|
|
220
|
+
13. 依 `source-tracing-rules.md` 整理本次 scope 的逐檔 `file_actions`、`change_justification`、`Evidence Checked` / `Not Checked` 與 completion-impacting gaps;這些內容只整理成本次 `current_run` 與必要 root metadata,不得把 prior `scope_deltas` 全量展開成新的寫作材料。
|
|
221
|
+
14. 依 `generation-handoff-contract.md` 的 `Write Discipline` 準備本次 handoff patch JSON,並執行 `Handoff Patch And Queue Sync Gate`。Patch JSON 必須包含 `current_run`,且 root `generation_scope`、`current_run.scope` 與 CLI `--scope` 必須等於本次 invocation scope;若 handoff 不存在或缺少 `baseline`,patch 也必須依 `references/handoff-initial-template.json` 補入 compact `baseline`。`handoff_update.py` 負責保留既有 `baseline`、replace 同一 scope 的 compact delta、覆寫 `current_run`、維持 `handoff_path` / `doc_profile` / `map_drift` / `artifact_drift` / `status`,並以 atomic replace 寫回 durable handoff。Documenter 不得手動重寫整份 `handoff.json`,也不得把 prior deltas 重新摘要成長篇 history。
|
|
222
|
+
15. 依 `target-queue-contract.md` 的 generation entrypoint / scope status mapping 更新本次 scope owned status,並用 `spec_queue.py select` 重新讀取 selected row 驗證更新結果。`baseline` scope 只更新 `baseline_status` 與 durable `last_handoff` path,不更新 target-facing doc status、review status 或 completion flag。每次非 baseline generation run 結束後都必須檢查 selected row `document_path` 下三份 target SPEC 文件是否存在;三份都存在時設定 `document_completed_flag(Y/N)=Y`,否則保持或設定為 `N`。Generation 只可將 `review_status` 設為 `pending` 或 `blocked`;`passed`、`failed`、`waived` 由 review workflow 更新。
|
|
223
|
+
16. 非 baseline generation 將結果交給 review workflow;review workflow 只負責後續 `review_status`、findings 與必要 notes。`baseline` scope 不觸發 review,只在 Final Response 建議下一步執行 `01` / `02` / `03`。
|
|
172
224
|
|
|
173
225
|
## Final Response
|
|
174
226
|
|
|
175
|
-
回報 target id、entrypoint、document root、`doc_profile`、generated files、handoff path、queue status 與下一步 review prompt。若本次 run 建立或修改任何不在 `doc_file_plan.selected_output_files` 的 `docs/**/*.md` 檔案,必須明確列為 contract violation,並要求清理後重跑或 review。
|
|
227
|
+
回報 target id、entrypoint、document root、`doc_profile`、generated files、durable handoff path、reselect 後的 queue status 與下一步 review prompt。`baseline` scope 回報 confirmed evidence、relation candidates、unmapped behaviors、coverage gaps、`not_checked`、durable handoff path 與下一步建議 prompt,不回報 generated files 或 review handoff。若本次 run 建立或修改任何不在 `current_run.doc_file_plan.selected_output_files` 的 `docs/**/*.md` 檔案,必須明確列為 contract violation,並要求清理後重跑或 review。
|
|
176
228
|
|
|
177
229
|
若發現 queue status、`last_handoff` 或 `document_path` 與實際 artifact state 不一致,Final Response 必須回報 `Artifact Drift`,包含受影響 path、實際存在狀態、採取的 create-or-update action,以及是否影響 completion flag。
|
|
178
230
|
|
package/.github/skills/source-code-to-spec-documenter/references/handoff-initial-template.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"handoff_type": "source-code-to-spec-document-generation",
|
|
3
|
+
"target_id": "{target_id}",
|
|
4
|
+
"source_type": "{source_type}",
|
|
5
|
+
"group": "{business_group}",
|
|
6
|
+
"name": "{target_name}",
|
|
7
|
+
"entrypoint": "{entrypoint}",
|
|
8
|
+
"document_root": "docs/feature/{business_group}/{target_name}",
|
|
9
|
+
"generation_scope": "baseline",
|
|
10
|
+
"doc_profile": "standard",
|
|
11
|
+
"selected_coverage_views": [],
|
|
12
|
+
"generation_entrypoint": "baseline-discovery",
|
|
13
|
+
"review_entrypoint": "review-workflow",
|
|
14
|
+
"queue_path": "docs/docs-target-queue.md",
|
|
15
|
+
"handoff_path": ".github/artifacts/source-code-to-spec/{target_id}/handoff.json",
|
|
16
|
+
"baseline": {
|
|
17
|
+
"doc_file_plan": {
|
|
18
|
+
"selected_output_files": [],
|
|
19
|
+
"planned_output_files": [
|
|
20
|
+
"docs/feature/{business_group}/{target_name}/{target_name}-01-document-foundation-and-business.md",
|
|
21
|
+
"docs/feature/{business_group}/{target_name}/{target_name}-02-core-architecture-flow-data-logic.md",
|
|
22
|
+
"docs/feature/{business_group}/{target_name}/{target_name}-03-error-ops-scenario-coverage.md"
|
|
23
|
+
],
|
|
24
|
+
"guideline_reference_set": [],
|
|
25
|
+
"omitted_docs": []
|
|
26
|
+
},
|
|
27
|
+
"queue_status": "loaded",
|
|
28
|
+
"catalog_status": "loaded",
|
|
29
|
+
"reader_facing_name_map": [
|
|
30
|
+
{
|
|
31
|
+
"id": "{target_id}",
|
|
32
|
+
"name": "{target_name}",
|
|
33
|
+
"entrypoint": "{entrypoint}",
|
|
34
|
+
"relation": "selected_target",
|
|
35
|
+
"display_label": "{target_name}"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"related_rows": [],
|
|
39
|
+
"relation_candidates": [],
|
|
40
|
+
"coverage_hints": [],
|
|
41
|
+
"trace_hypotheses": [],
|
|
42
|
+
"search_priority": [],
|
|
43
|
+
"direct_evidence_refs": [],
|
|
44
|
+
"unmapped_behaviors_found": [],
|
|
45
|
+
"coverage_gaps": [],
|
|
46
|
+
"unresolved_items": []
|
|
47
|
+
},
|
|
48
|
+
"scope_deltas": [],
|
|
49
|
+
"current_run": {
|
|
50
|
+
"scope": "baseline",
|
|
51
|
+
"doc_file_plan": {
|
|
52
|
+
"selected_output_files": [],
|
|
53
|
+
"guideline_reference_set": [],
|
|
54
|
+
"omitted_docs": []
|
|
55
|
+
},
|
|
56
|
+
"generated_files": [],
|
|
57
|
+
"file_actions": [],
|
|
58
|
+
"change_justification": [],
|
|
59
|
+
"evidence_checked": [],
|
|
60
|
+
"not_checked": [],
|
|
61
|
+
"source_evidence": [],
|
|
62
|
+
"coverage_gaps": [],
|
|
63
|
+
"unresolved_items": [],
|
|
64
|
+
"status": "baseline_ready"
|
|
65
|
+
},
|
|
66
|
+
"map_drift": {
|
|
67
|
+
"status": "none",
|
|
68
|
+
"items": [],
|
|
69
|
+
"map_corrections": []
|
|
70
|
+
},
|
|
71
|
+
"artifact_drift": {
|
|
72
|
+
"status": "none",
|
|
73
|
+
"items": []
|
|
74
|
+
},
|
|
75
|
+
"status": "baseline_ready"
|
|
76
|
+
}
|