Skip to content

Workflow Configuration

Stage configuration on this page applies to the shared acceptance engine; examples where the model directly calls Check / Complete assume single mode. For multi callers and submission boundaries, see the role tool matrix.

A workflow consists of a set of stages executed in sequence. Each stage describes tasks, reference files, expected outputs, and a Checker; the Agent can call Check to view feedback, then use Complete to perform final acceptance and proceed. If a stage fails, it should first be fixed according to the Checker's diagnosis before retrying.

Before completing a stage, use SetCurrentStageJournal to record the work summary, artifacts, check results, and unresolved issues. A successful Check prompts for a missing journal; Complete returns immediately without running Checkers when the journal is missing. Record it and call Complete again to run final validation and applicable gates.

1. ToffeeUT Workflow Example

For new verification, use ucagent toffee-ut. The table below shows ToffeeUT's 21 top-level stages. The runtime Stage Manager flattens parent and child stages, so indices used by --skip, hmcheck_set, and GoToStage must come from status or hmcheck_list in the active run.

Top Index Stage Default Status
0 requirement_analysis_and_planning Executing
1 dut_function_understanding Executing
2 functional_specification_analysis: behavior groups, requirements, checkpoints, line mapping Line mapping skipped when no input documents exist
3 functional_specification_refine Executing
4 static_bug_analysis Executing
5 dut_wrapper_implementation: DUT creation, pytest fixture Executing
6 coverage_model_implementation: coverage groups, coverage points, batch implementation Executing
7 test_environment_implementation: env, Bundle, Mock, and fixture Partially human-checked, default skip
8 basic_api_implementation Executing
9 reference_model_implementation Enabled by runtime_options.ut_reference_model=true
10 reference_model_fixture_imp Enabled by runtime_options.ut_reference_model=true
11 basic_api_functional_test Executing
12 create_test_case_templates Executing
13 comprehensive_verification_and_bug_analysis: batch implementation of test cases Executing
14 refine_test_cases_based_on_functional_points Executing
15 static_bug_validation Executing
16 generate_random_test_cases Executing
17 line_coverage_analysis_and_improvement Enabled by default: runtime_options.ut_line_coverage=true
18 verification_review_and_summary Executing
19 record_and_report_bugs Executing
20 follow_up_failed_cases Runs when runtime_options.ut_case_followup is reproduce or fix

Human environment-spec review, human environment-implementation review, and Mock stages are controlled by runtime_options.ut_human_env_spec_review, runtime_options.ut_human_env_review, and runtime_options.ut_mock_components; all default to false. Without documents, derived requirements remain inferred/open; a stage's presence or skipped status is not proof of verification. After loading their plugins, select Formal, Vibe, and Increment with --workflow formal:formal, unittest:vibe, and unittest:incremental. Their acceptance settings differ from the table above.

2. Stage Fields

The minimum stage structure is as follows:

stage:
  - name: analyze_project
    desc: "Analyze project and generate report"
    task:
      - "Read {DUT}/README.md"
      - "Write results to {OUT}/{DUT}_analysis.md"
    reference_files:
      - "Guide_Doc/project_analysis_guide.md"
    output_files:
      - "{OUT}/{DUT}_analysis.md"
    checker:
      - name: markdown_check
        clss: "UnityChipCheckerMarkdownFileFormat"
        args:
          markdown_file_list: "{OUT}/{DUT}_analysis.md"
          no_line_break: true
    skill_list: []
    force_use_skill: false
    skip: false
  • name: Stable stage identifier. LLMs recommend using it for filtering, history, and logs.
  • desc: Stage title; may contain template variables provided by the Checker.
  • task: Task list for the Agent. Clearly specify input, actions, output format, and completion criteria.
  • reference_files: Relative paths or globs in the workspace that the stage needs to read. If required reference files are missing at runtime, fix the configuration or input.
  • output_files: Paths or globs that must exist as outputs of the stage; each pattern must match a path; content correctness is still verified by the Checker.
  • checker: Verification gates executed in sequence. Complete can only proceed after all gates pass.
  • stage: List of sub-stages. A parent stage only enters parent stage acceptance after its sub-stages are completed.
  • skip: Whether to default skip; suitable only for stages clearly not applicable.
  • need_human_check: Wait for human review after passing the Checker.
  • skill_list: Specialized skills for the current stage. When a skill is enabled and the list is non-empty, a real list/read/use evidence is required by default; force_use_skill: false makes it optional.

Stage history stores regular output files and symbolic links themselves. Directory links are not traversed; file, dangling, absolute, and external links retain their original target strings, which are also used for history comparisons and content views. Targets inside the output tree are archived at their real paths. External targets are not included automatically, so storing a link does not establish target availability or successful execution. Sync roots and their ancestors must be real directories, and source and destination must not overlap. Avoid concurrent modifications to the output tree during archiving.

3. Configuration Loading and Template Variables

