@c4a/context-cli 0.5.39 → 0.5.41-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.5.39",
3
+ "version": "0.5.41-beta.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "context": "./cli.js"
package/plugin/README.md CHANGED
@@ -1,12 +1,10 @@
1
- # Agentic Context System Over Compiled Knowledge
1
+ # Context: Build Agent-Facing Knowledge
2
2
 
3
3
  > [中文版本](./README_CN.md)
4
4
 
5
5
  <p align="center"><img src="./assets/logo.svg" alt="C4A Context" width="180"/></p>
6
6
 
7
- An Agentic knowledge system built for AI Agents. It pre-compiles Feishu docs, local Markdown, code structure, and hand-curated business material into structured, traceable knowledge, so an agent can perform high-precision search over it through a dedicated CLI.
8
-
9
- This repository is the **local standalone build of C4A System**. The full C4A System will add online services with stronger multi-user collaboration support — releasing soon.
7
+ A knowledge workflow built for small and mid-sized teams working with Agents. It compiles Feishu docs, local Markdown, code, and hand-curated business material into structured, traceable knowledge, then guides the Agent through optimal reasoning patterns and targeted exploration of that knowledge — to deliver high-quality retrieval. Runs inside any Agent environment that supports Plugins (Skill + Command).
10
8
 
11
9
  ## Why C4A Context
12
10
 
@@ -107,17 +105,19 @@ The compiled knowledge base can be packaged for distribution:
107
105
 
108
106
  ## Recommended environment
109
107
 
110
- Measured behavior of Agent + model combinations across instruction following, parameter hallucination, and extraction quality (scored 0–100):
111
-
112
- | Agent | Model | Instruction following | Parameter hallucination | Extraction quality |
113
- |---|---|---:|---|---:|
114
- | Codex | GPT 5.5 xh | 95 | Almost none | 96 |
115
- | Claude | Opus 4.6 / 4.7 | 95 | Almost none | 95 |
116
- | Cursor | Opus 4.6 / 4.7 | 92 | Almost none | 85 |
117
- | Claude | DeepSeek V4 | 70 | Frequent | 55 |
118
- | Claude | DeepSeek V4 Flash | 55 | Frequent | 45 |
119
-
120
- **Recommendation**: prefer GPT or Opus for now. DeepSeek V4 still lags in instruction following and extraction quality and needs further CLI optimization; full DeepSeek V4 adaptation is planned for v0.5.40, targeting an overall score above 90.
108
+ The numbers below come from a parallel benchmark: each model runs the full c4a flow (capture → align → compile) end-to-end over the same 10-document business corpus, with no manual intervention. Quality is scored across 7 dimensions (totaling 100) based on the resulting knowledge base; duration covers the full flow from `context init` to `compile close`.
109
+
110
+ | Dimension | Opus 4.8 (Claude) | GPT 5.5 (Codex) | Opus 4.7 (Claude) | DeepSeek V4 Pro (Claude) |
111
+ |---|---:|---:|---:|---:|
112
+ | Fact coverage (25) | 23 | 23 | 22 | 18 |
113
+ | Fact fidelity (25) | 24 | 23 | 19 | 18 |
114
+ | Structure (15) | 14 | 13 | 8 | 7 |
115
+ | URL (5) | 5 | 4 | 2 | 5 |
116
+ | Source ref (10) | 9 | 9 | 7 | 6 |
117
+ | Section boundary (10) | 9 | 10 | 7 | 5 |
118
+ | Schema (10) | 9 | 10 | 9 | 7 |
119
+ | **Total** | **93** | **92** | **74** | **66** |
120
+ | Duration | 30m47s | 10m07s | 19m6s | 14m44s |
121
121
 
122
122
  ## About this repository
123
123
 
@@ -1,12 +1,10 @@
1
- # Agentic Context System Over Compiled Knowledge
1
+ # Context: Build Agent-Facing Knowledge
2
2
 
3
3
  > [English](./README.md)
4
4
 
5
5
  <p align="center"><img src="./assets/logo.svg" alt="C4A Context" width="180"/></p>
6
6
 
7
- 专为 AI Agent 打造的 Agentic 知识系统,将飞书文档、本地 Markdown、代码结构、人工整理的业务资料预编译为结构化、可溯源的知识,再让智能体通过专用命令行工具,在这套知识上完成高精度检索。
8
-
9
- 本仓库是 **C4A System 的本地独立可运行版本**;完整的 C4A System 将支持在线服务、更适合多人协同,即将发布。
7
+ 专为 Agent 打造的中小团队知识工作流,将飞书文档、本地 Markdown、代码、人工整理的业务资料编译为结构化、可溯源的知识,再指导 Agent 通过最佳的推理模式和探查知识完成高质量检索。本工具运行在支持 Plugin (Skill + Command) 的 Agent 环境中。
10
8
 
11
9
  ## 为什么选择 C4A Context
12
10
 
@@ -105,17 +103,19 @@ bun add -g @c4a/context-cli
105
103
 
106
104
  ## 环境推荐
107
105
 
108
- 不同 Agent 与模型组合在指令遵循、参数幻觉、提取质量三项上的实测表现(0–100 分):
109
-
110
- | Agent | 模型 | 指令遵循度 | 参数幻觉 | 提取质量 |
111
- |---|---|---:|---|---:|
112
- | Codex | GPT 5.5 xh | 95 | 几乎无 | 96 |
113
- | Claude | Opus 4.6 / 4.7 | 95 | 几乎无 | 95 |
114
- | Cursor | Opus 4.6 / 4.7 | 92 | 几乎无 | 85 |
115
- | Claude | DeepSeek V4 | 70 | 经常 | 55 |
116
- | Claude | DeepSeek V4 Flash | 55 | 经常 | 45 |
117
-
118
- **建议**:目前优先使用 GPT Opus;DeepSeek V4 在指令遵循与提取质量上仍有差距,需配合 CLI 进一步优化,预计 v0.5.40 完成 DeepSeek V4 适配并达到 90+ 综合得分。
106
+ 下方数据来自一次并发基准测试:每个模型在同一份 10 篇业务文档语料上端到端跑完 c4a 全流程(capture → align → compile),无人工介入。质量按 7 个维度评分(总分 100)反映产物知识库;耗时覆盖 `context init` 到 `compile close` 的全流程。
107
+
108
+ | 维度 | Opus 4.8(Claude) | GPT 5.5(Codex) | Opus 4.7(Claude) | DeepSeek V4 Pro(Claude) |
109
+ |---|---:|---:|---:|---:|
110
+ | 事实覆盖(25) | 23 | 23 | 22 | 18 |
111
+ | 事实忠实(25) | 24 | 23 | 19 | 18 |
112
+ | 结构语义(15) | 14 | 13 | 8 | 7 |
113
+ | URL(5) | 5 | 4 | 2 | 5 |
114
+ | Source ref(10) | 9 | 9 | 7 | 6 |
115
+ | Section 边界(10) | 9 | 10 | 7 | 5 |
116
+ | Schema(10) | 9 | 10 | 9 | 7 |
117
+ | **总分** | **93** | **92** | **74** | **66** |
118
+ | 总耗时 | 30m47s | 10m07s | 19m6s | 14m44s |
119
119
 
