📝 CodeRabbit Chat: Implement requested code changes#119
📝 CodeRabbit Chat: Implement requested code changes#119coderabbitai[bot] wants to merge 1 commit into
Conversation
Reviewer's GuideRefines the test-support routines API by replacing broad dead-code allowances with reasoned Sequence diagram for a routine E2E test using the helperssequenceDiagram
actor TestAuthor
participant TestCode
participant Database
participant Workspace
participant RoutineEngine
participant TraceLlm
participant NotificationReceiver
TestAuthor->>TestCode: create_test_db()
TestCode->>Database: apply_migrations()
Database-->>TestCode: db_handle, tempdir_guard
TestAuthor->>TestCode: create_workspace(db_handle)
TestCode->>Workspace: new(default, db_handle)
Workspace-->>TestCode: ws
TestAuthor->>TestCode: build LlmTrace
TestAuthor->>TestCode: make_minimal_engine(trace, db_handle, ws)
TestCode->>TraceLlm: new(trace)
TraceLlm-->>RoutineEngine: TraceLlm instance
TestCode->>RoutineEngine: new(db_handle, ws, TraceLlm, ToolRegistry, SafetyLayer)
RoutineEngine-->>NotificationReceiver: create_mpsc_channel()
RoutineEngine-->>TestCode: engine, receiver
TestAuthor->>TestCode: make_routine(name, trigger, prompt)
TestCode->>Database: create_routine(routine)
Database-->>TestCode: ok
TestCode->>RoutineEngine: refresh_event_cache()
TestAuthor->>RoutineEngine: emit_system_event(spec)
RoutineEngine->>Database: load_matching_routines()
Database-->>RoutineEngine: routines
RoutineEngine->>RoutineEngine: spawn_routine_tasks()
loop until expected_runs observed
TestCode->>Database: list_routine_runs(routine_id, 10)
Database-->>TestCode: runs
end
TestCode->>TestCode: assert run_count == expected
Class diagram for routines E2E test-support helpersclassDiagram
class RoutinesSupport {
+create_test_db() Result_ArcDatabase_TempDir
+create_workspace(db Arc_Database) Arc_Workspace
+make_routine(name String, trigger Trigger, prompt Prompt) Routine
+make_test_incoming_message(content String) IncomingMessage
+make_minimal_engine(trace LlmTrace, db Arc_Database, ws Arc_Workspace) EngineAndReceiver
+register_github_issue_routine(db Arc_Database, engine RoutineEngine) Result_void
+assert_system_event_count(engine RoutineEngine, spec SystemEventSpec, expected usize, msg str_ref) Result_void
}
class SystemEventSpec {
+source String
+event_type String
+payload serde_json_Value
+new(source String, event_type String, payload serde_json_Value) SystemEventSpec
}
class Database {
+create_routine(routine Routine) Result_void
+list_routine_runs(routine_id RoutineId, limit usize) Vec_RoutineRun
}
class Workspace {
+id WorkspaceId
+name String
}
class RoutineEngine {
+refresh_event_cache() Result_void
+emit_system_event(spec SystemEventSpec) Result_void
}
class TraceLlm {
+trace LlmTrace
}
class ToolRegistry
class SafetyLayer
class IncomingMessage
class Routine
class LlmTrace
class NotificationReceiver
class TempDir
class Arc_Database
class Arc_Workspace
class EngineAndReceiver {
+engine RoutineEngine
+receiver NotificationReceiver
}
class Result_ArcDatabase_TempDir
class Result_void
class Vec_RoutineRun
class RoutineRun
class RoutineId
class WorkspaceId
class serde_json_Value
class Trigger
class Prompt
class str_ref
RoutinesSupport ..> SystemEventSpec
RoutinesSupport ..> Database
RoutinesSupport ..> Workspace
RoutinesSupport ..> RoutineEngine
RoutinesSupport ..> TraceLlm
RoutinesSupport ..> ToolRegistry
RoutinesSupport ..> SafetyLayer
RoutinesSupport ..> IncomingMessage
RoutinesSupport ..> Routine
RoutinesSupport ..> LlmTrace
RoutinesSupport ..> NotificationReceiver
RoutinesSupport ..> TempDir
RoutinesSupport ..> Arc_Database
RoutinesSupport ..> Arc_Workspace
RoutinesSupport ..> EngineAndReceiver
SystemEventSpec ..> serde_json_Value
RoutineEngine ..> Database
RoutineEngine ..> TraceLlm
RoutineEngine ..> ToolRegistry
RoutineEngine ..> SafetyLayer
EngineAndReceiver ..> RoutineEngine
EngineAndReceiver ..> NotificationReceiver
Database ..> Routine
Database ..> RoutineRun
RoutineRun ..> RoutineId
Workspace ..> WorkspaceId
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/testing-strategy.md" line_range="101" />
<code_context>
+| `make_minimal_engine(trace, db, ws)` | `fn` | Constructs a `RoutineEngine` backed by a `TraceLlm` replaying the given `LlmTrace`, a default `ToolRegistry`, and a `SafetyLayer` with injection checking enabled. Returns both the engine and the mpsc notification receiver so tests can observe or drain the channel. |
</code_context>
<issue_to_address>
**issue (review_instructions):** The acronym “mpsc” is introduced without being defined, which violates the requirement to define uncommon acronyms on first use.
Please expand “mpsc” (for example, “multi-producer, single-consumer (mpsc) notification receiver”) the first time it appears in the document.
<details>
<summary>Review instructions:</summary>
**Path patterns:** `**/*.md`
**Instructions:**
Define uncommon acronyms on first use.
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| | `create_workspace(db)` | `fn` | Wraps a database reference in an `Arc<Workspace>` named `"default"`. | | ||
| | `make_routine(name, trigger, prompt)` | `fn` | Builds a `Routine` value with sensible test defaults (zero cooldown, enabled, empty state). The trigger and prompt are supplied by the caller. | | ||
| | `make_test_incoming_message(content)` | `fn` | Builds an `IncomingMessage` on channel `"test"` with `user_id = "default"` and the supplied content string. | | ||
| | `make_minimal_engine(trace, db, ws)` | `fn` | Constructs a `RoutineEngine` backed by a `TraceLlm` replaying the given `LlmTrace`, a default `ToolRegistry`, and a `SafetyLayer` with injection checking enabled. Returns both the engine and the mpsc notification receiver so tests can observe or drain the channel. | |
There was a problem hiding this comment.
issue (review_instructions): The acronym “mpsc” is introduced without being defined, which violates the requirement to define uncommon acronyms on first use.
Please expand “mpsc” (for example, “multi-producer, single-consumer (mpsc) notification receiver”) the first time it appears in the document.
Review instructions:
Path patterns: **/*.md
Instructions:
Define uncommon acronyms on first use.
Code changes was requested by @leynos.
The following files were modified:
docs/testing-strategy.mdtests/support/mod.rstests/support/routines.rsSummary by Sourcery
Document and validate the shared test helpers for routine and heartbeat end-to-end tests while tightening compiler lints around their usage.
Enhancements:
Documentation: