@c4a/context-cli 0.7.0 → 0.7.4

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 (219) hide show
  1. package/README.md +18 -39
  2. package/README.zh-CN.md +13 -27
  3. package/cli.js +59230 -80555
  4. package/indexers/bundles/context-code-indexer/SKILL.md +30 -3
  5. package/indexers/bundles/context-code-indexer/context-indexer.yaml +3 -8
  6. package/indexers/bundles/context-code-indexer/references/indexer.md +110 -7
  7. package/indexers/bundles/context-code-indexer/references/metrics.md +143 -37
  8. package/indexers/bundles/context-code-indexer/templates/adapter-integration.md +2 -2
  9. package/indexers/bundles/context-code-indexer/templates/component-library.md +8 -0
  10. package/indexers/bundles/context-code-indexer/templates/gateway-facade.md +16 -0
  11. package/indexers/bundles/context-markdown-indexer/SKILL.md +13 -3
  12. package/indexers/bundles/context-markdown-indexer/context-indexer.yaml +20 -7
  13. package/indexers/bundles/context-markdown-indexer/references/indexer.md +33 -4
  14. package/indexers/bundles/context-markdown-indexer/references/semantic-planning.md +30 -14
  15. package/indexers/bundles/context-markdown-indexer/references/structure-and-artifacts.md +6 -0
  16. package/indexers/bundles/context-markdown-indexer/tests/fixtures/anonymous.json +1 -1
  17. package/indexers/bundles/context-markdown-indexer/tests/fixtures/profiles.json +13 -13
  18. package/indexers/bundles/context-markdown-indexer/tests/fixtures/routing.json +122 -0
  19. package/indexers/contracts/operator-contract.json +2 -2
  20. package/indexers/contracts/profile-contract.json +3819 -454
  21. package/indexers/release-manifest.json +22 -22
  22. package/package.json +13 -3
  23. package/plugins/VERSION +1 -1
  24. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  25. package/plugins/claude/commands/context.md +44 -85
  26. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  27. package/plugins/codex/skills/context/SKILL.md +44 -85
  28. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  29. package/plugins/cursor/commands/c4a-context.md +44 -85
  30. package/plugins/skills/context/SKILL.md +44 -85
  31. package/plugins/skills/context-code-indexer/SKILL.md +30 -3
  32. package/plugins/skills/context-code-indexer/context-indexer.yaml +3 -8
  33. package/plugins/skills/context-code-indexer/references/indexer.md +110 -7
  34. package/plugins/skills/context-code-indexer/references/metrics.md +143 -37
  35. package/plugins/skills/context-code-indexer/templates/adapter-integration.md +2 -2
  36. package/plugins/skills/context-code-indexer/templates/component-library.md +8 -0
  37. package/plugins/skills/context-code-indexer/templates/gateway-facade.md +16 -0
  38. package/plugins/skills/context-markdown-indexer/SKILL.md +13 -3
  39. package/plugins/skills/context-markdown-indexer/context-indexer.yaml +20 -7
  40. package/plugins/skills/context-markdown-indexer/references/indexer.md +33 -4
  41. package/plugins/skills/context-markdown-indexer/references/semantic-planning.md +30 -14
  42. package/plugins/skills/context-markdown-indexer/references/structure-and-artifacts.md +6 -0
  43. package/plugins/skills/context-markdown-indexer/tests/fixtures/anonymous.json +1 -1
  44. package/plugins/skills/context-markdown-indexer/tests/fixtures/profiles.json +13 -13
  45. package/plugins/skills/context-markdown-indexer/tests/fixtures/routing.json +122 -0
  46. package/providers/context/actions/advance-current-indexer-lifecycle.yaml +6 -0
  47. package/providers/context/actions/configure-indexer-providers.yaml +1 -1
  48. package/providers/context/actions/materialize-indexer-workset-view.yaml +7 -0
  49. package/providers/context/actions/run-indexer-lifecycle.yaml +7 -0
  50. package/providers/context/actions/run-indexer-post-author-composer.yaml +1 -1
  51. package/providers/context/codes.yaml +9 -49
  52. package/providers/context/graphs/indexer.yaml +75 -592
  53. package/providers/context/graphs/workspace.yaml +25 -500
  54. package/providers/context/manifest.json +110 -1199
  55. package/providers/context/provider.yaml +2 -2
  56. package/providers/context/resources/diagnostics/projection-stale.md +0 -1
  57. package/providers/context/resources/dialogue/human-gates.md +3 -3
  58. package/providers/context/resources/manuals/reference/package-templates.md +2 -3
  59. package/providers/context/resources/manuals/reference/project-api.md +52 -985
  60. package/providers/context/resources/procedures/close-and-build.md +8 -23
  61. package/providers/context/resources/procedures/knowledge-review.md +13 -4
  62. package/providers/context/resources/procedures/source-capture-detailed.md +6 -8
  63. package/providers/context/resources/views/authorized-indexer-workset-view.yaml +15 -0
  64. package/providers/context/resources/views/package-current.yaml +1 -1
  65. package/providers/context/resources/views/resolved-indexer-instructions.yaml +1 -1
  66. package/providers/context/resources/views/review-current.yaml +1 -1
  67. package/providers/context/resources/views/source-boundary.yaml +1 -1
  68. package/providers/context/resources/views/source-current.yaml +1 -1
  69. package/providers/context/resources/views/verification-current.yaml +1 -1
  70. package/providers/context/resources/views/workspace-current.yaml +1 -1
  71. package/providers/context/schemas/indexer-agent-step-input.schema.json +2 -2
  72. package/providers/context/schemas/indexer-agent-step-result.schema.json +298 -32
  73. package/providers/context/schemas/indexer-authorized-workset-view.schema.json +65 -0
  74. package/providers/context/schemas/indexer-contract-overlay-validation-input.schema.json +0 -42
  75. package/providers/context/schemas/indexer-contract-overlay-validation-result.schema.json +27 -122
  76. package/providers/context/schemas/indexer-lifecycle-continuation.schema.json +15 -0
  77. package/providers/context/schemas/indexer-main-lifecycle-input.schema.json +13 -20
  78. package/providers/context/schemas/indexer-main-lifecycle-output.schema.json +17 -2
  79. package/providers/context/schemas/indexer-materialized-resource.schema.json +8 -1
  80. package/providers/context/schemas/indexer-overlay-question-proposal-input.schema.json +55 -6
  81. package/providers/context/schemas/indexer-overlay-question-rebind-input.schema.json +4 -4
  82. package/providers/context/schemas/indexer-workset-view-materialization-request.schema.json +32 -0
  83. package/providers/context/skills/configure-indexer-providers/SKILL.md +40 -27
  84. package/providers/context/skills/run-indexer-agent-step/SKILL.md +34 -8
  85. package/providers/context/skills/run-indexer-lifecycle/SKILL.md +37 -0
  86. package/providers/context/skills/run-indexer-post-author-composer/SKILL.md +38 -9
  87. package/docs/document-optimization.md +0 -82
  88. package/docs/document-optimization.zh-CN.md +0 -70
  89. package/indexers/capability-manifest.json +0 -40
  90. package/indexers/contracts/hard-rule-conformance.json +0 -2644
  91. package/providers/context/actions/accept-main-index-run.yaml +0 -7
  92. package/providers/context/actions/accept-material-answer-run.yaml +0 -7
  93. package/providers/context/actions/accept-post-author-composer-run.yaml +0 -7
  94. package/providers/context/actions/actualize-material-answer-bindings.yaml +0 -8
  95. package/providers/context/actions/align-next.yaml +0 -6
  96. package/providers/context/actions/apply-code-index-guidance.yaml +0 -5
  97. package/providers/context/actions/apply-document-optimization-guidance.yaml +0 -5
  98. package/providers/context/actions/apply-structure-confirmation.yaml +0 -5
  99. package/providers/context/actions/audit-material-gap-state.yaml +0 -8
  100. package/providers/context/actions/audit-projected-artifact-fan-out.yaml +0 -8
  101. package/providers/context/actions/authorize-indexer-contract-overlay.yaml +0 -7
  102. package/providers/context/actions/build-main-index-author-worksets.yaml +0 -7
  103. package/providers/context/actions/build-main-index-catalog-fallback.yaml +0 -7
  104. package/providers/context/actions/build-main-index-partition-worksets.yaml +0 -7
  105. package/providers/context/actions/build-material-question-workset.yaml +0 -7
  106. package/providers/context/actions/build-post-author-composer-worksets.yaml +0 -7
  107. package/providers/context/actions/build-question-target-inventory.yaml +0 -7
  108. package/providers/context/actions/build-subject-catalog.yaml +0 -7
  109. package/providers/context/actions/build-target-resolution-views.yaml +0 -7
  110. package/providers/context/actions/checkpoint-material-answer-review.yaml +0 -8
  111. package/providers/context/actions/checkpoint-material-gaps.yaml +0 -8
  112. package/providers/context/actions/close-indexer-approved-knowledge.yaml +0 -8
  113. package/providers/context/actions/compile-next.yaml +0 -5
  114. package/providers/context/actions/compose-indexer-post-author-fragments.yaml +0 -7
  115. package/providers/context/actions/configure-code-extraction.yaml +0 -5
  116. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -5
  117. package/providers/context/actions/converge-main-index-partition-run.yaml +0 -7
  118. package/providers/context/actions/evaluate-material-gaps.yaml +0 -8
  119. package/providers/context/actions/extract-next.yaml +0 -5
  120. package/providers/context/actions/fail-main-index-run.yaml +0 -7
  121. package/providers/context/actions/fail-material-answer-run.yaml +0 -7
  122. package/providers/context/actions/fail-post-author-composer-run.yaml +0 -7
  123. package/providers/context/actions/inspect-code-extraction.yaml +0 -5
  124. package/providers/context/actions/inspect-document-classification.yaml +0 -5
  125. package/providers/context/actions/inspect-index-candidate-review-readiness.yaml +0 -8
  126. package/providers/context/actions/inspect-index-profile-failure.yaml +0 -7
  127. package/providers/context/actions/inspect-material-answer-review.yaml +0 -8
  128. package/providers/context/actions/inspect-structure.yaml +0 -5
  129. package/providers/context/actions/migrate-codeindex.yaml +0 -5
  130. package/providers/context/actions/observe-main-index-run-ledger.yaml +0 -7
  131. package/providers/context/actions/observe-material-answer-runs.yaml +0 -7
  132. package/providers/context/actions/observe-post-author-composer-worksets.yaml +0 -7
  133. package/providers/context/actions/optimize-documents.yaml +0 -6
  134. package/providers/context/actions/override-index-profile-audit.yaml +0 -7
  135. package/providers/context/actions/prepare-main-index-run-ledger.yaml +0 -7
  136. package/providers/context/actions/prepare-material-answer-runs.yaml +0 -7
  137. package/providers/context/actions/preview-extraction-batch.yaml +0 -5
  138. package/providers/context/actions/reconcile-indexer-results.yaml +0 -7
  139. package/providers/context/actions/reconcile-review-identities.yaml +0 -5
  140. package/providers/context/actions/record-index-profile-revision.yaml +0 -7
  141. package/providers/context/actions/report-index-profile-failure.yaml +0 -7
  142. package/providers/context/actions/resolve-effective-composers.yaml +0 -7
  143. package/providers/context/actions/review-material-answer-candidate.yaml +0 -8
  144. package/providers/context/actions/revise-code-index-audit.yaml +0 -5
  145. package/providers/context/actions/revise-document.yaml +0 -5
  146. package/providers/context/actions/revise-index-output.yaml +0 -7
  147. package/providers/context/actions/run-material-answer-indexers.yaml +0 -7
  148. package/providers/context/actions/start-main-index-run.yaml +0 -7
  149. package/providers/context/actions/start-material-answer-run.yaml +0 -7
  150. package/providers/context/actions/start-post-author-composer-run.yaml +0 -7
  151. package/providers/context/actions/submit-code-index-audit.yaml +0 -6
  152. package/providers/context/resources/dialogue/code-extraction.md +0 -87
  153. package/providers/context/resources/dialogue/document-classification.md +0 -33
  154. package/providers/context/resources/dialogue/structure-confirmation.md +0 -44
  155. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +0 -25
  156. package/providers/context/resources/manuals/reference/code-extractors.md +0 -152
  157. package/providers/context/resources/procedures/code-extraction.md +0 -188
  158. package/providers/context/resources/procedures/code-index-audit.md +0 -113
  159. package/providers/context/resources/procedures/document-classification.md +0 -22
  160. package/providers/context/resources/procedures/document-optimization.md +0 -110
  161. package/providers/context/resources/procedures/document-revision.md +0 -36
  162. package/providers/context/resources/procedures/prose-align.md +0 -68
  163. package/providers/context/resources/procedures/prose-compile.md +0 -23
  164. package/providers/context/resources/semantic/align/candidate-resolution.md +0 -106
  165. package/providers/context/resources/semantic/align/density-profile.md +0 -41
  166. package/providers/context/resources/semantic/align/gates.md +0 -276
  167. package/providers/context/resources/semantic/align/structure-planning.md +0 -337
  168. package/providers/context/resources/semantic/code-index/classification.md +0 -270
  169. package/providers/context/resources/semantic/code-index/templates/adapter.md +0 -118
  170. package/providers/context/resources/semantic/code-index/templates/api-service.md +0 -116
  171. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +0 -109
  172. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +0 -129
  173. package/providers/context/resources/semantic/code-index/templates/contract-source.md +0 -73
  174. package/providers/context/resources/semantic/code-index/templates/contracts-and-chains.md +0 -81
  175. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +0 -78
  176. package/providers/context/resources/semantic/code-index/templates/derived-source.md +0 -116
  177. package/providers/context/resources/semantic/code-index/templates/domain-service.md +0 -109
  178. package/providers/context/resources/semantic/code-index/templates/event-flow.md +0 -62
  179. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +0 -124
  180. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +0 -56
  181. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +0 -52
  182. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +0 -88
  183. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +0 -132
  184. package/providers/context/resources/semantic/code-index/templates/web-application.md +0 -145
  185. package/providers/context/resources/semantic/compile/index.md +0 -31
  186. package/providers/context/resources/views/code-index-audit.yaml +0 -6
  187. package/providers/context/resources/views/document-optimization-current.yaml +0 -6
  188. package/providers/context/resources/views/extraction-preview.yaml +0 -6
  189. package/providers/context/resources/views/structure-current.yaml +0 -6
  190. package/providers/context/schemas/code-index-audit-decision.schema.json +0 -94
  191. package/providers/context/schemas/document-optimization-decisions.schema.json +0 -57
  192. package/providers/context/schemas/indexer-candidate-review-readiness-input.schema.json +0 -46
  193. package/providers/context/schemas/indexer-candidate-review-readiness-output.schema.json +0 -104
  194. package/providers/context/schemas/indexer-contract-overlay-authorization-input.schema.json +0 -32
  195. package/providers/context/schemas/indexer-contract-overlay-authorization-result.schema.json +0 -121
  196. package/providers/context/schemas/indexer-material-answer-lifecycle-input.schema.json +0 -90
  197. package/providers/context/schemas/indexer-material-answer-lifecycle-output.schema.json +0 -80
  198. package/providers/context/schemas/indexer-material-answer-review-inspection-input.schema.json +0 -32
  199. package/providers/context/schemas/indexer-material-answer-review-inspection-output.schema.json +0 -32
  200. package/providers/context/schemas/indexer-material-answer-review-resolution-input.schema.json +0 -19
  201. package/providers/context/schemas/indexer-material-answer-review-resolution-output.schema.json +0 -87
  202. package/providers/context/schemas/indexer-material-gap-lifecycle-input.schema.json +0 -86
  203. package/providers/context/schemas/indexer-material-gap-lifecycle-output.schema.json +0 -19
  204. package/providers/context/schemas/indexer-post-author-fragment-result.schema.json +0 -18
  205. package/providers/context/schemas/indexer-post-author-lifecycle-input.schema.json +0 -94
  206. package/providers/context/schemas/indexer-post-author-lifecycle-output.schema.json +0 -72
  207. package/providers/context/schemas/indexer-profile-failure-inspection-input.schema.json +0 -13
  208. package/providers/context/schemas/indexer-profile-failure-inspection-result.schema.json +0 -19
  209. package/providers/context/schemas/indexer-profile-failure-report-input.schema.json +0 -22
  210. package/providers/context/schemas/indexer-profile-failure-report-result.schema.json +0 -49
  211. package/providers/context/schemas/indexer-profile-override-decision.schema.json +0 -20
  212. package/providers/context/schemas/indexer-profile-override-result.schema.json +0 -49
  213. package/providers/context/schemas/indexer-profile-revision-agent-input.schema.json +0 -18
  214. package/providers/context/schemas/indexer-profile-revision-record-input.schema.json +0 -31
  215. package/providers/context/schemas/indexer-profile-revision-record-result.schema.json +0 -45
  216. package/providers/context/schemas/indexer-result-reconciliation-input.schema.json +0 -59
  217. package/providers/context/schemas/indexer-result-reconciliation-output.schema.json +0 -43
  218. package/providers/context/schemas/prose-structure-batch.schema.json +0 -35
  219. package/providers/context/skills/revise-index-output/SKILL.md +0 -12
