The previous attempt wrapped `register_resource` in `with session.begin():`
to guarantee parent + auto-discovered children commit atomically. That
pattern raises `sqlalchemy.exc.InvalidRequestError: A transaction is
already begun on this Session.` whenever a caller (e.g. the WF05
integration helper at `robot/helper_int_wf05_db_migration.py`) reuses a
single Session across multiple service calls — autobegin has already
opened the implicit transaction by the time `register_resource` runs.
This rewrites the flow to keep the simpler `session.commit()` pattern
that worked with shared sessions, but moves the commit to AFTER
`auto_discover_children` so any failure between `session.add(parent)`
and `session.commit()` rolls the whole transaction back via the
existing `except`/`session.rollback()` handlers. Atomicity is
preserved (parent is never persisted on an auto-discovery failure) and
shared-session callers no longer get the `InvalidRequestError`.
Also stabilises the `Service get_children returns auto-discovered
children for directory` scenario in `features/resource_cli_tree.feature`
by adding an explicit `Given a seeded directory exists at "/tmp/gcl"`
step that creates the directory and writes a sentinel file. Without
this seed the scenario depended on whatever happened to exist at
`/tmp/gcl` in the CI environment.
ISSUES CLOSED: #6464
The format_output() function returned a string that callers passed to
Rich console.print(), which wraps long lines at terminal width. This
injected literal newline characters into JSON string values (e.g. in
definition_of_done fields), producing invalid JSON that downstream
parsers could not decode (JSONDecodeError: Invalid control character).
For machine-readable formats (json, yaml, plain), format_output() now
writes the rendered output directly to sys.stdout and returns an empty
string. This preserves the exact serialization from json.dumps/
yaml.dump without Rich text processing artifacts.
Refs: #746
Add tree, inspect, link-child, and unlink-child subcommands to the
agents resource CLI group. Extend ResourceRegistryService with
link_child, unlink_child, get_children, and get_resource_tree methods.
- tree: display resource hierarchy with --depth, --type, and format options
- inspect: show resource details with --tree and --file options
- link-child/unlink-child: manage DAG edges with cycle detection
- 24 Behave scenarios, 4 Robot integration tests, ASV benchmarks
- CLI reference documentation in docs/reference/resource_cli.md