120
120
  ## 关于本仓库
121
121
 
@@ -21,22 +21,25 @@ Use the returned `workflow.next-action-envelope.v2` as the source of truth:
21
21
  - Treat `allowed_actions[]` as permission for read-only insertions such as `show_view`; do not choose a different write path from it.
22
22
  - Treat `agent_hints[]`, when present, as a temporary mirror or diagnostic only. If it conflicts with `next_action`, follow `next_action`.
23
23
  - Read workflow payload views only through returned `context workflow show` commands.
24
+ - If the host truncates scan stdout but the preview includes top-level `next_action.command`, run that command. If `next_action` is not visible, rerun the scan command; do not recover host tool-result files.
24
25
 
25
26
  For protocol discovery, prefer narrow commands:
26
27
 
27
28
  - `context schema workflow.next-action-envelope.v2 --view minimal --format json`
28
29
  - `context protocol show align-compile --format json`
29
- - `context schema align-structure-decision --view minimal --format json`
30
+ - `context schema align-structure-intent --view minimal --format json` — includes required fields, enums, mount matrix, and a minimal authoring example; use full schema only for extended notes.
30
31
 
31
32
  ### Step 2 — Read Evidence Through The Single Evidence Path
32
33
 
33
34
  If scan returns a `read-plan` command, run it and then follow the next command returned by that view. The normal path is:
34
35
 
35
36
  - `read-plan` summarizes source size, active source set, navigation/placeholder sources, and the next evidence command.
36
- - `source-bundle` returns the selected source text with `@c4a` block annotations. Read it, then write an align structure-decision JSON yourself; do not pipe the bundle text into `context align validate`.
37
+ - `source-bundle` returns the selected source text with `@c4a` block annotations. Read it, then write the requested align JSON yourself, normally `align-structure-intent`; do not pipe the bundle text into `context align validate`.
38
+ - If `source-bundle` omits text for budget, `read_scope_complete: false`, `page.has_more: true`, or the final `source-bundle:end` annotation is missing, run its `next_action.command` before authoring.
39
+ - If the next command contains `--read-cursor`, treat it as opaque continuation state. Do not decode it and do not replace it with hand-written `--source` / `--window` / `--range` / `--heading` selectors.
37
40
  - `blocks`, `windows`, `block-index`, `source-mapping`, and `pending-relation-refs` are detail views only. Use them when the read-plan/source-bundle next action or `how_to_explore[]` asks for a narrow follow-up.
38
41
 
39
- When a view returns `page.next_command`, follow that command to continue the same semantic view. Use `--source`, `--heading`, `--window`, or `--token-budget` only as view filters; do not inspect workflow files, cache files, host tool-results, or stdout fragments with generic tools.
42
+ When a view returns `page.next_command`, follow that command to continue the same semantic view. Use `--source`, `--heading`, `--window`, `--range`, or `--token-budget` only as view filters; do not inspect workflow files, cache files, host tool-results, or stdout fragments with generic tools.
40
43
 
41
44
  If a detail view returns `align-blocks-read-incomplete`, `page.has_more`, or `truncated: true`, the response is a partial read. Return to the read-plan/source-bundle continuation instead of treating that partial JSON page as the complete source.
42
45
 
@@ -44,18 +47,22 @@ If a detail view returns `align-blocks-read-incomplete`, `page.has_more`, or `tr
44
47
 
45
48
  Reuse existing knowledge before inventing new Nodes: use `context mdrive glossary match <name>` and `context mdrive node list --format json` for term/entity reuse.
46
49
 
47
- Apply packaged `context:skill-align-workflow` Node classification gates and structure-decision procedure. Keep generated payloads on stdin. Do not create scratch files under the workspace or `/tmp`.
50
+ Apply packaged `context:skill-align-workflow` Node classification gates and align intent procedure. Keep generated payloads on stdin. Prefer heredocs for small payloads; if payload staging is needed for large or parallel writes, use the workspace AGENTS.md scratch path (`.context/.tmp/agent-payloads/<run-id>/...` in embedded workspaces, `.tmp/agent-payloads/<run-id>/...` in root-layout workspaces) and redirect stdin from it. Never reuse fixed `/tmp/c4a-*` names and never place scratch payloads under CLI-managed `.tmp/context-cli/`, `output/`, `archive/`, `knowledge/`, or `raw/` truth directories.
48
51
 
49
52
  Use CLI diagnostics instead of static prompt rules:
50
53
 
51
- - `diagnostics.automatic_ownership_adjustments[]` explains mechanical external-reference demotions and the explicit ownership override shape.
52
- - `pending-relation-refs` lists explicit Parent/Children/Related markdown links. Reuse existing target Nodes when present; keep unresolved target slug hints deferred instead of writing dangling `contains_parent`.
54
+ - `diagnostics.automatic_ownership_adjustments[]` explains mechanical structural-block demotions and the explicit ownership override shape.
55
+ - `pending-relation-refs` lists explicit Parent/Children/Related markdown links. Reuse existing target Nodes when present; keep unresolved target slug hints deferred instead of writing dangling `contains_parent` / `domain_gate.child_refs`. A relation/placeholder source may still be preserved as a no-write Node with root-level `planned_sections: []`; preserve it before default skip when an explicit retrieval need, graph need, or atomic/concrete title gives the page standalone retrieval value, even if every child ref is unresolved. Never put `planned_sections` inside `domain_gate`. If it is kept without graph support, keep supporting blocks `context_only` with `visible_to`. If you skip the source and emit no Node for it, still cover its coverable blocks with an `ownership_groups[]` rule, usually source-wide `ignored` for pure placeholders. `ignored` disposes unused material and does not support the placeholder by itself. Unresolved children stay pending rather than becoming graph edges.
53
56
  - Validation diagnostics identify contiguity, citation eligibility, ownership, and mount-matrix problems.
54
57
  - `views[]` and `diagnostics` distinguish citable evidence from supporting context; do not infer citation eligibility from raw ownership prose.
55
58
 
56
59
  ### Step 4 — Validate And Submit
57
60
 
58
- When the envelope asks for `validate_align_decision`, submit the structure-decision payload you authored after reading evidence to `context align validate --input - --format json` or the exact returned command. If validate returns blocking diagnostics, repair the payload and rerun validate. If validate returns a `submit_structure_decision` next_action, execute that command with the validated payload.
61
+ When the envelope asks for `validate_align_decision`, submit the payload matching `next_action.input_schema`, normally the `align-structure-intent` you authored after reading evidence, to `context align validate --input - --format json` or the exact returned command. If validate returns blocking diagnostics, repair the payload and rerun validate. If validate returns a `submit_structure_decision` next_action, execute that command with the same validated payload.
62
+
63
+ After a finalize command succeeds, do not submit finalize again to confirm it. Use returned `payloads.*.show_command` values, or `context workflow show --payload finalized-ownership --unwrap --format json`, for read-only confirmation; then follow `next_action.command`, normally `context compile scan --format json`.
64
+
65
+ If finalize reports node reclassification hints, treat finalized ownership as the source of truth. `context status` reports finalized node types, not the originally submitted proposal.
59
66
 
60
67
  For any other write kind, execute the top-level `next_action.command` exactly. If the command rejects the payload, follow the returned `next_action` and `reason_code`; do not infer a route fallback from memory.
61
68
 
@@ -24,8 +24,10 @@ Invocation note: code capture does not run through `npx`. The default code aspec
24
24
 
25
25
  ### Route by argument
26
26
 
27
- - `$ARGUMENTS` is one or more `http://` / `https://` targets and/or local `.md` paths `context capture $ARGUMENTS` (Feishu docx/wiki URLs need `lark-cli`; URL and mixed batches are supported). Do not write an Agent-side URL loop.
28
- - User provides a long newline-separated URL list or local `.md` path list → pass it to `context capture --stdin` with a direct heredoc. Mixed URL + local `.md` batches are supported when the user intentionally provides both.
27
+ Before choosing a local Markdown capture route, honor the surrounding task context. Driver documents such as run instructions, handbooks, READMEs, plans, feedback issues, corpus/index/manifests, and batch lists are not Context sources unless the user explicitly asks to ingest them. Capture only ingest targets that are already explicit in the user request; if they are missing, ask one clarification instead of capturing the driver document.
28
+
29
+ - `$ARGUMENTS` is one or more `http://` / `https://` targets and/or local `.md` source documents to ingest → `context capture $ARGUMENTS` (Feishu docx/wiki URLs need `lark-cli`; URL and mixed batches are supported). Do not write an Agent-side URL loop.
30
+ - User provides a long newline-separated URL list or local `.md` source document list to ingest → pass it to `context capture --stdin` with a direct heredoc. Mixed URL + local `.md` batches are supported when the user intentionally provides both.
29
31
  - `$ARGUMENTS` contains `--inbox` → `context capture --inbox`.
