homerail-dag-patterns
GitHub用于选择和实例化 HomeRail DAG 设计模式,支持工作流控制流、网关语义及验证,适用于定期审查、并行执行等场景。
Trigger Scenarios
Install
npx skills add xiaotianfotos/homerail --skill homerail-dag-patterns -g -y
SKILL.md
Frontmatter
{
"name": "homerail-dag-patterns",
"description": "Select, inspect, instantiate, adapt, and validate HomeRail's built-in DAG design patterns.\nUse when an agent needs to design a reusable workflow for periodic triage, read-only issue diagnosis, planner\/worker fan-out,\non-demand executor\/advisor consultation, budget admission, graduated trust, standing-goal verification, quorum decisions, adversarial\nbuilder\/breaker review, monotonic improvement, or evidence-driven process evolution. Also use\nwhen deciding whether a workflow needs condition, loop, join, or while gateway semantics. Patterns describe control-flow invariants;\nfor stable live Actor panels, Surface updates, or follow-up commands, use homerail-dag-ops and a concrete presentation-aware Workflow."
}
HomeRail DAG Patterns
Treat a pattern as an abstract control-flow invariant, not a finished task template. Read the live Manager catalog before choosing one; it is the source of truth for parameters and generated topology.
Manager Agent Native Path
When running as the HomeRail Manager Agent, dedicated Manager Tools are the
shortest path for the operations below. The harness-native shell and hr --json
remain valid when they expose a needed command that has no dedicated Tool:
- Call
list_dag_patternsand comparetypical_uses,avoid_when, required primitives, and parameters. - Call
get_dag_patternfor the best candidate before changing Manager state. - Call
instantiate_dag_patternwith a stableworkflow_id, task-specific name, and typed parameters. Keep its defaultsync=trueonly after the selection is justified. - Call
create_and_runwith the returnedworkflow_id, an available runtime profile when needed, and a prompt containing task inputs and boundaries. - Use
get_run_statusfor progress. Never claim the DAG started without the real run id returned bycreate_and_run. - Use
list_dag_approvalsto find durable human-decision nodes. Never call the approval decision API yourself; present the proposal hash to the human. - Use
list_dag_triggersandfire_dag_eventfor Manager-owned schedules and idempotent event delivery. Always supply a stable idempotency key. - Use
get_dag_stateandset_dag_statefor versioned trust, budget, and goal ledgers. Preserve compare-and-set versions instead of overwriting blindly.
When adapting a pattern or authoring a custom workflow instead of using the generated instance unchanged:
- Call
get_dag_schema; do not rely on a remembered WorkflowSpec shape. - Emit
api_version: homerail.ai/v1with explicit top-level edges and terminal nodes. - Call
validate_dag_workflowand repair every structured diagnostic. - Call
sync_dag_workflowonly after validation returnsvalid: true. - Use the returned workflow revision and canonical hash as provenance.
For a simple one-step or linear task, do not force a pattern. Use an existing concrete orchestration or ask for the missing execution boundary.
Patterns do not imply presentation
A pattern instance defines topology and evidence flow. It does not gain a
Canvas Surface merely because its roles are called Actors or Workers.
orchestrator-workers in particular creates data-driven fan-out children with
no declared Skill, allowed_surface_views, report_surface_state, or
await_command. Use it for bounded parallel work whose results are aggregated.
When the request includes multiple live cards, parallel panels, continuous UI,
per-panel correction, or later follow-up, load homerail-dag-ops and select a
concrete Workflow that declares those presentation and lifecycle contracts.
Never promise that a generic pattern will update visible panels.
Inspecting results is the opposite case: it needs no declared presentation
contract at all. Every non-worker node (command, join, condition, and other
gateways) already has a structured, human-readable result at
GET /api/dag-status/<run_id>/node/<node_id>/result, and the node drawer plus
the Voice Cockpit dag_explorer widget render it by default. Do not author a
custom Workflow or generative UI just to make pattern results visible.
Select a Pattern
hr doctor
hr --json patterns list
hr --json patterns show <pattern-id>
Choose from constraints, not keyword similarity:
heartbeat: periodic work needs a cheap quiet exit, one selected action, and an independent verdict.issue-diagnosis: an untrusted issue snapshot must be checked against one explicit repository revision by independent reproduction, data-flow, and history reviewers, then arbitrated and unanimously verified without platform write-back.orchestrator-workers: one planner can split independent work that must aggregate before verification.executor-advisor: an executor should retain context and call a separately bound stronger model only at concrete ambiguity boundaries.budget-gate: measured usage must admit or stop work before execution.trust-ledger: autonomy varies per recurring skill based on measured history.standing-goal-sentinel: previously satisfied goals must be re-verified as standing invariants.quorum: expensive or risky action requires independent n-of-m agreement.sparring: a breaker, builder, and fresh verifier must remain separate.ratchet: one metric should improve through bounded attempts until a target.compost: repeated failures should produce a bounded set of proposals that remain behind human review.
Do not choose a pattern when the catalog's avoid_when conditions apply. A
small linear DAG is better than a pattern whose invariant is unnecessary.
Instantiate and Adapt
Generate YAML without syncing it first:
hr patterns instantiate quorum \
--set workflow_id=release-decision \
--set threshold=2 \
--output /tmp/release-decision.yaml
Adapt role names, prompts, evidence fields, and terminal actions to the task. Preserve the invariant that made the pattern useful:
- Keep voters independent in
quorum. - Keep planner, workers, and verifier distinct in
orchestrator-workers. - Keep advisor calls bounded and executor-owned in
executor-advisor. - Keep breaker, builder, and verifier distinct in
sparring. - Keep
ratchetbounded and metric-driven. - Keep policy changes behind review in
compost. - Keep the quiet path cheaper than the action path in
heartbeat. - Keep
issue-diagnosisrevision-pinned, credential-free, remote-read-only, and independent from issue-tracker triggers or comment permissions. Preserve its three investigation roles, explicit arbiter, and scenario/evidence/adversarial 3-of-3 verification policy. Only the reproduction role may modify a privatescratch/reproduction/sourcecopy for focused tests; the shared prepared source stays read-only. Treat issue comments that clarify state, ordering, provider, and credential reuse as part of the immutable snapshot. Consume the fixeddiagnosis.jsonandverification.jsonoutputs through generichr dag artifacts <run-id>/hr dag artifact <run-id> <name>commands.
Do not put provider, model, API key, or base URL fields in generated workflow YAML. Bind models through HomeRail database settings and runtime profiles.
Pattern instances are strict WorkflowSpec v1 documents. Keep the
api_version/kind/metadata/spec envelope, named port contracts, top-level
spec.edges, and explicit terminal outcomes when adapting them.
Compose Patterns
Compose only at explicit boundaries. Common combinations:
- Put
budget-gateorquorumbefore an expensiveorchestrator-workerssubgraph. - Put
trust-ledgerafter independent verification, not before execution alone. - Run
standing-goal-sentinelas a heartbeat action, but keep detection and repair as separate runs. - Feed failed runs and violated goals into
compost; never let Compost apply its own policy proposals.
When combining patterns, retain one structured handoff contract at each boundary. Avoid nested planners, duplicated verifiers, and loops without one clear stop predicate.
Use Gateway Semantics Correctly
condition: route one structured value by field and exact case.foreach: iterate a finite item list and emitdoneafter the last item; setresult_portto include every ordered iteration result in the final payload.join: aggregate all arrived inputs usingall,any, orn_of_m; configurefield,success_values, and threshold explicitly.while: compare the latest feedback value, emitcontinuewhile unmatched, and emitexhaustedaftermax_iterations.- A
kind: feedbackedge must declaremax_traversalsindependently of the run-wide edge limit. terminaldeclaresoutcome: success | failure | cancelledand never calls a model.commandruns an allowlisted argument vector with explicit timeout and typed evidence; the default allowlist is empty, and dynamic commands additionally requireHOMERAIL_DAG_ALLOW_DYNAMIC_COMMANDS=true.approvalpersists a proposal hash and waits for an authorized human actor. Declare a proposer actor distinct from every authorized approver. You may list pending approvals, but never decide one; direct the human tohr dag decidewith the displayed proposal hash.stateupdates a namespaced versioned ledger transactionally.budget_admitatomically reserves the positive amount selected byvalue_field; treat that amount as a conservative upper bound.fanoutcreates bounded run-local workers with explicit parallelism and completion policy. Setitem_fieldfor per-worker work andcontext_fieldfor immutable context shared by every worker and the aggregate verifier.- Agent
advisorsandworkspace_accessare runtime-enforced capabilities, not prompt suggestions. Workspace access validates final changes inside the workspace; external filesystem containment depends on the backend sandbox.
Data edges imply completion dependencies. Use depends_on only for a
control-only barrier that carries no payload. Join nodes wait for all declared
inputs before aggregating. Feedback edges must return to a foreach or while
node, remain statically bounded, and have an explicit dependency on that loop
gateway.
Validate Before Running
Inspect generated YAML, then sync and run it only when its task-specific prompts and runtime profile are complete:
hr dag schema
hr --json dag validate /tmp/release-decision.yaml
hr dag sync /tmp/release-decision.yaml
hr profile sync <profile.yaml> --workflow release-decision
hr run --workflow release-decision --profile <profile-id> --prompt "<task>"
hr dag watch <run-id> --timeout 600
hr dag handoffs <run-id> --content-limit 0
# Durable governance and state operations
hr dag approvals
hr dag decide <run-id> <node-id> --decision approved --actor <actor> --proposal-hash <hash>
hr dag triggers
hr dag trigger-event <event> --idempotency-key <stable-key>
hr dag state-get <namespace> <key>
hr dag state-set <namespace> <key> '<json>' --expected-version <version>
For a non-loopback Manager, set HOMERAIL_DAG_MUTATION_TOKEN in both the
Manager and the authorized CLI or Manager Agent environment before syncing
workflows/profiles or invoking any DAG write operation, including run lifecycle,
events, state, injection, and dynamic graph changes. This token does not
authorize approval decisions.
Require all of the following before calling the adaptation useful:
hr patterns instantiatereports a valid graph.- The YAML contains pattern id, version, source, and resolved parameters.
- Every branch reaches an explicit terminal node, possibly through a bounded feedback edge.
- Sync returns the expected immutable revision and canonical hash.
- A deterministic or fake-dispatch test exercises the topology.
- A real model-backed run exercises task semantics before production use.
- Terminal status and non-empty handoffs support the claimed result.
Version History
- 7f1ebb2 Current 2026-08-12 20:52


