Files
cleveragents-core/features/application_container_coverage_boost.feature
T
hurui200320 d878c04745
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 19s
CI / build (pull_request) Successful in 25s
CI / quality (pull_request) Successful in 30s
CI / typecheck (pull_request) Successful in 49s
CI / security (pull_request) Successful in 1m6s
CI / unit_tests (pull_request) Successful in 3m25s
CI / integration_tests (pull_request) Successful in 4m45s
CI / docker (pull_request) Successful in 1m0s
CI / e2e_tests (pull_request) Successful in 5m24s
CI / coverage (pull_request) Successful in 9m3s
CI / benchmark-regression (pull_request) Has been cancelled
test(e2e): E2E acceptance criteria for M5 (v3.4.0) — ACMS v1 and context scaling
Add robot/e2e/m5_acceptance.robot with 21 zero-mock E2E tests covering
all M5 acceptance criteria: context assembly (add/list/show/clear),
context scaling (10,000+ files without timeout), context policy
configuration (view-specific settings), budget enforcement
(max_file_size/max_total_size constraints), context analysis (ACMS
pipeline inspect/simulate), and plan execution with real LLM calls
(openai/gpt-4o-mini via plan use + plan resume).

Bug fixes discovered during E2E testing:

- Fix _save_policy_json commit bug: session.flush() -> session.commit()
  so policy changes persist after session.close() (project_context.py).
  Rollback wrapped in contextlib.suppress(Exception) to prevent masking
  the original commit exception.

- Add session_factory DI provider to Container as providers.Singleton so
  the four project context commands (set/show/inspect/simulate) resolve
  a real sessionmaker instead of hitting a missing attribute.  Return
  type annotated as sessionmaker[Session] using future annotations and
  TYPE_CHECKING guard (container.py).

- Propagate GEMINI_API_KEY in nox e2e_tests session (noxfile.py).

- Add Google/Gemini API key pattern (AIzaSy...) to secret redaction
  in redaction.py.

Review feedback addressed across eight review passes:

- Budget enforcement test verifies large_file.py exclusion by
  max_file_size constraint (not tautological token comparison).
- 10K scaling test validates simulation returns valid fragment_count
  (non-negative; non-zero deferred to full ACMS pipeline integration).
- Plan resume test parses JSON via Extract JSON From Stdout with
  TRY/EXCEPT — consistent with plan use test pattern.
- __import__("sqlalchemy") replaced with proper import in step defs.
- Context clear test verifies all three files removed (config/main/utils).
- Inspect test asserts tier_metrics and tier_budget are non-empty.
- _save_policy_json rollback wrapped in contextlib.suppress(Exception).
- Skip If No LLM Keys rewritten to use Evaluate with os.environ.get —
  keys never stored in any Robot variable.
- All assertion messages follow safe pattern (no stdout/stderr embedding).
- Review finding ID prefixes removed from all comments.
- Type annotations added to all 8 _build_session_factory step functions.
- Default view verification checks exclude-path __pycache__.
- Prerequisite skip guards added to sections 2-4 (Variable Should Exist).
- Plan ID extraction moved inside TRY block.

Results: 25/25 E2E (21 M5 + 2 smoke + 2 M1), 1536/1536 Robot
integration, 383/383 Behave features (10,926 scenarios), coverage 97%.

ISSUES CLOSED: #745
2026-03-19 06:31:05 +00:00

58 lines
3.0 KiB
Gherkin

Feature: Application Container coverage boost for _build_checkpoint_service, _build_trace_service, and _build_session_factory
As a developer
I want to exercise the _build_checkpoint_service, _build_trace_service, and _build_session_factory helper functions
So that the corresponding builder functions in container.py are covered by tests
Background:
Given a clean container state for coverage boost tests
# -----------------------------------------------------------------
# _build_checkpoint_service (lines 187-195)
# -----------------------------------------------------------------
Scenario: Build checkpoint service with in-memory database and no lifecycle service
When I build a checkpoint service with an in-memory database URL
Then the result should be a CheckpointService instance
And the checkpoint service should have a repository
And the checkpoint service should have no plan lifecycle service
Scenario: Build checkpoint service with an explicit plan lifecycle service
Given a mock plan lifecycle service
When I build a checkpoint service with the mock plan lifecycle service
Then the result should be a CheckpointService instance
And the checkpoint service should reference the mock plan lifecycle service
# -----------------------------------------------------------------
# _build_trace_service (lines 204-211)
# -----------------------------------------------------------------
Scenario: Build trace service with in-memory database using default settings
When I build a trace service with an in-memory database URL and no explicit settings
Then the result should be a TraceService instance
And the trace service should have a repository
And the trace service should have resolved settings from defaults
Scenario: Build trace service with explicit settings
Given explicit application settings for trace service
When I build a trace service with the explicit settings
Then the result should be a TraceService instance
And the trace service should use the explicitly provided settings
# -----------------------------------------------------------------
# _build_session_factory
# -----------------------------------------------------------------
Scenario: Build session factory with in-memory database returns callable sessionmaker
When I build a session factory with an in-memory database URL
Then the result should be a callable sessionmaker
And calling the session factory should produce a Session
Scenario: Build session factory with invalid URL raises an error
When I build a session factory with an invalid database URL
Then a database error should be raised when the factory is called
Scenario: Container.session_factory resolves a usable session factory
When I resolve session_factory from the container with an in-memory database URL
Then the resolved session factory should be callable
And calling the resolved session factory should produce a Session