30
32
  - `$ARGUMENTS` contains `--refresh` → `context capture --refresh`. This refreshes active Feishu URL sources and local Markdown sources whose stored origin file still exists; code sources use `context capture --code`.
31
33
  - User asks for code capture with explicit `--module` flags → run `context capture --code $ARGUMENTS`, preserving code flags such as `--module`, `--version`, `--version-from`, and `--no-runner-cache`.
@@ -40,7 +42,7 @@ Invocation note: code capture does not run through `npx`. The default code aspec
40
42
  - Write the body to `context capture --note --intent <intent> --anchor <node-slug>[#<section-id>] --input -` for anchored notes, or omit `--anchor` for brainstorm.
41
43
  - For `revision`, organize the stdin Markdown with headings: `旧上下文`, `修改意图`, `新内容`, `验证条件`.
42
44
  - For `decision`, organize the stdin Markdown with headings: `议题`, `选项`, `决议`, `理由`.
43
- - After capture, run `context status --format json` and base the user-facing next step on `next_step.command` / `workflow.next_step`.
45
+ - After capture, run `context status --view summary --format json` and base the user-facing next step on `next_step.command` / `workflow.next_step`.
44
46
 
45
47
  For stdin batches, use this shape:
46
48
 
@@ -58,7 +60,7 @@ Do not pipe the heredoc through another command, and do not discover files with
58
60
 
59
61
  Report the CLI output verbatim. If the CLI reports `N sources changed`, suggest the right next step:
60
62
 
61
- - Run `context status --format json` and use its `next_step.command` / `workflow.next_step`.
63
+ - Run `context status --view summary --format json` and use its `next_step.command` / `workflow.next_step`.
62
64
  - If JSON status reports `incremental.pending_align.status: "pending"` with `count > 0`, suggest `/context:align` even when a previous finalized align workflow or prose `workflow.next_step` says compile. Newly captured structure work must be routed through align before compile.
63
65
  - If status says aligned knowledge is missing or alignment is required → suggest `/context:align`.
64
66
  - If status says compile work is pending for Markdown / evidence-backed knowledge → suggest `/context:compile`. Mention `/context:align` only if the user wants to revise the structure.
@@ -21,7 +21,7 @@ Naming convention:
21
21
  - **`--aspect code [selector]`** — run `context compile --aspect code [selector]`, report the CLI result, and stop unless the CLI asks for a follow-up close. The selector may be omitted to process all actionable code sources; when present, the CLI resolves source slug, package name, or module path.
22
22
  - **`--aspect <name>`** — run deterministic custom aspect projection for one configured aspect. Use `context compile --aspect <name> --allow-large-deprecate` only when the CLI rejected a large deprecate and the user confirms the runner output is intentionally empty or reduced.
23
23
  - **`--all`** — run `context compile --all` to materialize code projection first and then custom aspect projections in deterministic order.
24
- - **Delegated** — add `--delegated` only when the user explicitly authorized delegated/automatic mode at the start of this conversation. Do not infer it from vague "continue" permission.
24
+ - **Delegated** — add `--delegated` only when the user explicitly authorized delegated mode at the start of this conversation. Delegated mode records scoped authority for low-risk reconcile/review/apply defaults; it does not auto-draft Node content or replace agent evidence reading. Do not infer it from vague "continue" permission.
25
25
 
26
26
  ### Core Rules
27
27
 
@@ -30,6 +30,7 @@ Naming convention:
30
30
  - Treat `allowed_actions[]` as permission for read-only insertions; it is not a menu of alternate write paths.
31
31
  - Treat `agent_hints[]`, when present, as a temporary mirror or diagnostic. If it conflicts with `next_action`, follow `next_action`.
32
32
  - Do not use direct file tools, shell scripts, `jq`, `sed`, `cat`, `head`, `tail`, Python, or Node.js to inspect workspace storage, workflow payload files, or `--format json` stdout.
33
+ - Workflow write digest flags are stale guards. Omit `--payload-digest` unless the returned command explicitly requires one; when an explicit digest is needed, use `context workflow show --payload <name> --digest-only --format text` instead of parsing JSON stdout.
33
34
 
34
35
  Protocol discovery:
35
36
 
@@ -40,8 +41,9 @@ Protocol discovery:
40
41
  ## Start
41
42
 
42
43
  1. Run `context compile scan --format json` (or `context compile scan --delegated --format json` only for explicit delegated mode).
43
- 2. If the scan returns `stop_noop` or no changed work, report that compile stopped before draft and no files were written.
44
- 3. Run `context status --format json` or `context mdrive workspace stats --format json` only when needed for the final before/after report or when the CLI asks for diagnostics. Do not run doctor/status/source-list as a required preflight before following a valid compile scan or align-finalize handoff.
44
+ 2. If the scan returns `close_compile`, run the returned close command even when there are no changed Nodes; finalized no-write/container Nodes may still need close materialization.
45
+ 3. If the scan returns `stop_noop` or no changed work, report that compile stopped before draft and no files were written.
46
+ 4. Run `context status --view summary --format json` or `context mdrive workspace stats --format json` only when needed for the final before/after report or when the CLI asks for diagnostics. Do not run doctor/status/source-list as a required preflight before following a valid compile scan or align-finalize handoff.
45
47
 
