Skip to content

feat(engine): task.save lists the capabilities a task's steps need in requires (#2818) - #2963

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:feat/2818-task-save-requires
Nov 25, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:feat/2818-task-save-requires

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #2818 (the writer; the reader was #2867). task.save now writes requires with the capabilities the task's steps need, found through the walk a project uses for its tasks (COMMAND_CAPABILITIES and table-export-order, through command_uses), so a model.run step with its graph inline and a script line are covered. A task whose steps need nothing is written byte for byte as before (the task is serialized as a struct, so its keys keep their order).

  • project_capabilities.rs: task_capabilities(steps), next to the table it reads. The project's own code is left as it is.
  • items.rs: the task's file is the task plus requires when it is not empty, as a model's file is (model::to_file).
  • docs/maintaining.md: a task file lists and checks requires; models inside a task's steps leave the exception.

Why the writer ships in the release that carries the reader (0.9.0), not one after: a RustGIS older than #2867 ignores the key, exactly as it reads today's files (Task doesn't deny unknown fields), so nothing it reads changes.

Reaches: the desktop app and the browser (Save Task), the command line, Python, the Assistant, MCP, scripts and plugins (task.save). Undo: not applicable (a file).

Not in this PR: the presentation and notebook readers, which #2818 allows separately.

Testing

  • crates/engine/src/tests/task_files.rs: a task that needs nothing is written with the same bytes as before and a task with requires keeps its keys in order (both failed with the first version, which sorted the keys); a step, the same step twice, a script line, a table export order and an inline model graph each list their capability once, and equal what a project holding the same task saves; a saved task imports and one whose requires is edited to an unknown name is refused by name. Without the writer, the listing test fails; the rest pin what already held.
  • checks.sh on rustgis-engine: fmt, clippy, nextest (9599 passed), doctests, layers, schema, all exit 0.
  • git merge-tree against feat(layout): a layout's page takes a colour #2950 and feat(layout): section lines on a map frame (#2863 part 1) #2872 (both touch files near this one): no conflict.

UI evidence

No visible UI change.

Related issue

Closes #2818.

Summary by CodeRabbit

  • New Features

    • Saved task files now include a requires list when their steps need specific capabilities. The list covers capabilities used by commands, inline model tools, and table-export settings, with each capability listed once. Tasks with no requirements keep the existing file format.
    • Importing a task now refuses files that declare unknown capabilities and reports the capability name.
  • Documentation

    • Updated guidance to explain capability declarations and validation for saved task files.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Task output now derives required capabilities from saved task steps and adds a requires field when the list is non-empty. Tests cover capability discovery, serialization, and import rejection of unknown requirements. The maintenance guide documents these task-file behaviors.

Changes: Saved task capability requirements

Layer / File(s) Summary
Derive and serialize task requirements
crates/engine/src/project_capabilities.rs, crates/engine/src/project.rs, crates/engine/src/cmd/items.rs
The capability walk derives requirements from task steps, including table-export ordering. Task output uses the walk and omits requires when the list is empty.
Verify saved task requirements
crates/engine/src/tests/task_files.rs, docs/maintaining.md
Tests cover serialization order, capability discovery, and rejection of unknown requirements. The maintenance guide describes task save and import behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant task.save
  participant task_json
  participant task_capabilities
  participant COMMAND_CAPABILITIES
  task.save->>task_json: serialize task output
  task_json->>task_capabilities: derive requirements from steps
  task_capabilities->>COMMAND_CAPABILITIES: match commands and predicates
  COMMAND_CAPABILITIES-->>task_capabilities: capability entries
  task_capabilities-->>task_json: requirement list
  task_json-->>task.save: JSON with requires when non-empty
Loading

Possibly related issues

  • opengeos/RustGIS#2758 — The task capability walk covers inline model.run graphs and script lines, addressing the missing discovery described in this issue.
  • opengeos/RustGIS#1405 — Task files now list capabilities used by their saved steps.

Possibly related PRs

  • opengeos/RustGIS#2835 — Extends capability discovery into inline model.run graphs, which the task capability walk uses.
  • opengeos/RustGIS#2246 — Defines the table-export-order capability included by the task capability walk.
  • opengeos/RustGIS#2867 — Adds task import checks for unknown capabilities, matching the requirements written by this change.

Suggested reviewers: mavrick-f, choupeanut

Merge Risk: Minimal · up to 5091a