Configuration is loaded in the following order, with later layers overriding earlier ones:

  1. ucagent/setting.yaml
  2. ~/.ucagent/setting.yaml
  3. ucagent/core/locales/<lang>.yaml
  4. Task workflow baseline, selected explicitly or resolved from the workflow selector. It extends the framework mission prompts.
  5. Workspace ./.ucagent/setting.yaml
  6. File specified by --config (defaults to config.yaml if omitted)
  7. CLI arguments and --override

When selecting a plugin workflow, its configuration baseline is inserted after the language default configuration and before the workspace configuration; see Plugin Development and Release. The project configuration search scope includes the current startup directory, ~/.ucagent/, ucagent/launcher/presets/<lang>/, and the repository root; relative --config paths are not default relative to the workspace.

Later configuration layers replace each list as a whole. Use ref and expand below to build a complete list from reusable stages.

Common template variables:

Variable Meaning
{DUT} DUT subdirectory name
{OUT} Output directory under the workspace; ToffeeUT defaults to ut_project
{WORKSPACE} Absolute path of the current workspace
{GUIDE_DOC} Runtime Guide_Doc path in the workspace
{DOC_GEN_LANG} Document language, from template configuration

{OUT} comes from --output, the workflow's output value, or the framework fallback output, in that order. Use --output to change the output path for a run.

Environment variable substitution occurs during YAML loading, e.g., $(NEED_REF_MODEL: false); template variables like {DUT} and {OUT} are rendered after configuration parsing. Do not re-read raw environment variables at runtime to infer the already-parsed configuration.

Compose YAML Fragments

Place reusable stages in shared_stages.yaml alongside the declaring workflow. The target file has a YAML mapping at its root. A reference can select a mapping, list, or scalar.

stages:
  inspect:
    name: "inspect_{DUT}"
    desc: "Inspect the {DUT} interface"
    task:
      - "Read {DUT}/README.md"
  review:
    - name: "review_{DUT}"
      desc: "Review the {DUT} clock and reset"
      task:
        - "Record the clock and reset signals with label {LABEL}"
    - name: "summarize_{DUT}"
      desc: "Summarize the review"
      task:
        - "Write the results to {OUT}/{DUT}_review.md"

Compose one stage and a group of stages in the workflow. The resulting stage contains inspect_Adder, review_Mux, and summarize_Mux in that order.

1
2
3
stage:
  - '$(ref: ./shared_stages.yaml::stages.inspect, DUT=Adder)'
  - '$(expand: ./shared_stages.yaml::stages.review, DUT=Mux, LABEL="fast,debug")'
  • $(ref: file.yaml::key.path) preserves the target's YAML type. Use it as a mapping value or a list item. A list target occupies one position as a single value.
  • $(expand: file.yaml::key.path) splices the target list's items into the enclosing list in order, one level deep. An empty list removes the placeholder item.
  • Separate mapping keys with dots and use zero-based list indexes, as in stages.review[0].name. Write each directive as a complete YAML scalar. Quote the scalar and use the other quote style for parameter strings inside it.
  • ./ and ../ resolve from the declaring file's directory. Other relative paths try that directory first, then the startup directory, ~/.ucagent/, the launch presets for the current language, and the repository root. Absolute paths are also supported.
  • $(expand: app1:workflows/shared.yaml::stages.review) reads from the Plugin.root of application app1. Application IDs use the selected applications and the existing discovery rules for installed entry points and plugin.search_paths. Files and symlinks must stay inside the application root. A reference reads configuration data. The caller selects which workflows, tools, and runtime hooks to activate. Include shared YAML files as package data when publishing an application.
  • Append NAME=value parameters to override template values for the reference. Values use YAML types. For example, CC=123 is an integer, CC="123" is a string, and PORTS=[clk, rst] is a list. Each right-hand side uses the caller's context, so SOURCE={DUT}, DUT=Mux keeps the original DUT in SOURCE. The resulting context applies to the filename, key path, target content, and nested references. DUT=Mux changes only that reference's rendering.
  • The loader substitutes environment variables, renders templates, then selects and combines the fragments. Workspace, --config, and CLI overrides retain their usual precedence. An indexed override such as stage[1] sees the expanded list.

Supply startup settings such as the workflow selector, application search directories, and Agent role directly. A workflow template factory can supply variables for references. Its inputs must be available before it generates those variables. An output reference can select a path independent of {OUT} and factory variables. Missing files, keys or indexes, non-list expand targets, and cycles report the declaring file and configuration location at startup.

4. Skip, Rollback, and Human Review

Temporarily skip a stage:

ucagent <workspace> <DUT> --skip <runtime_stage_index>
ucagent <workspace> <DUT> --unskip <runtime_stage_index>

Used during runtime:

1
2
3
4
skip_stage <runtime_stage_index>
unskip_stage <runtime_stage_index>
tool_invoke GoToStage {"index":2}
hmcheck_set <runtime_stage_index> true

Replace 2 with the target runtime index.