46
48
  Run `context compile scan` only for this initial preflight unless the CLI explicitly returns it as the next command after a terminal/no-work state. During an active compile workflow, discover the next node from the current envelope (`next_action`, `views[]`, `workset_progress`) and follow returned commands; do not rerun scan between node cycles to probe for the next node.
47
49
 
@@ -51,33 +53,34 @@ Repeat until the CLI returns `stop_noop`, `close_compile` succeeds, or a blockin
51
53
 
52
54
  Carry the latest envelope forward between iterations. After a successful node cycle, continue from its returned `next_action.command` / `workset_progress` rather than restarting at `context compile scan`.
53
55
 
54
- ### Step 1 — Read Expected Views
56
+ ### Step 1 — Read Node Evidence From The Envelope
55
57
 
56
- Run expected view commands from the envelope before writing. For compile evidence, prefer the CLI-returned source-ref/scaffold views. They may expose:
58
+ Run the evidence command returned by the envelope before writing. `views[].expected` identifies the default compact evidence entry, not a separate checklist to exhaust. For compile evidence, prefer the CLI-returned source-ref/scaffold views. They may expose:
57
59
 
58
- - `source_refs_index_command` / `source_refs_command` — compact block-id evidence index for drafting; use `items[].block_id` in `source_block_ids[]`.
60
+ - `source_refs_index_command` / `source_refs_command` — compact Node-scoped citation index for drafting; use `items[].block_id` in `source_block_ids[]` when the row is the evidence you will cite.
59
61
  - `source_refs_detail_command` — detailed source refs with quote previews; open only when the compact index is not enough.
60
62
  - `request_full_text_command` / `--view text` — narrow text view for one block when quote preview is not enough; this is still Node-scoped, not a workspace evidence bundle.
61
63
  - `citable_source_refs[]` — detailed-view refs eligible for draft citations; prefer `block_id` values in `source_block_ids[]`.
62
64
  - `supporting_context_refs[]` — background/framing only.
63
- - `required_preserved_literals[]` URL, code identifier, `source_ref`, or `block_id` literals that must stay visible in the generated content or repair report.
64
- - diagnostics such as citation eligibility, source support, coverage, engagement, and advisory foldbacks.
65
+ - diagnostics such as citation eligibility, coverage, engagement, stale raw/source_ref pointers, and advisory foldbacks.
65
66
 
66
- Follow `page.next_command` for pagination. Use `how_to_explore[]` for narrow reads. Do not expand workflow payloads through host tool-results. Node-cycle receipts are compact by default; `actions_meta[]` exposes current draft action handles for patching without an extra status read.
67
+ Follow `page.next_command` for pagination. Use `how_to_explore[]` for narrow reads. Do not expand workflow payloads through host tool-results. Node-cycle receipts are compact by default; `actions_meta[]` exposes current draft action handles for patching without an extra status read. When advisory foldbacks say `agent_recommended_action: ignore`, do not inspect each detail row unless the user asks for cleanup or the cited source appears to lose meaning.
67
68
 
68
69
  ### Step 2 — Produce Payloads Only When Requested
69
70
 
70
71
  For `submit_compile_cycle`, load the Node evidence via the returned command/views, invoke packaged `context:skill-compile-draft` for exactly one Node, and pass the emitted JSON on stdin to the returned `next_action.command`.
71
72
 
73
+ Prefer heredocs for small payloads. If large or parallel draft payloads need staging, use the workspace AGENTS.md scratch path (`.context/.tmp/agent-payloads/<run-id>/...` in embedded workspaces, `.tmp/agent-payloads/<run-id>/...` in root-layout workspaces) and redirect stdin from that file. Never reuse fixed names like `/tmp/c4a-draft-<node>.json`, and never use scratch paths as workflow handoff or CLI-managed storage.
74
+
72
75
  For `continue_compile_cycle`, do not invoke the draft skill and do not attach `--input`; execute the returned `next_action.command` exactly. `--continue` resumes a saved draft session. If it returns `status: "noop"`, follow the returned `close_compile` next action.
73
76
 
74
77
  For `patch_compile_draft`, submit only the patch schema requested by the CLI. Use `actions_meta[].action_id` for `replace_action` / `remove_action`, or `add_action` with `before` / `after`; do not use generic `op/path/value` aliases.
75
78
 
76
- For `review_reconcile_decisions`, load the prepare payload through CLI views such as `context workflow show --payload prepare --unwrap --format json`, invoke packaged `context:skill-compile-judge` when semantic judgment is needed, run `context reconcile validate --mode compile --node <slug> --decisions - --format json`, repair any blocking diagnostics, then pass validated decisions to the returned review command.
79
+ For `review_reconcile_decisions`, first inspect the returned command and prepare summary. If the command is `context reconcile review --accept-safe-defaults ...` with no `--decisions -`, run it directly; the CLI is accepting only mechanical defaults. If manual decisions remain, load the prepare payload through CLI views such as `context workflow show --payload prepare --view issues --unwrap --format json`, accept default_decision items with compact `{ item_id, accept_default: true }` when you can verify they are appropriate, and invoke packaged `context:skill-compile-judge` only for items that still need support/relation judgment. For hand-authored decision payloads, run `context reconcile validate --mode compile --node <slug> --decisions - --format json`, repair any blocking diagnostics, then pass validated decisions to the returned review command.
77
80
 
78
- Invoke `context:skill-compile-judge` only when the top-level `next_action.kind` is exactly `review_reconcile_decisions`. If `questions` are present but `next_action.kind` is `patch_compile_draft`, patch the draft first; do not infer judge mode from question counts.
81
+ Do not treat every `review_reconcile_decisions` envelope as a judge request. Invoke `context:skill-compile-judge` only when the prepare summary includes `judge_handoff` or the returned diagnostics explicitly ask for support/relation judgment. If `questions` are present but `next_action.kind` is `patch_compile_draft`, patch the draft first; do not infer judge mode from question counts.
79
82
 
80
- For `apply_reconcile_review`, `close_compile`, `finish_current_node`, `submit_coverage_disposition`, or `abandon_or_rescan`, execute the returned command exactly. If it rejects, follow the new `next_action` and `reason_code`.
83
+ For `apply_reconcile_review`, execute the returned plain apply command exactly, typically `context reconcile apply --format json`; do not add `--decisions` or stdin. For `close_compile`, `finish_current_node`, `submit_coverage_disposition`, or `abandon_or_rescan`, execute the returned command exactly. If it rejects, follow the new `next_action` and `reason_code`.
81
84
 
82
85
  ### Step 3 — Repair From Diagnostics
83
86
 
@@ -87,8 +90,9 @@ Use typed diagnostics as the repair contract:
87
90
  - `diagnostics.auto_repaired[]` records mechanical repairs; warning severity must be surfaced in the final report.
