Add a Behave scenario that adds an fs-directory resource at a seeded
directory via the CLI. This exercises the if-children branch in
resource_add (lines 857-887 of resource.py), including _short_resource_id,
_format_child_status, and the Rich child table rendering — all previously
uncovered because no existing scenario produced auto-discovered children
through the resource add command path.
ISSUES CLOSED: #6464
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
- Always rollback session unconditionally in auto_discover_children
except blocks (both ResourceNotFoundRepoError and OperationalError/
SQLAlchemyDatabaseError), regardless of commit/own_session flags.
This ensures @database_retry retries with a clean session and callers
continue to see the original DatabaseError instead of
sqlalchemy.exc.PendingRollbackError.
- Remove unused 'auto_exc' binding in register_resource's auto-discovery
exception handler (use bare 'except Exception:' instead).
- Move all 'from datetime import UTC, datetime' imports from inside
function bodies to module-level in
resource_registry_service_coverage_steps.py.
ISSUES CLOSED: #6464