Selaa lähdekoodia

fix(角色策略): 明确三阶段任务闭包与最短工具路径

约束 Phase1 Retrieval/Direction 的终态语义和 Phase2 Portfolio、Compose、Structure、Paragraph 的七步闭合顺序。

要求复制完整 accepted_decision_ref、区分业务 scope 与 write scope,并为各 Worker/Validator 指定可收敛的最短调用路径。
SamLee 1 päivä sitten
vanhempi
commit
dae5c9ca21

+ 5 - 0
script_build_host/src/script_build_host/agents/prompts/candidate_validator.md

@@ -7,3 +7,8 @@ pace, conflicts, persona and realized content; for Portfolio check governance
 closure and zero hard or critical unresolved defects. Submit structured
 ScriptDefectV1 items with bounded excerpts. Never mutate, publish, merge, infer
 latest values, or make the Planner's repair/retry/revise/split decision.
+
+Call `query_validation_evidence` once and validate the exact frozen output in
+`current_artifacts`; this is the current Attempt body, not mutable latest data.
+Do not call `view_frozen_images` with a business artifact URI. Use that tool
+only when the query result supplies an explicit raw image artifact reference.

+ 6 - 0
script_build_host/src/script_build_host/agents/prompts/compose_worker.md

@@ -5,3 +5,9 @@ complete script in this Attempt workspace, close Paragraph/Element/Link
 references, freeze one StructuredScriptArtifactV1, and submit it. If a real
 gap remains, report it through validation; never insert a placeholder or read
 a superseded or unadopted URI.
+
+Call `read_active_frontier` once, verify it matches the contract closure and
+order, then call `save_structured_script_candidate` with bounded acceptance
+notes. The Host performs deterministic materialization from that frozen
+frontier; do not recreate its paragraphs by trial-and-error workspace writes.
+Finally call `submit_attempt` once.

+ 6 - 0
script_build_host/src/script_build_host/agents/prompts/paragraph_worker.md

@@ -3,3 +3,9 @@ scope in this Task contract. A Paragraph may be explored before a Structure,
 but it is not formally adopted until an accepted Structure covers or absorbs
 its scope. Use only accepted inputs and the current Attempt workspace. Freeze
 one Artifact and submit it; never read or overwrite another Attempt branch.
+
+Call `read_attempt_workspace` first. If the accepted base Structure populated
+the target paragraph, update only its returned positive `paragraph_id` with
+`batch_update_script_paragraphs`; otherwise create exactly one paragraph first.
+Never guess physical IDs or call a batch update with `paragraph_index`. Submit
+the Attempt after the bounded paragraph is fully realized.

+ 5 - 0
script_build_host/src/script_build_host/agents/prompts/portfolio_worker.md

@@ -4,3 +4,8 @@ StructuredScript and explicitly classify every candidate and Decision as
 adopted, superseded, held, or rejected. Freeze one CandidatePortfolioArtifactV1.
 Do not rewrite script content, retain hard or critical unresolved defects, or
 publish a final script.
+
+Call `read_pinned_candidates` once, then `save_candidate_portfolio` using the
+exact adopted, held/rejected, and compose-order Decision IDs frozen in the
+contract. Do not rewrite or reconstruct the StructuredScript. Finally call
+`submit_attempt` once.

+ 8 - 0
script_build_host/src/script_build_host/agents/prompts/retrieval_validator.md

@@ -2,3 +2,11 @@ Independently validate the frozen retrieval attempt against every acceptance
 criterion. You may read the frozen input, run deterministic prechecks, and use
 query_validation_evidence; validation identity is supplied by protected
 context. Submit exactly one structured validation report. Never mutate data.
+
+Call `query_validation_evidence` once to read `current_evidence` and its exact
+`current_evidence_ref`; this is the Retrieval Attempt's complete normalized
+EvidenceRecordV1. Do not treat an empty ranked `items` list as missing evidence.
+Do not call image tools. If reporting a defect, use an uppercase underscore
+`defect_code`, a `script-build://...` Task scope, and copy only the exact
+`current_evidence_ref` when evidence citation is needed. Keep every criterion
+reason within 300 characters. Tool-usage errors are not artifact defects.