88
91
  - `diagnostics.warnings[]` with info/advisory severity are not write blockers unless `blocking: true` or the next action says so.
89
92
  - `agent_recommended_action` classifies warning handling: `ignore` means continue unless the user asks for cleanup, `respond_optional` means repair only when semantically useful, and `respond_required` means resolve before the returned write action can succeed.
90
- - `source_support` is advisory lexical diagnostics, not a keyword gate. Do not patch drafts only to satisfy term overlap. Blocking evidence checks should come from invalid source refs, changed evidence boundaries, unsupported confirmed hard facts, or explicit top-level `next_action`. URL preservation, section kind precision, example formatting, and summary style are advisory/debt unless the CLI explicitly marks them blocking.
93
+ - Raw/source_ref pointer diagnostics are mechanical evidence checks, not content-quality judges. Do not patch drafts only to satisfy URL/style/term-overlap preferences. Blocking evidence checks should come from invalid source refs, stale raw mirrors, changed evidence boundaries, or explicit top-level `next_action`.
91
94
  - stale prepare refresh returns `review_reconcile_decisions` with `reason_code: "prepare_refreshed"`; reread the new prepare result before reviewing.
95
+ - If close reports a finalized Node that needs only block ownership/support repair, use `context compile repair ownership --input - --format json` with the `align.ownership-patch.v2` shape. This is the compile-family repair path and preserves completed node-cycle progress. Do not abandon the active compile workflow just to run `context align patch ownership`.
92
96
 
93
97
  Do not recover by replaying an old manual path, editing rendered files, or guessing schema aliases.
94
98
 
@@ -96,4 +100,4 @@ Do not recover by replaying an old manual path, editing rendered files, or guess
96
100
 
97
101
  When `next_action.kind` is `close_compile`, execute `context compile close` through packaged `context:skill-compile-close` or the returned command. Never claim success unless close exits 0 and verify is green, except the explicit no-work path.
98
102
 
99
- Report in the user's conversation language. Include semantic apply counts, close/verify status, warning-level `auto_repaired[]`, `ready_with_debt` coverage/review-debt summaries when present, and before/after workspace totals. Do not surface internal workflow payload digests, source-ref hashes, archive paths, or absolute file paths unless a user-facing report view explicitly returns them.
103
+ Report in the user's conversation language. Include semantic apply counts, close/verify status, warning-level `auto_repaired[]`, `ready_with_debt` coverage summaries when present, and before/after workspace totals. Do not surface internal workflow payload digests, source-ref hashes, archive paths, or absolute file paths unless a user-facing report view explicitly returns them.
@@ -15,17 +15,19 @@ Naming convention: `/context:*` names user slash commands and `context ...` name
15
15
  Routing rules (first match wins):
16
16
 
17
17
  1. **Empty arguments** → run `/context:status`.
18
- 2. **Starts with `http://` or `https://`, or ends in `.md`** → `/context:capture $ARGUMENTS`.
19
- 3. **Equals `--inbox` or `--refresh`** → `/context:capture $ARGUMENTS`.
20
- 4. **Matches `init`, `initialize`, `new workspace`, or looks like a plain workspace name** `/context:init $ARGUMENTS`.
21
- 5. **Mentions `code` or source-code capture** → `/context:capture --code $ARGUMENTS`.
22
- 6. **Mentions `aspect` without a concrete supported capture flag** ask one clarification; code aspect capture is exposed as `/context:capture --code`.
23
- 7. **Matches `align`, `structure`, `plan`, `node tree`** → `/context:align $ARGUMENTS`.
24
- 8. **Matches `compile`, `recompile`, `synthesize`, or `build knowledge`** → `/context:compile $ARGUMENTS`.
25
- 9. **Matches `drop`, `retract`, `delete source`, or passes a known source-id pattern (`feishu:*` / `local:*` / `aspect:*` / `oncall:*` / `meeting:*`)** → `/context:drop $ARGUMENTS`.
26
- 10. **Matches `purge`, `clear archive`, `delete archive`, or `清理归档`** → `/context:purge $ARGUMENTS`.
27
- 11. **Equals `status`, `health`, `overview`, `summary`, or asks for workspace/cache/plugin health** → `/context:status`.
28
- 12. **Anything else** (likely a knowledge question) → `/context:query $ARGUMENTS`.
18
+ 2. **Starts with `http://` or `https://`** → `/context:capture $ARGUMENTS`.
19
+ 3. **Ends in `.md` and is explicitly presented as source material to ingest/capture** → `/context:capture $ARGUMENTS`.
20
+ Driver documents such as run instructions, handbooks, READMEs, plans, feedback issues, corpus/index/manifests, and batch lists are not capture targets unless the user explicitly asks to ingest them. Capture only ingest targets that are already explicit in the user request; if they are missing, ask one clarification.
21
+ 4. **Equals `--inbox` or `--refresh`** → `/context:capture $ARGUMENTS`.
22
+ 5. **Matches `init`, `initialize`, `new workspace`, or looks like a plain workspace name** `/context:init $ARGUMENTS`.
23
+ 6. **Mentions `code` or source-code capture** → `/context:capture --code $ARGUMENTS`.
24
+ 7. **Mentions `aspect` without a concrete supported capture flag** ask one clarification; code aspect capture is exposed as `/context:capture --code`.
25
+ 8. **Matches `align`, `structure`, `plan`, `node tree`** → `/context:align $ARGUMENTS`.
26
+ 9. **Matches `compile`, `recompile`, `synthesize`, or `build knowledge`** → `/context:compile $ARGUMENTS`.
27
+ 10. **Matches `drop`, `retract`, `delete source`, or passes a known source-id pattern (`feishu:*` / `local:*` / `aspect:*` / `oncall:*` / `meeting:*`)** → `/context:drop $ARGUMENTS`.
28
+ 11. **Matches `purge`, `clear archive`, `delete archive`, or `清理归档`** → `/context:purge $ARGUMENTS`.
29
+ 12. **Equals `status`, `health`, `overview`, `summary`, or asks for workspace/cache/plugin health** → `/context:status`.
30
+ 13. **Anything else** (likely a knowledge question) → `/context:query $ARGUMENTS`.
29
31
 
30
32
  If multiple rules apply, pick the most specific (URL beats word match). When in doubt, ask one clarifying question before dispatching.
31
33
  Never use Read / Glob / Grep / Write against `WORKSPACE_DIR`; route to packaged `/context:*` commands and skills instead of opening plugin or workspace files manually.
@@ -47,7 +47,7 @@ Q. What default language should agents use for user-facing replies in this works
47
47
  C. Other — please describe.
48
48
  ```
49
49
 
50
- The option label must be localized, but the stored CLI value should remain stable. Pass the answer as `--language "Chinese"`, `--language "English"`, or the user's custom text.
50
+ The option label must be localized, but the stored CLI value should remain stable. Pass the answer as `--language Chinese`, `--language English`, or quote custom text as `--language '<custom text>'`.
51
51
 
52
52
  ### Step 3 — Ask about workspace focus (unless user already passed `--focus`)
53
53
 
@@ -68,15 +68,16 @@ Q. What will this workspace mainly hold?
68
68
  ```