@@ -1,276 +0,0 @@
1
- ---
2
- id: context.semantic.align.align-gates
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - node_type
7
- - domain
8
- - action
9
- - edges
10
- - tags
11
- ---
12
-
13
- # Node Classification Gates
14
- <!-- Context workflow semantic resource. -->
15
-
16
- Use these gates before every structure draft and before authoring the align
17
- payload described by the current schema view.
18
- Align owns Node type, tag, graph, planned Section, and ownership classification. It does **not** write Section prose.
19
-
20
- Current schema mapping:
21
-
22
- - Treat the action checklist, domain checklist, and inference tables as private
23
- working notes unless the current schema view explicitly exposes matching
24
- fields.
25
- - In `context.structure.v1`, persist the outcome through `node_type`, `tags`,
26
- `summary`, `ownership`, `sections[].source_refs`, `edges[]`, and
27
- `unresolved[]`.
28
- - Do not add unknown gate fields to the payload just because this procedure uses
29
- them for reasoning.
30
-
31
- ## Node Type Order
32
-
33
- Answer in this order and stop at the first match:
34
-
35
- 1. **Action?** A large executable event / process with both:
36
- - scale: can support `planned_sections` with at least two distinct Section kinds, or contains at least one child Action;
37
- - process evidence: explicit steps, phases, trigger -> handling -> result, role collaboration, or repeatable plan. Parallel lists such as "three API modes" are not process evidence.
38
- Single-section user-story / scenario / incident records may be meaningful to
39
- a human reader, but the CLI does not infer that exception from source prose.
40
- If the structure cannot express at least two distinct Section kinds or a
41
- child Action, keep the material as a Section under the owning Node.
42
- 2. **Entity?** A concrete independent subject with retrieval value: deployable code, product/application/system, library/module/CLI/symbol, or an atomic term/pattern.
43
- 3. **Domain?** A container/scope that groups at least one child Node.
44
- 4. Otherwise do not create a Node; leave the material for compile as a Section under the owning Node.
45
-
46
- Good examples:
47
-
48
- | Type | Examples |
49
- |---|---|
50
- | `domain` | "X business domain", "Y technical area", "Z research topic" |
51
- | `entity` concrete | `@acme/api-server`, `@acme/ui-kit` `Button`, "X sub-application" |
52
- | `entity` term | "X identifier", "Y business metric", idempotency |
53
- | `action` | "user submits X request end-to-end flow", "operator executes Y change flow", "team Z release flow" |
54
-
55
- ## Title and Source Heading Rules
56
-
57
- Classify the Node by the evidence referent, not by the source file title, heading, or local section title. A source title is ordinary evidence just like body prose. It has no automatic right to become `node.title`, `aliases[]`, or `slug`.
58
-
59
- After choosing `node_type`, choose the title to fit that type:
60
-
61
- | Final type | Title shape |
62
- |---|---|
63
- | `entity` concrete | The concrete product, service, library, module, CLI, symbol, application, or system name. |
64
- | `entity` term | The atomic concept or pattern name, without extra scope/process suffixes. |
65
- | `domain` | The grouping scope that owns child Nodes. |
66
- | `action` | The executable process / runbook / flow name that passed the Action Gate. |
67
-
68
- Scope/process words in a source title are warning signals when proposed as an Entity title, not hard classification rules. Re-check the type/title when a proposed Entity title contains words such as "方案", "架构", "体系", "演练", "流程", "策略", "能力", "机制", "framework", "architecture", "system", "strategy", "process", or "drill". Keep the wording only when evidence shows it is the formal name of a concrete object or an atomic term.
69
-
70
- Do not promote broad architecture/system/方案 content to `domain` just because it sounds like a scope. When the source has writable Sections but no resolvable current/existing child Nodes, use an Entity such as `[system]` or `[application]` and put the architecture facts in Sections. Use `domain` only when it groups child Nodes through supported `edges[]`.
71
-
72
- Relation-only sources should not force title copying or dangling graph edges. Decide placeholder handling in this order:
73
-
74
- 1. If resolved current/existing child Nodes make the page a real grouping scope, keep the relation evidence as supported `edges[]` only when the Domain also has at least one source-backed planned Section.
75
- 2. If an explicit user-facing retrieval need or graph need makes the source/page identity valuable, and the title names an atomic concept or concrete object, keep that identity in `unresolved[]` until it has source-backed section evidence, a valid generated `parent_index` view with source-backed `contains` edges to child views, or a compile-time `skip` decision. Do not submit root-level `planned_sections: []` or ordinary source-bound `sections: []`.
76
- 3. Otherwise, skip navigation-only / placeholder-only material; keep a short
77
- `unresolved[]` note only when the deferred relation remains useful.
78
-
79
- Do not create a hidden domain-gate object. A kept placeholder needs support:
80
- source refs, approved graph support, or explicit user-confirmed retrieval value.
81
- For Domain placeholders, write only resolved current/existing children as typed
82
- `edges[]`; if all children are unresolved/deferred relation clues, keep those
83
- target hints in `unresolved[]`. If the source names only an atomic concept and
84
- that term is useful on its own, prefer a concise term Entity title without
85
- scope/process suffixes.
86
-
87
- For no-write placeholder summaries, describe only the preserved page identity and unresolved navigation clues. Do not say the Node "provides navigation/links/relations to X" unless those targets are resolved graph children or rendered links; say the source contains deferred navigation clues instead.
88
-
89
- ## Section Promotion Gate
90
-
91
- Classify local evidence as a Section before creating a child Node/View. A
92
- heading, table row, FAQ label, or short sub-topic does not by itself establish a
93
- standalone page.
94
-
95
- Promote a Section to a child View only when at least one condition is supported
96
- by source evidence:
97
-
98
- 1. The title is a concrete product/code object/system/module/library, not just a
99
- local heading.
100
- 2. The item is an atomic term or pattern that answers standalone lookup
101
- questions outside the parent page.
102
- 3. The item clears the Action Gate or Domain Gate.
103
- 4. The source gives it independent article identity: owner/date, lifecycle,
104
- timeline, tracking record, or cross-cutting support scope.
105
-
106
- Use one content-neutral test for every proposed child View: does cited evidence
107
- support an independent subject identity, enough context to stand alone, and a
108
- separate retrieval need? A heading, section kind, collection name, or contains
109
- edge is not sufficient by itself. The CLI warns when many same-source,
110
- single-section child Entities look mechanically fragmented, but it does not
111
- reject a page merely because of its content type.
112
-
113
- ## Entity Tag Rules
114
-
115
- Use `tags` to state what the Entity is. Legal combinations:
116
-
117
- | Case | Tags |
118
- |---|---|
119
- | Runtime/code object | one A tag: `app`, `service`, `lib`, `cli`, `module`, or `symbol` |
120
- | Product-analysis object | one B tag: `application` or `system` |
121
- | Code + product object | one A tag plus one B tag |
122
- | Pure term / pattern | only `term` |
123
-
124
- `term` is mutually exclusive with A/B tags. React is `[lib]`, not `[lib, term]`; if a separate term entry is useful, create another Entity tagged `[term]` and let the structure plan express the relation as a typed edge or unresolved relation with `source_refs[]`.
125
-
126
- Do not inherit scope tags mechanically. If a parent Entity is tagged `system` or
127
- `application`, a child Entity should repeat that tag only when it is itself an
128
- independent system/application. Local aspects under that parent should either
129
- use their own shape tag or remain Sections.
130
-
131
- ## Action Gate
132
-
133
- Use `node_type: action` only after the Node Type Order says action. Fill the
134
- action reasoning checklist in your working notes; persist only fields accepted by
135
- the current structure schema.
136
-
137
- The action probe uses five booleans as a reasoning checklist, but the semantic
138
- bar is:
139
-
140
- | Field | Meaning | Evidence rule |
141
- |---|---|---|
142
- | `has_steps_or_phases` | Process evidence exists: steps, phases, trigger -> handling -> result, role collaboration, or repeatable plan. | Hard requirement; support it from span evidence. |
143
- | `has_actor_or_role` | A user, system, operator, service, or role performs the work. | May be inferred; record the source. |
144
- | `has_outcome_or_goal` | The process has a target result, acceptance condition, or operational goal. | May be inferred; record the source. |
145
- | `is_repeatable_or_planned` | The work is repeatable, scheduled, policy-like, or intentionally planned. | May be inferred; record the source. |
146
- | `queries_answerable_with_refs` | The Node can answer how/when/who/what-to-do questions from cited spans. | May be inferred; record the source. |
147
-
148
- Do not emit an Action for a single sentence, a one-off conclusion, a short operation, or a parallel enumeration. Those become Sections under the owning Entity or Domain. The CLI does not infer single-Section Action exceptions from source prose; represent the material with enough structure or keep it as a Section.
149
-
150
- Action anti-examples:
151
-
152
- | Candidate | Correct routing |
153
- |---|---|
154
- | "migrate to X tool" as one conclusion | `decision` Section under the owning Entity |
155
- | "component X usage" as one sentence | `description` + maybe `example` under X |
156
- | "submit -> validate -> generate" as one unexpanded sentence | `spec` Section under X/Y |
157
- | "three API call modes" | `comparison`, `spec`, or `description` Section; not Action |
158
-
159
- ## Fake Entity Gate
160
-
161
- A relationship-style title is only suspicious by itself. Downgrade or change type when at least **two** signals are true:
162
-
163
- 1. Title contains relationship language such as "X impact on Y", "Y under X", "Y side of X", "X migration", or "X collection".
164
- 2. No legal Entity tag fits.
165
- 3. The Node does not stand alone away from its upstream Node.
166
-
167
- Repairs:
168
-
169
- | Pattern | Repair |
170
- |---|---|
171
- | "X impact on Y" | Section under X plus a typed edge or unresolved relation to Y when the evidence supports it |
172
- | "Y under X condition" | Section under Y; X is a condition in the Section body |
173
- | "X subsystem migration" | Action only if it clears the Action Gate; otherwise `decision` Section under X |
174
- | "X error collection" / "X FAQ collection" | `faq` / `incident` Sections under X |
175
-
176
- ## Domain Gate
177
-
178
- Use `node_type: domain` only for a scope that groups child Nodes. Keep this
179
- domain reasoning checklist in working notes and persist supported relations through current
180
- `edges[]` or `unresolved[]`:
181
-
182
- | Field | Meaning |
183
- |---|---|
184
- | `scope_refs[]` | Source refs that describe the scope boundary or grouping. |
185
- | `child_refs[]` | Working-note candidate ids, local refs, or final slugs for children in the scope; persist valid ones as `edges[]`. |
186
- | `grouping_reason` | Why these children belong together under this domain. |
187
-
188
- If a domain has no resolvable child refs, no clear grouping reason, or only one same-file child without a broader scope, do not emit a Domain. For navigation-only / placeholder-only sources with only deferred children, skip the Node after ruling out standalone retrieval or graph value for an atomic-term or concrete Entity; keep only useful unresolved relation notes. Emit an Entity only when evidence names an atomic term or concrete object and choose its Entity tag yourself. The CLI rejects invalid Domain gates; it does not auto-downgrade a Domain or choose fallback tags.
189
-
190
- Scope-name titles such as "X 业务域", "Y 领域", "business domain", or "technical area" are a warning sign when proposed as Entity. Keep them as Entity only when the subject is an atomic term or concrete object; otherwise use Domain with supported child edges or unresolved relation hints.
191
-
192
- ## Edge Gate
193
-
194
- Use a typed edge only when all four checks pass:
195
-
196
- 1. Both `from` and `to` nodes exist in the current structure or approved
197
- knowledge.
198
- 2. The relation type is in the current closed set (`is_a`, `contains`,
199
- `depends_on`, `corresponds_to`, `causes`, `triggers`, `prerequisite`,
200
- `applies_to`, `verified_by`, `supersedes`).
201
- 3. `source_refs[]` cite evidence for the relation itself, not just for one
202
- endpoint.
203
- 4. The relation is stronger than a vague "related" hint.
204
-
205
- If any check fails, write an `unresolved[]` item instead of an edge.
206
-
207
- If the source sentence states the relation with uncertainty, keep the edge only
208
- when the uncertainty is source-authored and preserved through
209
- `confidence: possible` or `confidence: hypothesis`. Do not use `confidence` for
210
- Agent uncertainty. If you are uncertain whether the evidence supports the
211
- relation, write `unresolved[]` instead.
212
-
213
- ## Inference Sources
214
-
215
- Inference sources are working notes for the action reasoning checklist; do not
216
- persist this object unless the current schema explicitly exposes it:
217
-
218
- ```yaml
219
- inference_sources:
220
- actor:
221
- source_type: explicit-span
222
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
223
- rationale: "The span names the operator role."
224
- outcome_or_goal:
225
- source_type: inferred-from-span
226
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
227
- rationale: "The span describes recovery as the expected result."
228
- repeatability_or_plan:
229
- source_type: heading-and-span
230
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
231
- rationale: "The runbook heading and ordered list indicate planned reuse."
232
- answerability:
233
- source_type: explicit-span
234
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
235
- rationale: "The steps answer how the operation is performed."
236
- ```
237
-
238
- Allowed `source_type` values:
239
-
240
- | Value | Use when |
241
- |---|---|
242
- | `explicit-span` | The evidence span directly states the signal. |
243
- | `heading-and-span` | The heading plus span text together support the signal. |
244
- | `ref-node` | An existing or same-decision Node reference supplies the signal. Include `ref_nodes`. |
245
- | `inferred-from-span` | The signal is inferred from span content. Keep the rationale short and concrete. |
246
-
247
- Each source must include `rationale` when inferred and at least one of `source_refs[]` or `ref_nodes[]`.
248
-
249
- ## Final Reflection
250
-
251
- - Entity cannot pick a legal tag, or depends on its upstream title to make sense -> write it as a Section under the upstream Node or change type before submit.
252
- - Action only supports one Section -> confirm its standalone retrieval value, write it as a Section under its owner, or add another source-backed Section / child Action. Multiple source-backed Sections may use the same kind; the CLI does not manufacture semantic variety to validate an Action.
253
- - Action "steps" are parallel options/configs -> route to Entity `comparison` / `spec` / `description`.
254
- - Domain has no children -> delete it or merge it into a larger Domain.
255
-
256
- ## Current CLI Quality Diagnostics
257
-
258
- Current `context.structure.v1` validation preserves the old Node quality
259
- checks as deterministic diagnostics:
260
-
261
- | Diagnostic | Meaning | Required response |
262
- |---|---|---|
263
- | `schema.section_kind_invalid` | A planned Section uses a kind outside the current prose kind set. | Replace it with a kind from the schema view; do not invent local kind names. |
264
- | `schema.section_kind_mount_invalid` | A planned Section kind cannot be mounted on the chosen `node_type`. | Choose a kind allowed by the mount matrix, or reclassify the Node before confirming structure. |
265
- | `tags.term_conflict` | An Entity uses `term` together with concrete runtime/product tags such as `lib`, `service`, `application`, or `system`. | Split the term from the concrete object, or remove the conflicting tag before staging. |
266
- | `node.description_dominates` | A non-Action Node has at least half of its planned Sections as `description`. | Re-run kind precision. Keep it only when source evidence is genuinely narrative; otherwise split into `example`, `spec`, `comparison`, `faq`, `incident`, `decision`, `warning`, or `principle`. |
267
- | `node.thin_concrete_entity` | A concrete Entity has one Section and no child Nodes. | Keep it only when it has stable standalone retrieval value; otherwise merge it into the owning Node. |
268
- | `node.children_should_be_sections` | One parent contains many same-source, single-section child Entities with no stable shape tag. | Merge those children into parent Sections unless the user confirms each child has standalone lookup value. |
269
- | `node.term_expanded_beyond_definition` | A `term` Entity has grown past a compact definition or owns children. | Move rules, procedures, designs, and examples to the owning Node; keep the term entry narrow. |
270
- | `node.action_too_thin` | An Action has one planned Section and no child Action. | Confirm its standalone retrieval value, keep it as a Section under the owning Node, add another source-backed Section, or add a child Action. This warning does not require artificial Section-kind diversity. |
271
- | `node.domain_without_children` | A Domain has no source-backed `contains` child edge. | Add supported children, keep an explicitly confirmed no-write placeholder, or reclassify the Node. |
272
- | `tags.child_inherits_system` | A child Entity repeats its parent `system` / `application` scope tag. | Retag by the child’s own shape/scope, or keep the child as a Section if it is only a local aspect. |
273
- | `edge.confidence_invalid` | An edge declares a confidence value outside the current schema. | Use only `possible` or `hypothesis`, or omit the field for source-certain relations. |
274
-
275
- Warnings are not automatic blockers, but they are not suggestions to ignore.
276
- Resolve them or include the user-confirmed rationale when confirming structure.
@@ -1,337 +0,0 @@
1
- ---
2
- context_resource: semantic/align/structure-planning
3
- id: context.semantic.align.structure-planning
4
- kind: procedure
5
- media-type: text/markdown
6
- applies-to:
7
- - node_type
8
- - title
9
- - tags
10
- - ownership
11
- - edges
12
- - structure
13
- name: structure-planning
14
- description: "Internal procedure for the current align gate. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits context.structure.v1 payloads for CLI validation/stage."
15
- ---
16
-
17
- # Structure Planning Procedure
18
-
19
- ## TL;DR
20
-
21
- Run `context run align:<type>:<source>:<collection> --view read-plan --format json`, follow the top-level `next_action.command` to read the CLI-selected evidence path, produce a `context.structure.v1` structure payload, and continue following top-level `next_action`. The CLI owns route, validation, repair commands, and stage guards; the Agent owns only semantic classification and source-bound structure judgment.
22
-
23
- <reference>
24
-
25
- ## Canonical Data
26
-
27
- - The current phase view result is authoritative. Branch on `next_action.kind`,
28
- execute `next_action.command`, and treat listed views as detail reads rather
29
- than a checklist.
30
- - `allowed_actions[]` describes capabilities on the current view result; it is
31
- not a menu of alternate write paths and does not override `next_action`.
32
- - `agent_hints[]`, when present, are diagnostics. Do not prefer them over
33
- top-level `next_action`.
34
- - Schema names and enum values come from
35
- `context run align:<type>:<source>:<collection> --view schema --format json`. Use
36
- that schema as the authoring contract for `context.structure.v1`.
37
- - Existing approved knowledge is the lookup registry exposed by the current
38
- align `existing-knowledge` View. Do not read `knowledge/**`, guess a top-level
39
- query command, or create a separate registry file.
40
- - Code projection Nodes are reusable knowledge handles. When document evidence belongs on a code symbol, reuse the code slug instead of creating a parallel document Node.
41
- - Validation diagnostics are the mechanical structure ownership source of
42
- truth. Non-content spans such as navigation references, placeholders, front
43
- matter, marker quotes, embed tags, and embedded assets should not become
44
- reader-facing Sections unless the evidence itself is the cited knowledge.
45
- - When relation hints are present, inspect them before finalizing graph
46
- structure. Use existing/current matches for typed `edges[]`; keep unresolved
47
- target ref/title hints deferred in `unresolved[]` and do not write dangling
48
- parent, child, or edge refs. Ordinary source-bound views require at least one
49
- source-backed planned section. The only empty-section exception is a generated
50
- parent index view: it must use `generated: parent_index`, `sections: []`, and
51
- source-backed `contains` edges to child views. For navigation-only /
52
- placeholder-only sources, keep useful source/page identities as `unresolved[]`
53
- notes until there is source-backed section evidence, a supported edge target,
54
- a valid parent-index container, or a later compile `skip` decision. If a
55
- placeholder/relation source is skipped entirely, leave its relation clues in
56
- `unresolved[]` only when they still matter; otherwise omit them.
57
- - `views[]` and diagnostics distinguish citable evidence from supporting context. Do not promote supporting/context-only material into cited Sections unless a later ownership correction makes it citation-eligible.
58
- - Keep cache-friendly prompt order: fixed protocol/schema first, source evidence
59
- views second, targeted existing-knowledge results third, and the current
60
- semantic payload last. Preserve CLI JSON order and do not add timestamps,
61
- random ids, scratch paths, or host paths to generated payloads.
62
- - Structure digests and snapshot hashes are stale guards. Follow returned
63
- `next_action.command` and do not invent digest values.
64
- - Node type, tag, fake-Entity, `domain`, and `action` gates are in `structure-planning/references/gates.md`.
65
- - Coarse reading density and neutral signal rules are in `structure-planning/references/density-profile.md`.
66
- - Candidate anomaly handling, stable references, duplicate handling, and
67
- conflict handling are in
68
- `structure-planning/references/candidate-resolution.md`.
69
-
70
- </reference>
71
-
72
- <procedures>
73
-
74
- Use this only inside the current align gate.
75
-
76
- ### Step 1 — Start From The Envelope
77
-
78
- Run `context run align:<type>:<source>:<collection> --view read-plan --format json`.
79
- Confirm the response is the current prose align view result, then identify
80
- `next_action`, available views, source metadata, and diagnostics.
81
-
82
- If the host truncates a view result but the preview includes top-level
83
- `next_action.command`, run that command. If `next_action` is not visible, rerun
84
- the current view command; do not recover host tool-result files.
85
-
86
- If no current phase view result is present, stop and surface the CLI output; do
87
- not reconstruct an align route from prior prompt memory.
88
-
89
- ### Step 2 — Follow The Evidence Read Path
90
-
91
- Run the returned `next_action.command`. For structural align work this is
92
- normally `read-plan`; after that, follow the evidence view's `next_action.command`
93
- or `next_command`.
94
-
95
- `read-plan` is the navigation surface. It chooses whether the next evidence read
96
- is `source-index`, `span-detail`, `span-text`, or another current evidence view.
97
- Read those views and then author the requested `context.structure.v1` payload
98
- yourself after completing the targeted lookup in Step 3. Never pipe evidence
99
- text into validate.
100
-
101
- If an evidence view is truncated, `page.has_more: true`, or the CLI returns a
102
- `next_command`, run that command before authoring.
103
-
104
- Read evidence through semantic CLI views, not shell parsing. Follow `page.next_command` for pagination. If the command contains `--read-cursor`, treat it as opaque continuation state and run it exactly; do not replace it with hand-written `--source`, `--heading`, `--window`, or `--range` selectors. Use `--source`, `--heading`, `--window`, `--range`, and `--token-budget` as view filters only. `--unwrap` removes workflow metadata; it does not expand a compact view into full detail.
105
-
106
- If an evidence view returns `page.has_more`, `truncated: true`, or a
107
- view-specific incomplete-read diagnostic, treat that response as a partial
108
- read. Do not decide source-wide ownership or dense planned Sections from
109
- headings alone; continue the current detail view only when `page.next_command`
110
- is explicitly needed, otherwise return to the CLI-designated navigation view.
111
-
112
- ### Step 3 — Reuse Existing Knowledge
113
-
114
- After source evidence identifies a candidate title or stable ref, run:
115
-
116
- ```bash
117
- context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
118
- ```
119
-
120
- Use the returned pagination command when present. Exact title, NodeRef, or
121
- ViewRef hits should usually reuse the existing Node instead of creating a
122
- duplicate candidate. The lookup returns only the best title/NodeRef/ViewRef
123
- identity tier. Shared tag matches are summarized separately and never require
124
- walking the related subgraph merely to determine whether a root identity
125
- exists. The lookup is deterministic identity discovery; the Agent still
126
- decides whether the source evidence describes the same concept.
127
-
128
- When a code projection Node already represents the object, reuse its slug for prose evidence and plan only prose-owned Sections for the current source evidence.
129
-
130
- ### Step 4 — Route Collection, Then Classify Semantic Structure
131
-
132
- Before choosing Node type or Section kind, route each evidence unit to its
133
- internal collection. The phase `<collection>` is only the entry profile for the
134
- current run; it is not a cap on what this structure may contain. A mixed source
135
- can produce multiple `views[]` in one confirmed structure when source evidence
136
- supports them.
137
-
138
- Use collection routing first:
139
-
140
- - product intent, user story, requirement, roadmap, or product scenario ->
141
- `product`;
142
- - architecture, service/module/system design, runtime dependency, code-adjacent
143
- prose -> `architecture`; if an existing code projection already owns the
144
- object, reuse its NodeRef/ViewRef instead of creating a `codeindex` prose
145
- view;
146
- - SOP, runbook, operation drill, workflow, or how-to procedure -> `sop`;
147
- - FAQ, question/answer, support notes -> `faq` only when the evidence is an
148
- independent FAQ page or cross-cutting support knowledge; a single Q&A or
149
- scattered support note stays as a `faq` Section under the owning view;
150
- - standards, policy, rules, conventions, reusable constraints -> `standards`;
151
- - decision record, trade-off, migration conclusion -> `decision` only when it
152
- is an independent decision record with owner/date/lifecycle or cross-cutting
153
- decision scope; one-off conclusions stay as `decision` Sections under the
154
- owning view;
155
- - incident, postmortem, outage, fault timeline, action item -> `incident` only
156
- when it has incident identity, timeline, follow-up, or tracking lifecycle;
157
- isolated warnings/failures/action items stay as `incident` or `warning`
158
- Sections under the owning view;
159
- - test plan, validation scenario, acceptance case -> `test`;
160
-
161
- Do not route prose align views to `codeindex` or `feats`: `codeindex` is
162
- produced by code extraction / AST projection, and `feats` is reserved for the
163
- dedicated feature workflow. For section-vs-collection overlap, keep a local
164
- `faq`, `decision`, or `incident` as a Section kind under the owning view unless
165
- the source is independently queryable across the package and has its own
166
- lifecycle, ownership, timeline, or cross-cutting scope.
167
-
168
- After collection routing, apply `structure-planning/references/gates.md` before
169
- authoring Nodes: classify Node type in order (`action` scale + process evidence,
170
- then concrete/term `entity`, then child-bearing `domain`), reject fake Entities
171
- only when at least two suspicious signals match, keep `term` separate from
172
- concrete tags, and provide required gate evidence.
173
-
174
- Preserve shared-source intent when the same source span legitimately supports
175
- multiple views. Do not copy the span text into multiple rewritten bodies; cite
176
- the same CLI `source_ref` in each supported view and let structure-summary mark
177
- the shared evidence.
178
-
179
- Source titles and headings are ordinary evidence, not structural authority. Choose titles and summaries that fit the final Node type and the CLI-provided generation policy.
180
-
181
- Plan source material as Sections first. A source heading only becomes a child
182
- Node/View when the cited evidence names a concrete independent subject, an
183
- atomic term, a gated Action, or a child-bearing Domain. A `contains` edge only
184
- states hierarchy; it does not prove that a thin child page has standalone
185
- retrieval value.
186
-
187
- Avoid same-source fragmentation. If one parent would contain many single-section
188
- child Entities from the same source document, keep them as Sections unless each
189
- child has an independent product/code object, atomic term, Action, or Domain
190
- identity. Also avoid copying the parent `system` / `application` scope tag onto
191
- local child aspects; tag a child by what it independently is.
192
-
193
- Do not promote a source fragment into a child page solely because it has a
194
- heading or a recognized section kind. Judge every proposed child with the same
195
- source-backed criteria: independent subject identity, sufficient context, and
196
- standalone retrieval value. The CLI may warn about repeated same-source thin
197
- children, but page granularity remains an evidence-backed structure decision
198
- for the review report rather than a content-type-specific hard gate.
199
-
200
- For `node.title` and `node.summary`, follow the workspace/source language
201
- surfaced by the current view or the user's instruction. In Chinese workspaces,
202
- translate descriptive scaffold words such as architecture, strategy, lifecycle,
203
- overview, scheduling, high availability, and warning into Chinese while
204
- preserving product names, code identifiers, CLI flags, slugs, source_ref tokens,
205
- and citation tokens exactly when needed. Do not copy an English source title
206
- into `node.title` merely because the source is English.
207
-
208
- Do not classify a broad architecture/system/方案 source as `domain` just because the title sounds like a scope. If it has writable Sections but no resolvable current/existing child Nodes, use an `entity` tag such as `system` or `application`; reserve `domain` for grouping child Nodes through typed `edges[]` with supported child targets.
209
-
210
- For large or batched payloads, use
211
- `structure-planning/references/density-profile.md` and
212
- `structure-planning/references/candidate-resolution.md` as judgment aids.
213
- They do not create additional workflow stages or alternate payloads.
214
-
215
- ### Step 5 — Build The Payload Requested By `next_action`
216
-
217
- Use `context run align:<type>:<source>:<collection> --view schema --format json` to
218
- shape the payload. Treat that schema as the authoring contract.
219
-
220
- Produce one `context.structure.v1` document with semantic Nodes, planned
221
- Sections, typed edges, unresolved items, lifecycle state, sources, and evidence
222
- snapshot hash. Section identities are part of the structure gate: choose stable
223
- section ids such as `overview`, `behavior`, `constraints`, or a source-backed
224
- domain-specific name when the evidence supports it.
225
-
226
- For an independent collection entry, omit `containment`; the CLI derives
227
- `<collection>/<slug>.md`. Set `containment` only when the confirmed structure
228
- intentionally places the View under a parent path. Do not add a source/module
229
- wrapper merely to make every page use the same directory depth.
230
-
231
- Use only CLI-provided `source_refs[]` for section and edge evidence. Continuity
232
- is a per-Section constraint, not a per-View constraint: one View may contain
233
- many independently retrievable Sections, each with its own continuous mirror.
234
- Do not invent heading/range/window selectors inside the structure. Treat source
235
- heading changes as section-planning signals: sibling sub-headings under a shared parent
236
- may stay in one Section when they form one coherent semantic topic; headings
237
- with no shared parent should usually split unless you intentionally want one
238
- Section to span them. If a semantic section would require non-contiguous or
239
- cross-source evidence, split it during align or return the issue to the
240
- structure gate. Current compile writes approved knowledge by mirroring source
241
- spans; it does not use rewritten multi-ref sections to compress unrelated
242
- evidence.
243
-
244
- Validate will surface source mirror blockers before confirmation. Treat
245
- `section.source_mirror_split_required`,
246
- `section.source_mirror_repair_required`, and
247
- `section.source_mirror_source_refs_missing` as structure problems, not compile
248
- drafting problems. Use the returned `repair.suggested_splits[]` when present;
249
- otherwise repair source refs from CLI evidence views or move unsupported
250
- material to `unresolved[]`.
251
-
252
- For pure suggested-split repairs, prefer the CLI repair view before hand-editing:
253
- Deterministic source-boundary repairs are applied internally by validate/stage
254
- and are not a separate Agent command.
255
- It splits non-contiguous Section mirrors and can expand a broad cross-heading
256
- Section into Markdown structural groups within the same View. Apply the
257
- non-blocking repair hint when the groups should be independently retrievable;
258
- otherwise keep the Section and explain the grouping in structure review.
259
- Oversized Views still require the Agent to apply the returned child-View and
260
- contains-edge suggestions while classifying every child Node from evidence.
261
- Those suggestions preserve Section order and place adjacent Sections into
262
- bounded groups; `part-N` names are placeholders, not semantic titles. Rename
263
- and classify each child from evidence instead of expanding one child View per
264
- Section or treating the suggested grouping as a content decision. The repair
265
- command does not resolve orphan ownership, unsupported evidence, or competing
266
- semantic groupings.
267
-
268
- When the cited source sentence itself is uncertain, preserve that uncertainty on
269
- the edge with `confidence: possible` or `confidence: hypothesis`. This is only
270
- for source-authored uncertainty such as "可能", "疑似", "may", or "might". If
271
- you are unsure whether the source supports the relation, do not add an uncertain
272
- edge; move the relation to `unresolved[]`.
273
-
274
- No-write/navigation-only/placeholder-only material should become `unresolved`
275
- at align time when it has retrieval or graph value but lacks source-backed
276
- section evidence. Do not turn relation-only navigation into a factual Section.
277
- Do not submit `sections: []` for an ordinary source-bound view. Use
278
- `sections: []` only for a generated parent index view, and only when it has
279
- `generated: parent_index` plus source-backed `contains` edges to child views.
280
- If the relationship matters but evidence or a target node is missing, keep it
281
- unresolved instead of writing a dangling edge.
282
-
283
- Emit `depends_on` edges only when cited source refs explicitly say one Node
284
- consumes, requires, calls, is configured by, or is downstream of another Node as
285
- a prerequisite, capability provider, upstream input, runtime dependency, or
286
- data-flow source. Direction is consumer/downstream -> provider/upstream. Do not
287
- create `depends_on` for parent/child containment, `Related`/`See also` lists,
288
- sibling co-occurrence, shared table membership, name similarity, or a plain
289
- mention without a dependency predicate. `edges[].source_refs[]` must include the
290
- source ref that states the dependency; if the relationship matters but evidence
291
- is missing, leave the edge unresolved instead of guessing.
292
-
293
- Prefer the strongest source-backed `section_kind` using the current schema's
294
- `section_kind_priority` and the semantic rules below; avoid planning an entire
295
- dense source as `description` when the evidence clearly contains fenced
296
- examples, comparison tables, Q&A, decisions, specs, warnings, or principles.
297
- Use `example` for fenced command/config/code or literal sample blocks, not
298
- ordinary scenario prose. Use `comparison` for two or more subjects compared
299
- across two or more dimensions. Use `faq` for a question-and-answer pair. Use
300
- `incident` only for dated or timestamped failure evidence with impact scope
301
- plus root cause, mitigation, or handling record. Use `changelog` for a
302
- versioned or dated change record. Use `decision` only when the source surfaces
303
- two or more alternatives or options plus the chosen path and rationale. Use
304
- `spec` for a verifiable rule, threshold, requirement, constraint, or checkable
305
- target; `warning` for an explicit caveat, risk, hazard, or limitation;
306
- `principle` for a stable invariant, design rule, or core mechanism without a
307
- check method; and `description` only as the narrative fallback. Treat kind
308
- precision as a drafting quality preference, not a reason to block an otherwise
309
- source-backed write. Keep only raw-backed semantic decisions in the payload;
310
- leave mechanical repair and patch routing to CLI diagnostics.
311
-
312
- There is no parallel candidate-body authoring path. Emit only the
313
- `context.structure.v1` payload accepted by the current schema view.
314
-
315
- ### Step 6 — Validate And Submit
316
-
317
- Before staging, write the `context.structure.v1` payload to the Route-selected `.tmp/agent-payloads/` path and run the returned `context run align:<type>:<source>:<collection> --validate --input <payload-file> --format json` command. The CLI applies deterministic boundary repairs internally and returns only remaining blockers. For oversized Views, apply the returned child-View and contains-edge suggestions while classifying child Nodes from evidence. Resolve other blockers from evidence; ask the user only when evidence supports multiple incompatible semantic choices. Stage only after validation state is `ready`. The stage result opens the final HTML report for the Route-selected structure-confirmation gate. Execute the revision-bound confirmation command returned by `workflow.current`; managed session authority may resolve that gate without another question.
318
-
319
- After stage succeeds, do not rerun the same write command to confirm success.
320
- Use `context status --format json` or the returned result for read-only
321
- confirmation; then continue with the returned `next_action.command`, normally
322
- `context run compile:<type>:<source>:<collection> --view read-plan --format json`.
323
-
324
- If any write is rejected, follow the returned `next_action` and `reason_code`.
325
- Do not retry by guessing direct/batched stages, forcing route bypasses, or
326
- editing CLI-managed files.
327
-
328
- ### Step 7 — Self-verify
329
-
330
- - [ ] All writes followed top-level `next_action.command`. If not, return to **Step 1**.
331
- - [ ] Evidence was read through returned `next_action.command`, `next_command`, or current CLI schema/view commands only. If not, return to **Step 2**.
332
- - [ ] Node classification used the semantic gates in `structure-planning/references/gates.md`. If not, return to **Step 4**.
333
- - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
334
- - [ ] The requested align payload passed the exact Route-selected `--validate --input <payload-file>` command before stage. If not, return to **Step 6**.
335
- - [ ] No `sources/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
336
-
337
- </procedures>