The index is the flattened runtime index; do not continue using old numbers after modifying the workflow. GoToStage can only go back to stages already reached. Skipping a stage does not generate the files it should have produced; subsequent Checkers may fail as a result; only skip if the stage is confirmed not applicable.

5. Checker Configuration

Checker classes are specified via clss. Short names first resolve through the loaded plugins' Checker registry, then fall back to ucagent.core.checkers; full paths can point to custom modules. Load the providing plugin before using its short names: UnitTest domain Checkers are not generic core exports:

1
2
3
4
5
6
7
checker:
  - name: word_count
    clss: "my_workflow.checkers.WordCountChecker"
    args:
      file_path: "{OUT}/{DUT}_analysis.md"
      word_min: 200
      need_human_check: false

args are passed to the constructor and cfg is automatically injected; extra_args are set via set_extra after instantiation, cannot override existing attributes, and cannot replace constructor parameters or dedicated setters. Whether need_human_check takes effect depends on whether the Checker's constructor handles it; alternatively, set need_human_check: true directly on the stage.

See Custom Checker for full implementation, lifecycle, and structured diagnosis of custom Checkers.

6. Batch Stages

Stages for feature coverage, test templates, test cases, and line mapping use BatchTask to manage progress. When configuring batch tasks:

  • Set batch_size before constructing BatchTask;
  • Use the current source document and test files as the source of truth; checkpoints are only for recovery;
  • Resynchronize source/generated tasks after source file changes, delete or mark expired tasks;
  • Use Check to finish the current batch and expose the next one; in single the Agent calls Complete, while multi completes authorized substages and submits for framework finalization, without creating a new Sub for each batch;
  • Failure diagnosis returns only a bounded missing range and the next step; do not dump the entire source or logs into the prompt.

The functional line mapping stage has additional constraints: file_list is the authoritative input; do not treat Guide_Doc as a mapping target; every non-empty physical line must have FG/FC/CK or a justified IGNORE; an interval can have at most 100 lines. See Guide_Doc/dut_line_func_map.md and functional_line_mapping_gap_analysis in the default configuration.

7. Custom Workflows

Do not modify default.yaml directly within the package. Instead, copy the complete stage list that needs modification in the project configuration, or use --override for targeted temporary overrides:

1
2
3
ucagent <workspace> <DUT> \
  --config config.yaml \
  --override 'runtime_options.need_ref_model=True'

When adding a new stage, provide the task, reference document, output, and Checker simultaneously; if the stage requires skills, ensure that the same goal can still be achieved using standard tools and Checker when skills are disabled. Stage-specific skills, Guide_Doc, templates, and scripts collectively form the runtime contract, and any change at any layer should be tested synchronously.

8. Runtime Snapshot

After configuration parsing, UCAgent writes .ucagent/runtime_config.json to the workspace with resolved, non-sensitive fields such as DUT, OUT, runtime_options, and ucagent_python_path. Workflows that declare tools.RunTestCases.test_dir also publish test_output_dir and current_test_report, the shared pointer to the latest test report. Skill scripts read resolved settings and import paths from this snapshot. ucagent_python_path is the absolute import root containing the running package's ucagent/__init__.py.

The workspace .ucagent/ directory and all its contents are read-only to the Agent/LLM. The shared system prompt prohibits creating, editing, deleting, moving, or changing permissions on these files through file tools, backend-native tools, shell commands, or scripts. Custom system prompts retain this rule. Built-in file tools reject writes, and the generated opencode configuration also denies native edits to this directory; reads remain available. UCAgent and public workflow tools can still maintain snapshots, progress, and evidence. When the runtime environment blocks work, the model should report the diagnostic and required operator action. The operator repairs configuration or the environment and restarts UCAgent; the model must not edit runtime state or framework/plugin source to repair the environment. Running processes do not automatically reload configuration, system prompts, or backend permissions.

9. Loop Stall Protection

loop_settings.max_stalled_rounds accepts a nonnegative integer, defaults to 18, and can be disabled with 0. It detects stalls after each completed model round: repeated identical explicit Checker diagnostics in the same stage accumulate, as do rounds with no new Check/Complete and no changes to task files in the output directory. A normal CLI exit or read-only file activity does not count as progress.

A stage transition, a new passing check, or batch progress resets the counter; a changed explicit diagnostic starts a new count at 1. Without a new check, creating, modifying, or deleting an output task file also resets it. File changes use path, size, and modification time; hidden directories, symlinks, caches, logs, temporary files, and waveform data do not count as progress. If a new check still returns the same diagnostic, writing a file does not cancel that failure.

At the limit, UCAgent pauses --loop, displays the latest diagnostic when available, and preserves the task and artifacts for operator intervention. After repairing task inputs, enter loop in the console to resume with a fresh counter. Configuration or runtime environment changes require restarting UCAgent. This protection applies to completed model rounds; a single blocked backend call remains subject to backend timeout and interruption controls.

Next: Run the Mini Example first, then learn Custom Tools, Template Files, and Plugins as needed.