Saved tasks now record the capabilities their steps need. Tasks that need none are saved exactly as before. No merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #2818 asks for four coding changes: (1) task.save writes requires from the steps' needs, (2) task.import refuses unknown required capabilities by name, (3) models inside task steps are checked t… Confirm at the reviewed head that the task import path (the reader from #2867) refuses unknown capabilities in a task's inline model.run graph steps, for example by a test that saves or edits a task whose model.run graph uses an unknown req…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: task.save now writes a requires list with the capabilities its steps need. It also carries the engine scope and the issue number. The changeset matches this descriptio…
Description check Passed The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section correctly states there is no visible UI change. The Summary e…
Out of Scope Changes check Passed All changed files relate to #2818. items.rs changes the task file writer. project_capabilities.rs adds task_capabilities, which reuses the existing project capability table. project.rs re-exports task…
Full details: Title check

Explanation

The title names the main change: task.save now writes a requires list with the capabilities its steps need. It also carries the engine scope and the issue number. The changeset matches this description: a new task_capabilities function, the items.rs serializer change, tests, and a docs update.

Full details: Description check

Explanation

The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section correctly states there is no visible UI change. The Summary explains the change and its scope. The Testing section lists the new tests and the checks.sh run. The Related issue section cites #2818. The description is detailed and specific.

Full details: Out of Scope Changes check

Explanation

All changed files relate to #2818. items.rs changes the task file writer. project_capabilities.rs adds task_capabilities, which reuses the existing project capability table. project.rs re-exports task_capabilities for crate use. tests/task_files.rs tests the writer and import behavior. docs/maintaining.md updates the task exception text. The PR does not change presentation or notebook readers, which the issue allows to be separate. No unrelated change was found in the summary.

Full details: Linked Issues check

Explanation

Issue #2818 asks for four coding changes: (1) task.save writes requires from the steps' needs, (2) task.import refuses unknown required capabilities by name, (3) models inside task steps are checked the same way, (4) docs drop the task and model exception. Writer (1): met. The diff adds task_capabilities in crates/engine/src/project_capabilities.rs, which walks COMMAND_CAPABILITIES and table-export-order, and items.rs writes requires after steps only when non-empty. Tests in crates/engine/src/tests/task_files.rs cover direct steps, repeated steps, script lines, table export order, and inline model.run graphs. Import (2): the test that an edited unknown requirement is refused by name is present, but the reader code is not changed in this PR. It is attributed to #2867, which I could not verify at the base. Models (3): the PR text says models in task steps now leave the exception, but this PR has no reader change for them, and I could not confirm that the existing import path walks inline model graphs. Docs (4): docs/maintaining.md at head drops the model exception for tasks, which is met. The base commit could not be read, so the pre-existing reader behavior is unverified.

Resolution