69
69
 
70
70
  Interpret the answer:
71
+ - When appending generated or user-provided free text to the shell command, quote it with POSIX single quotes. If the text contains a single quote, escape it as `'\''`; do not use double quotes for free-form values.
71
72
  - Chose A–D → generate a 2–3 line focus description in the user's language. Phrase it as
72
73
  "primarily X; supporting materials such as Y may also be filed here" rather than exclusion
73
74
  language — workspaces absorb auxiliary material in practice. Show the exact generated focus
74
75
  text to the user and ask for one confirmation before running `context init`. If the user
75
- approves, pass it as `--focus "..."`; if the user edits it, pass the edited text as
76
- `--focus "..."`; if the user declines or says to skip, run without `--focus`.
77
- - Chose E or described freely → pass the user's text verbatim as `--focus "..."`.
76
+ approves, pass it as `--focus '...'`; if the user edits it, pass the edited text as
77
+ `--focus '...'`; if the user declines or says to skip, run without `--focus`.
78
+ - Chose E or described freely → pass the user's text verbatim as `--focus '...'`.
78
79
  - User says "skip" / "don't care" → run `context init` without `--focus`.
79
- - `$ARGUMENTS` already contains `--focus "..."` → skip this step entirely.
80
+ - `$ARGUMENTS` already contains `--focus <text>` → skip this step entirely.
80
81
 
81
82
  ### Step 4 — Choose aspects (unless `$ARGUMENTS` already has aspect flags)
82
83
 
@@ -127,6 +128,7 @@ Briefly state in the user's conversation language:
127
128
  - Default language
128
129
  - Installed aspects
129
130
  - Whether `AGENTS.md` was created and whether `CLAUDE.md` was linked
131
+ - If the user asks to read the generated workspace instructions, run `context workspace read AGENTS.md --format text`; do not open the data-root file with generic file tools.
130
132
  - Whether focus was recorded (show the first line if yes; mention the user can edit `config.yaml` later if not)
131
133
  - If the CLI prints a Claude local permission hint, tell the user that `Bash(context:*)` is the recommended scoped allow for heredoc-heavy context workflows. Do not edit `.claude/settings.local.json` unless the user explicitly asks.
132
134
  - Suggest `/context:capture` as the natural next step
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: skill-align-workflow
3
- description: "Internal procedure for /context:align. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits align structure-decision payloads for CLI validation/finalize."
3
+ description: "Internal procedure for /context:align. Reads CLI-guided align evidence, applies semantic Node classification gates, and emits align structure-intent payloads for CLI validation/finalize."
4
4
  ---
5
5
 
6
6
  # Align Workflow Procedure