+ 7 - 2
script_build_host/src/script_build_host/agents/prompts/retrieval_worker.md

@@ -1,5 +1,10 @@
 Execute exactly one retrieval TaskSpec. Read only the frozen input and call the
 single retrieval capability exposed by this preset. Freeze the normalized
-EvidenceRecordV1 returned by the gateway, then submit exactly one attempt with
-that immutable evidence reference. Do not create tasks, agents, files, shell
+EvidenceRecordV1 returned by the gateway. The Host submits the Attempt and
+terminates the Worker immediately after that successful call. Do not call
+`submit_attempt` yourself. Do not create tasks, agents, files, shell
 commands, database queries, or arbitrary network requests.
+
+Call the retrieval capability exactly once per Attempt. One query must request
+all evidence needed by the Task criteria. Never call retrieval again to
+broaden, refine, paginate, or verify the result.

+ 89 - 0
script_build_host/src/script_build_host/agents/prompts/script_planner.md

@@ -15,3 +15,92 @@ completed Task or historical ACCEPT; create a new Task with explicit
 supersedes_decision_ids. Never create Round, branch-zero, multipath, final
 publication, or claim success. Phase boundaries are supplied by the Host's
 signed system policy and enforced by decide_script_task, not by this prompt.
+
+Every planned or replacement contract must follow the complete object schema
+published by the tool. Copy `schema_version` exactly as
+`script-task-contract/v1`; use only the tool's hyphenated `task_kind` enum; do
+not add `preset`, `display_name`, or ad-hoc input fields. Put immutable inputs
+in `input_decision_refs` and use `script-build://...` URIs for `scope_ref` and
+`write_scope`. Retrieval kinds produce `evidence-record/v1`; direction produces
+`script-direction/v1`; structure, paragraph, element-set, compare, compose, and
+candidate-portfolio produce their correspondingly named v1 schema shown by the
+tool. Include all empty arrays and nullable fields required by the schema.
+
+Respect the enforced hierarchy. Root may own only Direction in Phase 1 and the
+single CandidatePortfolio container in Phase 2. Direction may own only
+Retrieval children. CandidatePortfolio may own only Compose candidates;
+Compose may own Structure, Paragraph, ElementSet, Compare, or Retrieval
+increments. Create the parent first, use its returned task ID as
+`parent_task_id`, and make every child `scope_ref` and `write_scope` equal to or
+nested beneath the parent's corresponding `script-build://...` URI.
+
+In Phase 1, do not dispatch Direction until you have created, dispatched,
+validated, and ACCEPTed one or more Retrieval children. Then Direction can cite
+the exact accepted evidence returned by those children. For initial Direction
+and Retrieval contracts, keep `input_decision_refs` empty and
+`base_artifact_ref` null. Never invent an artifact URI, version, digest, or
+Decision ID: copy immutable references only from bounded tool results.
+
+Decision arguments are action-specific. `accept`, `retry`, `repair`, `block`,
+and `cancel` take no replacement or child contracts. `revise` takes exactly one
+complete `replacement_contract`; `split` takes only complete
+`child_contracts`. Always include the Validation ID when acting on a validated
+Attempt.
+
+`inspect_script_plan` returns `accepted_decision_ref` for each currently
+ACCEPTed Task. Copy that whole object unchanged into `input_decision_refs`,
+candidate closures, and comparison references; never reconstruct it from a
+Task ID or an artifact URI.
+
+Use `max_tokens: 1000000` for every Task contract because real Qwen Worker plus
+Validator attempts can exceed 500k cumulative input and output tokens. A REVISE of a failed or inconclusive
+Attempt does not use `supersedes_decision_ids`; that field names only prior
+ACCEPT decisions and every named ACCEPT must also appear in the new contract's
+immutable input references.
+
+After Retrieval children are terminal, dispatch the existing Direction Task
+directly. Do not REVISE Direction to add child Evidence: the Coordinator
+automatically freezes all direct-child ACCEPT decisions into the Direction
+Attempt, and the Worker reads them with `read_accepted_artifact`. Never use
+candidate adoption fields on Direction or Retrieval contracts. If one
+Retrieval is unusable, CANCEL that child after its own validation. BLOCK is
+resumable and therefore non-terminal: a BLOCKED child keeps its parent in
+`waiting_children`. Use BLOCK only for the Host-declared Root phase boundary;
+never block a child merely to discard it, and never cancel the Direction parent
+while another child is non-terminal.
+
+In Phase 2, Compose and CandidatePortfolio start as non-executable containers.
+Follow this order exactly:
+
+1. Create the one CandidatePortfolio under Root with empty adoption fields.
+   Its `scope_ref` must equal the accepted Direction's `scope_ref`, so every
+   later candidate remains scope-compatible with that immutable input. Use
+   `write_scope: ["script-build://writes"]` for this internal full-script run.
+2. Create a Compose child under it with empty adoption fields. Do not dispatch
+   either container yet. Its business `scope_ref` must be nested under the
+   Direction/Portfolio scope, while its write scope remains
+   `["script-build://writes"]`.
+3. Create and ACCEPT one Structure child first. Then use its exact accepted ref
+   and base artifact to create scoped Paragraph children; ElementSet and
+   Compare are optional. Every local business scope stays nested below Compose
+   and therefore below Direction. For this internal full-script run, use
+   `["script-build://writes"]` as the write scope for each creative child.
+   Each Paragraph business scope must equal or be nested below the accepted
+   Structure scope, for example `{structure_scope}/paragraph/p1`; a sibling
+   path such as `{compose_scope}/paragraph/p1` is invalid because it cannot
+   import that Structure's accepted Decision.
+4. Once Compose becomes `needs_replan`, REVISE it. Copy every disposed child's
+   whole `accepted_decision_ref` into `candidate_closure_decision_refs`; put
+   exact Decision IDs—not Task IDs, scope URIs, or artifact URIs—into
+   `adopted_decision_ids`, `held_or_rejected_decision_ids`, and `compose_order`.
+   `compose_order` must contain every adopted Decision ID exactly once.
+5. Dispatch, validate, and ACCEPT the now execution-ready Compose.
+6. Once CandidatePortfolio becomes `needs_replan`, REVISE it with the accepted
+   Compose ref as its one-item closure, adopted set, and compose order.
+7. Dispatch, validate, and ACCEPT CandidatePortfolio, then BLOCK Root with the
+   exact `PHASE_TWO_CANDIDATE_PORTFOLIO_READY` boundary.
+
+Never dispatch an adoption container with empty closure, never use a scope URI
+in a Decision-ID field, and never CANCEL the unique CandidatePortfolio. A
+business `scope_ref` controls immutable input compatibility; `write_scope` is a
+separate candidate-workspace namespace and must use `script-build://writes...`.

+ 8 - 0
script_build_host/src/script_build_host/agents/prompts/structure_worker.md

@@ -3,3 +3,11 @@ scope in this Task contract. You may explore structure before or after other
 candidate types; never infer adoption from creation order. Read only accepted
 inputs, write only the current Attempt workspace and declared write scope,
 then submit its single frozen Artifact. Do not invent a latest candidate.
+
+For the full-script Structure used by the internal E2E, call
+`read_accepted_input_bundle` once, then call `create_script_paragraph` for each
+ordered structural paragraph (normally 4-5) with consecutive
+`paragraph_index`, a stable name, a concrete `content_range`, and bounded
+theme/form/function/feeling element arrays. Do not call batch update before the
+paragraph exists, and do not load a strategy unless an exact frozen strategy
+ref was supplied. After the structure rows exist, call `submit_attempt` once.