Confirm at the reviewed head that the task import path (the reader from #2867) refuses unknown capabilities in a task's inline model.run graph steps, for example by a test that saves or edits a task whose model.run graph uses an unknown requirement and checks that import names it. Alternatively, confirm the base commit and show the reader code that performs this check.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit saves a task with care,
Its needed capabilities written there.
Steps and scripts declare their need,
Inline models join the deed.
Unknown names stop at the gate,
The guide now tells the task-file state.<!--fixed_issue_severity>Medium</fixed_issue_severity>-->

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 06ca14a6-6eab-44b6-a238-bb412cbf886e
Commits

Reviewing files that changed from the base of the PR and between 91c6522 and 5091aef.

Files selected for processing: 2

  • crates/engine/src/cmd/items.rs
  • crates/engine/src/tests/task_files.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment thread crates/engine/src/cmd/items.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the staged AGENTS.md and metadata, and the surrounding code: project_capabilities.rs (the existing project walk and COMMAND_CAPABILITIES), durable::output, the task import path, and the task tests. The prior-review file has no threads, so nothing was left out as already raised.

Bugs

  • None found. task_capabilities uses the same predicates as the project-level walk for tasks (command_uses, including inline model.run graphs and script.run lines via the existing script.run arms). table-export-order is not in COMMAND_CAPABILITIES, so it isn't counted twice. The flatten struct keeps key order, and the empty-list skip keeps the old bytes. Confidence: medium-high. I could not compile or run the tests here (no shell).

Security

  • None found. The walk is bounded (MAX_NODES, MAX_EDGES, and script.run is not recursed into), and it only reads the task's own steps.

Performance

  • None found. The walk is one pass per capability over the task's steps, and the steps are bounded by the task's size.

Quality

AGENTS.md

  • No rule break found. Writer and reader ship in the same release (0.9.0). The docs rule "reading a new version ships at least one release before anything writes it" is about format versions, and this PR does not change the format. The PR body argues that old readers behave as they do today, so I'm not raising it as a violation. Confidence: low-medium. The release manager may want to confirm the ordering.

Change size

Compared with main (merge base ced7c3d to PR head 91c6522): 5 files changed, all modified. Size before 441.3 KB, size after 446.1 KB, change +5.2 KB.

Measure Value
Files changed 5 (added 0, modified 5, removed 0, renamed 0)
Size before 441.3 KB
Size after 446.1 KB
Total size change +5.2 KB
Path Before After Change
crates/engine/src/tests/task_files.rs 11.2 KB 15.0 KB +3.8 KB
crates/engine/src/cmd/items.rs 101.7 KB 102.3 KB +679 B
crates/engine/src/project_capabilities.rs 152.5 KB 153.1 KB +639 B
docs/maintaining.md 22.3 KB 22.3 KB +22 B
crates/engine/src/project.rs 153.7 KB 153.7 KB +19 B

…nores requires (opengeos#2818)

The byte-identity test also runs a float and a non-ASCII string through the new writer.
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security problems or AGENTS.md violations in the changed code. I posted no inline comments: the only remaining points are small quality items, listed below. I could not compile or run the tests (no shell here), so the claim that the suite passes rests on the PR description, not on my run.

Bugs

None found. Confidence: high (the code is read, not compiled).

What I checked:

  • task_capabilities walks the steps with the same command_uses and command_uses_table_export_order calls that uses_commands and the project's required use for tasks, so a task file and a project holding the same task list the same names. The inline model.run graph and script-line cases are covered by the same path.
  • Every name the writer can emit (COMMAND_CAPABILITIES plus table-export-order) is in project::CAPABILITIES, so task.import will not refuse a file this writer produced.
  • to_json is still used at lines 1881, 1887 and 1998, so the -D warnings builds get no dead-code error.
  • task_json is the only task writer. Both item_output callers (lines 1831 and 1987) go through it, so desktop, browser, CLI, Python and MCP all get requires.
  • Serde's flatten keeps the field order the tests assert. Tasks with no capabilities produce the same bytes as before (skip_serializing_if).
  • Line lengths are under max_width = 140.

Security

None found. No new input parsing, paths or secrets. The task walk uses existing bounded checks (MAX_NODES, MAX_EDGES).

Performance

None worth raising. The walk runs once per save, over a handful of steps and about 26 checks.

Quality

  • task_capabilities (project_capabilities.rs:139) repeats the task part of the project's required computation (project_capabilities.rs:83–86). Sharing one helper would stop the two copies drifting apart. Low priority; this is a refactor, so it can wait for the release quality pass.
  • The new tests in tests/task_files.rs are sound. The byte-identity test compares against the same serializer, which is the intended pin. The ThreadId in the temp file name is fine.

AGENTS.md

None found. Checked against the rules that apply:

  • No project schema change is needed, because Task and TaskStep are unchanged.
  • No command surface change, so command-surface.txt needs no update.
  • The docs/maintaining.md text matches the new behaviour.
  • The PR states which surfaces it reaches.
  • Undo does not apply: a saved file is not a layer or project change.

Earlier review threads

One earlier concern was left alone: the task_json doc comment wording (items.rs:436). The thread is outdated, and the current text already contains its suggestion.

Change size

Compared with main (merge base ced7c3d to PR head 5091aef). Sizes below are from pr-context/stats.json.

Measure Value
Files changed 5 (0 added, 5 modified, 0 removed, 0 renamed)
Size before 441.3 KB
Size after 446.6 KB
Total size change +5.3 KB
Path Before After Change
crates/engine/src/tests/task_files.rs 11.2 KB 15.0 KB +3.9 KB
crates/engine/src/cmd/items.rs 101.7 KB 102.4 KB +777 B
crates/engine/src/project_capabilities.rs 152.5 KB 153.2 KB +639 B
docs/maintaining.md 22.2 KB 22.3 KB +22 B
crates/engine/src/project.rs 153.7 KB 153.7 KB +19 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2963/
Web app https://preview.rustgis.app/pr-2963/app/
Commit 5091aef

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 25, 2026
Merged via the queue into opengeos:main with commit c91a75b Nov 25, 2026
30 checks passed
@jgregoriorincon
jgregoriorincon deleted the feat/2818-task-save-requires branch November 25, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saved task files don't list or check the capabilities their steps need

1 participant