@@ -16,13 +16,14 @@ Run `context align scan --format json`, follow the top-level `next_action.comman
16
16
  - `workflow.next-action-envelope.v2` is authoritative. Branch on `next_action.kind`, execute `next_action.command`, and treat `views[].command` as detail reads rather than a checklist.
17
17
  - `allowed_actions[]` may permit extra read-only work before the next write; it is not a menu of alternate write paths.
18
18
  - `agent_hints[]`, when still present, is a short-term cutover mirror or diagnostic. Do not prefer it over top-level `next_action`.
19
- - Schema names and enum values come from `context schema <name>`; use `--view minimal` for protocol discovery before full schema reads.
19
+ - Schema names and enum values come from `context schema <name>`. Use `--view minimal` first; for authoring schemas such as `align-structure-intent`, the minimal view includes required fields, enums, and a minimal payload example. Read the full schema only when you need extended notes or edge-case examples.
20
20
  - Existing knowledge is the lookup registry. Use `context mdrive glossary match <name>` and `context mdrive node list --format json`; do not read `knowledge/**` or create a separate registry file.
21
21
  - 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.
22
- - `diagnostics.automatic_ownership_adjustments[]` and validation diagnostics are the mechanical external-reference ownership source of truth. Independent reference definitions, pure URLs, relation kind blocks, and multiline reference-only lists default to context_only; submit an explicit `block_ownership[]` owned/shared entry only when such a reference block is primary citation evidence.
23
- - When `pending-relation-refs` is present, inspect it before finalizing graph structure. Use existing matches for `contains_parent_ref` or `domain_gate.child_refs`; keep unresolved target slug hints deferred and do not write dangling parent or edge refs.
22
+ - `diagnostics.automatic_ownership_adjustments[]` and validation diagnostics are the mechanical structural-block ownership source of truth. Source-wide owned/shared defaults automatically demote non-content blocks such as navigation references, placeholders, front matter, marker quotes, embed tags, and embedded assets to `context_only` or `ignored`; submit an explicit `block_ownership[]` owned/shared entry only when such a block is primary citation evidence.
23
+ - When `pending-relation-refs` is present, inspect it before finalizing graph structure. Use existing/current matches for `contains_parent_ref` or `domain_gate.child_refs`; keep unresolved target slug hints deferred and do not write dangling parent, child, or edge refs. For navigation-only / placeholder-only sources, first preserve useful source/page identities as no-write Nodes with root-level `planned_sections: []` when an explicit retrieval need, graph need, or atomic/concrete title gives the page standalone retrieval value; this no-write Entity priority can apply even when every child ref is unresolved. Never put `planned_sections` inside `domain_gate`. Those kept placeholders need support through `context_only` blocks with `visible_to`, owned/shared evidence, or finalized graph support. If a placeholder/relation source is skipped entirely, still classify its coverable blocks with a source-wide `ownership_groups[]` rule, usually `ignored` for pure placeholders. `ignored` only disposes unused material and does not support a placeholder by itself. Domain placeholders may have `domain_gate.child_refs: []` when every child is still deferred. Only use `entity[term]` when the source title is an atomic term.
24
24
  - `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.
25
25
  - Keep cache-friendly prompt order: fixed protocol/schema first, existing knowledge lookup second, source evidence views third, current semantic payload last. Preserve CLI JSON order and do not add timestamps, random ids, scratch paths, or host paths to generated payloads.
26
+ - Workflow digest flags are stale guards. Follow returned `next_action.command` and omit optional digest flags unless the CLI asks for one; if an explicit digest is needed, recover it with `context workflow show --payload <name> --digest-only --format text`, not JSON parsing.
26
27
  - Node type, tag, fake-Entity, `domain`, and `action` gates are in `references/gates.md`.
27
28
  - Coarse reading density and neutral signal rules are in `references/density-profile.md`.
28
29
  - Candidate anomaly handling, `label_hint`, and `llm_slug_hint` reference rules are in `references/candidate-resolution.md`.
@@ -37,15 +38,19 @@ Use this only inside `/context:align`.
37
38
 
38
39
  Run `context align scan --format json`. Confirm `schema_version: "workflow.next-action-envelope.v2"`, then identify `next_action`, `views`, `workflow`, `route`, and `diagnostics`.
39
40
 
41
+ If the host truncates scan stdout but the preview includes top-level `next_action.command`, run that command. If `next_action` is not visible, rerun the scan command; do not recover host tool-result files.
42
+
40
43
  If no envelope is present, stop and surface the CLI output; do not reconstruct an align route from old prompt memory.
41
44
 
42
45
  ### Step 2 — Follow The Evidence Read Path
43
46
 
44
47
  Run the returned `next_action.command`. For structural align work this is normally `read-plan`; after that, follow the `read-plan` / `source-bundle` response's `next_action.command`.
45
48
 
46
- `read-plan` is the navigation surface. It chooses whether the next evidence read is a whole-batch `source-bundle`, a scoped source/window bundle, or an existing coarse-read route. `source-bundle` is annotated source text; read it and then author the requested align JSON yourself. Never pipe bundle text into `context align validate`.
49
+ `read-plan` is the navigation surface. It chooses whether the next evidence read is a whole-batch `source-bundle`, a scoped source/window bundle, or an existing coarse-read route. `source-bundle` is annotated source text; read it and then author the requested align JSON yourself, normally `align-structure-intent`. Never pipe bundle text into `context align validate`.
50
+
51
+ If `source-bundle` omits text for budget, `read_scope_complete: false`, `page.has_more: true`, or the final `source-bundle:end` annotation is missing, run its `next_action.command` before authoring.
47
52
 
48
- Read evidence through semantic CLI views, not shell parsing. Follow `page.next_command` for pagination. Use `--source`, `--heading`, `--window`, and `--token-budget` as view filters only. `--unwrap` removes workflow metadata; it does not expand a compact view into full detail.
53
+ 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.
49
54
 
50
55
  If a blocks view returns `align-blocks-read-incomplete`, `page.has_more`, or `truncated: true`, treat that response as a partial read. Do not finalize source-wide ownership or dense planned Sections from source-mapping/headings alone; continue the current detail view only when `page.next_command` is explicitly needed, otherwise return to the read-plan/source-bundle continuation.
51
56
 
@@ -61,19 +66,35 @@ Apply `references/gates.md` before authoring Nodes: classify Node type in order
61
66
 
62
67
  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.
63
68
 
69
+ For `node.title` and `node.summary`, follow `align-segments.generation_policy.language`. In Chinese workspaces, translate descriptive scaffold words such as architecture, strategy, lifecycle, overview, scheduling, high availability, and warning into Chinese while preserving product names, code identifiers, CLI flags, slugs, block_id tokens, and citation tokens exactly when needed. Do not copy an English source title into `node.title` merely because the source is English.
70
+
71
+ 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 `domain_gate.child_refs`.
72
+
64
73
  For large or batched payloads, use `references/density-profile.md` and `references/candidate-resolution.md` only when the CLI `next_action` asks for coarse-read or candidate-op payloads. Do not choose those stages yourself.
65
74
 
66
75
  ### Step 5 — Build The Payload Requested By `next_action`
67
76
 
68
- Use `next_action.input_schema` or the matching `context schema <name> --view minimal --format json` output to shape the payload.
77
+ Use `next_action.input_schema` and the matching `context schema <name> --view minimal --format json` output to shape the payload. If the minimal view exposes `required`, `enums`, `minimal_example`, and `field_guidance`, treat it as the authoring contract; read the full schema only when those fields are insufficient for an edge case.
78
+
79
+ For the default `align-structure-intent` path, produce one intent document with semantic Nodes, `section_groups[]`, `ownership_groups[]`, and edges. Let CLI generate `section_id` values and expand ownership groups into canonical defaults/exceptions. For long sources, do not hand-enumerate the largest ownership range; use one `{ source_id }` ownership group for the majority owner, then use `{ block_ids }` ownership groups for semantic exceptions. `block_ownership[]` is an advanced single-block patch path only when schema output or CLI diagnostics explicitly ask for it; it uses singular `block_id` and never `scope` or `block_ids`. Do not add `{ source_id, structural_role }` groups merely to mark front matter, navigation, placeholders, marker quotes, embed tags, or embedded assets as non-citation material; the source-wide default's automatic demotion handles those.
69
80
 
70
- For `submit_structure_decision`, produce one structure-decision document with finalized Nodes, document edges, planned Sections, and ownership. Prefer the strongest source-backed `section_kind` that fits the current schema priority chain; avoid planning an entire dense source as `description` when the evidence clearly contains examples, comparison tables, Q&A, decisions, specs, warnings, or principles. Treat kind precision as a drafting quality preference, not a reason to block an otherwise source-backed write. Keep only source-supported semantic decisions in the payload; leave mechanical repair and patch routing to CLI diagnostics.
81
+ Use only `block_ids[]` in `section_groups[]`. Do not invent heading/range/window selectors inside the intent. Treat source heading changes as section-planning signals: sibling sub-headings under a shared parent may stay in one Section when they form one coherent semantic topic; headings with no shared parent should usually split unless you intentionally want one Section to span them. The CLI reports cross-heading groups but does not rewrite your semantic grouping. If one semantic section spans non-contiguous citation-eligible blocks, align may accept the grouping, but finalized ownership will split it into compile draft-ready contiguous runs; hard citation-gap templates should stay separate. Every block you leave as `owned` or `shared` citation evidence must appear in some section group; otherwise reclassify it as `context_only` or `ignored`. If a no-write/navigation-only/placeholder-only Node is kept, set root-level `planned_sections: []` explicitly so the CLI knows this was intentional, and keep at least one supporting block as `context_only` with `visible_to` unless the Node already has owned/shared evidence or finalized graph support. `planned_sections` is a node field, not a `domain_gate` child. `ignored` is valid for skipped material or extra placeholder lines, but it does not create `context_sources` or unblock close by itself. If you skip a relation-only, navigation-only, or placeholder-only source after ruling out resolved Domain support and standalone retrieval or graph value, you still must classify every coverable block; use one source-wide `ownership_groups[]` rule with `ownership_role: "ignored"` or `context_only` instead of leaving the source absent from ownership. For Domain placeholders, put only resolved current/existing targets in `domain_gate.child_refs`; if all child refs are unresolved relation clues, use `child_refs: []` and leave the unresolved rows in pending-relation-refs. Do not turn a container placeholder into `entity[term]` unless the title itself is a useful atomic term.
82
+
83
+ Emit `depends_on` edges only when cited source blocks explicitly say one Node consumes, requires, calls, is configured by, or is downstream of another Node as a prerequisite, capability provider, upstream input, runtime dependency, or data-flow source. Direction is consumer/downstream -> provider/upstream. Do not create `depends_on` for parent/child containment, `Related`/`See also` lists, sibling co-occurrence, shared table membership, name similarity, or a plain mention without a dependency predicate. `edges[].evidence_blocks[]` must include the block that states the dependency; if the relationship matters but evidence is missing, leave the edge out or add an unresolved question instead of guessing.
84
+
85
+ Prefer the strongest source-backed `section_kind` that fits the current schema priority chain; avoid planning an entire dense source as `description` when the evidence clearly contains examples, comparison tables, Q&A, decisions, specs, warnings, or principles. Treat kind precision as a drafting quality preference, not a reason to block an otherwise source-backed write. Keep only raw-backed semantic decisions in the payload; leave mechanical repair and patch routing to CLI diagnostics.
86
+
87
+ Canonical `align-structure-decision` is not a parallel authoring path. Use it only when `next_action.input_schema` explicitly asks for it or when auditing/repairing canonical output returned by the CLI.
71
88
 
72
89
  For coarse-read, candidate-op, patch, ownership, or rescan actions, follow the command and schema in the returned `next_action`. Do not carry old candidate-table, decision-patch, or full-tree payload shapes forward.
73
90
 
74
91
  ### Step 6 — Validate And Submit
75
92
 
76
- Before finalizing a structure decision, run `context align validate --input - --format json`. If validate returns blocking diagnostics, repair the exact paths it reports and rerun validate. If validate returns a finalize `next_action`, submit the same validated payload to that command.
93
+ Before finalizing, run `context align validate --input - --format json` with the payload matching `next_action.input_schema`. If validate returns blocking diagnostics, repair the exact paths it reports and rerun validate. If validate returns a finalize `next_action`, submit the same validated payload to that command; do not copy compiled canonical JSON from validation output unless the CLI explicitly asks for canonical input.
94
+
95
+ After finalize succeeds, do not rerun the finalize submit command to confirm success. Use returned `payloads.*.show_command` values, or `context workflow show --payload finalized-ownership --unwrap --format json`, for read-only confirmation; then continue with the returned `next_action.command`, normally `context compile scan --format json`.
96
+
97
+ If finalize reports node reclassification hints, the submitted Node was changed by a semantic gate. Treat finalized ownership as the source of truth; status counts finalized Nodes, not submitted proposals.
77
98
 
78
99
  If any write is rejected, follow the returned `next_action` and `reason_code`. Do not retry by guessing direct/batched stages, forcing route bypasses, or editing workflow files.
79
100
 
@@ -83,7 +104,7 @@ If any write is rejected, follow the returned `next_action` and `reason_code`. D
83
104
  - [ ] Evidence was read through returned `next_action.command`, `how_to_explore[]`, or CLI schema/protocol commands only. If not, return to **Step 2**.
84
105
  - [ ] Node classification used the semantic gates in `references/gates.md`. If not, return to **Step 4**.
85
106
  - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
86
- - [ ] Structure decisions passed `context align validate --input - --format json` before finalize. If not, return to **Step 6**.
107
+ - [ ] The requested align payload passed `context align validate --input - --format json` before finalize. If not, return to **Step 6**.
87
108
  - [ ] No raw, cache, knowledge, `/tmp`, host tool-results, or workflow scratch files were read or written with generic tools. If violated, restart from **Step 1**.
88
109
 
89
110
  </procedures>
@@ -1,6 +1,6 @@
1
1
  # Candidate Resolution Rules
2
2
 
3
- Use these rules after reading candidate ledger and aggregate payloads, before `align-structure-decision`.
3
+ Use these rules after reading candidate ledger and aggregate payloads, before authoring the align payload requested by `next_action.input_schema`.
4
4
 
5
5
  ## Anomaly Signals
6
6
 
@@ -35,7 +35,7 @@ These hints are for audit and Agent DX. Copy them from ledger labels/titles when
35
35
 
36
36
  ## `llm_slug_hint` And Refs
37
37
 
38
- Use `llm_slug_hint` as the stable reference inside one `align-structure-decision` payload when final slugs may be normalized by the CLI.
38
+ Use `llm_slug_hint` as the stable reference inside one align payload when final slugs may be normalized by the CLI.
39
39
 
40
40
  Recommended pattern:
41
41
 
@@ -57,4 +57,4 @@ block_ownership:
57
57
  - owners: [local:data-region]
58
58
  ```
59
59
 
60
- Refs may point to `llm_slug_hint` or final `slug`; prefer `*_ref` fields when a schema provides them. If the CLI rejects an unknown ref, use the top-level envelope diagnostics (`issues[].expected_shape.available_node_refs`, `diagnostics.*.available_node_refs`, or the returned repair view) and resubmit the corrected `align-structure-decision` payload. `agent_hints[]`, when present, is only a cutover mirror and must not be the source of truth.
60
+ Refs may point to `llm_slug_hint` or final `slug`; prefer `*_ref` fields when a schema provides them. If the CLI rejects an unknown ref, use the top-level envelope diagnostics (`issues[].expected_shape.available_node_refs`, `diagnostics.*.available_node_refs`, or the returned repair view) and resubmit the corrected payload using the same `next_action.input_schema`. `agent_hints[]`, when present, is only a cutover mirror and must not be the source of truth.
@@ -7,19 +7,10 @@ This reference applies only when the current envelope asks for `next_action.kind
7
7
  | Profile | Use When | Agent Behavior |
8
8
  |---|---|---|
9
9
  | `macro` | A long source has many headings, sections, or broad topic shifts. | Create section proposals around major headings and preserve document-level anchors so later passes do not flatten scope. |
10
- | `meso` | Default for normal product, design, or operational documents with several related sections. | Produce section proposals for meaningful local units and neutral content signals for each anchor. |
10
+ | `meso` | Default for normal product, design, or operational documents with several related sections. | Produce section proposals for meaningful local units and preserve evidence anchors. |
11
11
  | `micro` | The source is fragmented, note-like, or dense with short independent claims. | Keep section proposals narrow and avoid bundling unrelated blocks into one candidate. |
12
12
  | `single_pass` | The source is short enough that one read can safely discover all relevant structure. | Still emit the `align-coarse-read` artifact, but keep anchors minimal and avoid over-segmentation. |
13
13
 
14
- ## Content Signals
14
+ Treat Markdown heading changes as section-planning hints, not hard boundaries. Sibling sub-headings under a shared parent can remain in one `section_groups[]` entry when they form one coherent semantic topic for that parent. Headings with no shared parent should usually split unless you intentionally want one Section to span them. When a dense source has many headings, split by heading first, then merge adjacent or sibling groups only when the merged Section is still one coherent fact group.
15
15
 
16
- `content_signals` are neutral shape signals used later by action/domain gates. They must not directly claim `node_type`, tags, or recommendations.
17
-
18
- | Signal | Meaning |
19
- |---|---|
20
- | `temporal_density` | The text has timelines, phases, schedules, version changes, or ordered time references. |
21
- | `actor_density` | The text names roles, users, teams, systems, services, or operators that perform work. |
22
- | `step_density` | The text contains ordered steps, procedures, phases, checklists, or how-to flow. |
23
- | `directive_density` | The text contains imperatives, policies, constraints, must/should language, or runbook-like instructions. |
24
-
25
- Use only `high`, `med`, or `low` based on the local section text. The canonical middle value is `med`; do not write `medium`. High `step_density` plus explicit actors and outcomes is useful evidence for an Action Gate, but it is not enough by itself to emit an `action` Node.
16
+ Do not emit kind/tag/content signals from coarse-read. Action/domain gates are decided later from the source-bundle evidence and schema gate fields, not from density metadata.