From e4fb386be35ce6d99888d3abc3f26c8630f16d02 Mon Sep 17 00:00:00 2001 From: "Brent E. Edwards" Date: Thu, 26 Mar 2026 20:03:32 +0000 Subject: [PATCH 1/2] Merge remote-tracking branch 'origin/master' into tdd/m3-session-create-persist --- CHANGELOG.md | 6 ++ .../steps/tdd_session_create_persist_steps.py | 90 +++++++++++++++++++ features/tdd_session_create_persist.feature | 24 +++++ robot/e2e/e2e_session_create_persist.robot | 20 +++++ 4 files changed, 140 insertions(+) create mode 100644 features/steps/tdd_session_create_persist_steps.py create mode 100644 features/tdd_session_create_persist.feature create mode 100644 robot/e2e/e2e_session_create_persist.robot diff --git a/CHANGELOG.md b/CHANGELOG.md index d122e14a7..48f7f3251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +- Added TDD bug-capture tests for bug #1141 — session create does not persist + into subsequent session list output. Added a Behave scenario and Robot E2E + test with required tags (`@tdd_bug`, `@tdd_bug_1141`, `@tdd_expected_fail` / + `tdd_bug`, `tdd_bug_1141`, `tdd_expected_fail`) to assert create→list should + show one session. The underlying assertion currently fails and is intentionally + inverted until bug #1141 is fixed. (#1142) - Implemented `--mount` flag on `resource add container-instance`. Supports resource-reference mounts (`--mount local/api-repo:/workspace`) and host-path mounts (`--mount /var/config:/config:ro`). Multiple `--mount` diff --git a/features/steps/tdd_session_create_persist_steps.py b/features/steps/tdd_session_create_persist_steps.py new file mode 100644 index 000000000..083eb95a5 --- /dev/null +++ b/features/steps/tdd_session_create_persist_steps.py @@ -0,0 +1,90 @@ +"""Step definitions for TDD Bug #1141 — session create does not persist. + +Steps exercise the create-then-list round-trip through the real DI path. +All step names use the ``tdd1141`` prefix to avoid ``AmbiguousStep`` +collisions with existing session create/list steps. + +The shared ``Given a CLI runner using the real session DI path`` step +(from ``tdd_session_shared_steps.py``) handles setup and cleanup: +temp database, DI reset, structlog suppression, and cleanup registration. +""" + +from __future__ import annotations + +import json + +from behave import then, when +from behave.runner import Context + +from cleveragents.cli.main import app as main_app + + +@when("I tdd1141 invoke init with force yes") +def step_tdd1141_invoke_init(context: Context) -> None: + """Invoke ``init --force --yes`` via the root CLI app.""" + context.tdd1141_init_result = context.runner.invoke( + main_app, ["init", "--force", "--yes"] + ) + + +@then("the tdd1141 init should exit successfully") +def step_tdd1141_init_exits_ok(context: Context) -> None: + """Assert init exits with code 0.""" + result = context.tdd1141_init_result + assert result.exit_code == 0, ( + f"Expected init exit code 0, got {result.exit_code}.\nOutput:\n{result.output}" + ) + + +@when("I tdd1141 invoke session create") +def step_tdd1141_invoke_create(context: Context) -> None: + """Invoke ``session create`` through the root CLI app.""" + context.tdd1141_create_result = context.runner.invoke( + main_app, ["session", "create"] + ) + + +@then("the tdd1141 session create should exit successfully") +def step_tdd1141_create_exits_ok(context: Context) -> None: + """Assert session create exits with code 0.""" + result = context.tdd1141_create_result + assert result.exit_code == 0, ( + f"Expected session create exit code 0, got {result.exit_code}.\n" + f"Output:\n{result.output}" + ) + + +@when("I tdd1141 invoke session list with format json") +def step_tdd1141_invoke_list_json(context: Context) -> None: + """Invoke ``session list --format json`` through the root CLI app.""" + context.tdd1141_list_result = context.runner.invoke( + main_app, ["session", "list", "--format", "json"] + ) + + +@then("the tdd1141 session list should exit successfully") +def step_tdd1141_list_exits_ok(context: Context) -> None: + """Assert session list exits with code 0.""" + result = context.tdd1141_list_result + assert result.exit_code == 0, ( + f"Expected session list exit code 0, got {result.exit_code}.\n" + f"Output:\n{result.output}" + ) + + +@then("the tdd1141 session list output should report total {count:d}") +def step_tdd1141_list_contains_count(context: Context, count: int) -> None: + """Assert the JSON output reports the expected total session count.""" + output = context.tdd1141_list_result.output + try: + data = json.loads(output) + except json.JSONDecodeError as exc: + raise AssertionError( + f"Session list output is not valid JSON:\n{output}" + ) from exc + + actual = data.get("total") + assert actual == count, ( + f"Expected 'total': {count} in session list output, got {actual!r}.\n" + f"Full output:\n{output}" + ) diff --git a/features/tdd_session_create_persist.feature b/features/tdd_session_create_persist.feature new file mode 100644 index 000000000..f24b7dd7a --- /dev/null +++ b/features/tdd_session_create_persist.feature @@ -0,0 +1,24 @@ +@tdd_expected_fail @tdd_bug @tdd_bug_1141 +Feature: TDD Bug #1141 — session create does not persist for session list + As a developer + I want to verify that a session created via `agents session create` + appears in a subsequent `agents session list` + So that the persistence bug is captured and will be caught by a regression test + + The bug: `agents session create` succeeds (exit code 0) but the created + session does not appear when `agents session list` is invoked immediately + after. This test captures bug #1141 and intentionally keeps + `@tdd_expected_fail` so CI passes while the bug remains unfixed. + + Scenario: Init then create should make list total increase from 0 to 1 + Given a CLI runner using the real session DI path + When I tdd1141 invoke init with force yes + Then the tdd1141 init should exit successfully + When I tdd1141 invoke session list with format json + Then the tdd1141 session list should exit successfully + And the tdd1141 session list output should report total 0 + When I tdd1141 invoke session create + Then the tdd1141 session create should exit successfully + When I tdd1141 invoke session list with format json + Then the tdd1141 session list should exit successfully + And the tdd1141 session list output should report total 1 diff --git a/robot/e2e/e2e_session_create_persist.robot b/robot/e2e/e2e_session_create_persist.robot new file mode 100644 index 000000000..e5bf71b7e --- /dev/null +++ b/robot/e2e/e2e_session_create_persist.robot @@ -0,0 +1,20 @@ +*** Settings *** +Documentation TDD Bug #1141 — session create does not persist session +... for subsequent list. This test captures the bug described +... in #1141. The tdd_expected_fail tag inverts the result so +... CI passes while the bug is unfixed. Remove the tag when +... the fix is merged. +Resource common_e2e.resource +Suite Setup E2E Suite Setup +Suite Teardown E2E Suite Teardown + +*** Test Cases *** +Session Create Then List Shows Session + [Documentation] Create a session and verify it appears in session list. + [Tags] E2E tdd_expected_fail tdd_bug tdd_bug_1141 + Run CleverAgents Command init --force --yes + ${r1}= Run CleverAgents Command session list --format json + Should Contain ${r1.stdout} "total": 0 + Run CleverAgents Command session create --format plain + ${r2}= Run CleverAgents Command session list --format json + Should Contain ${r2.stdout} "total": 1 -- 2.52.0 From 80fefe2f00f968cf60a72b75fa2c863036e73e25 Mon Sep 17 00:00:00 2001 From: "Brent E. Edwards" Date: Sat, 28 Mar 2026 03:20:35 +0000 Subject: [PATCH 2/2] test(tdd): align #1141 expected-fail tags with validator Replace legacy tdd_bug tags with required tdd_issue tags so tdd_expected_fail scenarios pass TDD tag validation in both unit and E2E suites. --- features/tdd_session_create_persist.feature | 2 +- robot/e2e/e2e_session_create_persist.robot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/tdd_session_create_persist.feature b/features/tdd_session_create_persist.feature index f24b7dd7a..2ed55c3c8 100644 --- a/features/tdd_session_create_persist.feature +++ b/features/tdd_session_create_persist.feature @@ -1,4 +1,4 @@ -@tdd_expected_fail @tdd_bug @tdd_bug_1141 +@tdd_expected_fail @tdd_issue @tdd_issue_1141 Feature: TDD Bug #1141 — session create does not persist for session list As a developer I want to verify that a session created via `agents session create` diff --git a/robot/e2e/e2e_session_create_persist.robot b/robot/e2e/e2e_session_create_persist.robot index e5bf71b7e..301aaa4a2 100644 --- a/robot/e2e/e2e_session_create_persist.robot +++ b/robot/e2e/e2e_session_create_persist.robot @@ -11,7 +11,7 @@ Suite Teardown E2E Suite Teardown *** Test Cases *** Session Create Then List Shows Session [Documentation] Create a session and verify it appears in session list. - [Tags] E2E tdd_expected_fail tdd_bug tdd_bug_1141 + [Tags] E2E tdd_expected_fail tdd_issue tdd_issue_1141 Run CleverAgents Command init --force --yes ${r1}= Run CleverAgents Command session list --format json Should Contain ${r1.stdout} "total": 0 -- 2.52.0