Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/sovereign_cortex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
class CommandRequest(BaseModel):
text: str = Field(min_length=1)
workspace: str = "demo-project"
auto_approve: bool = False
date: Date | None = None


Expand All @@ -45,7 +44,7 @@ def run_command(request: CommandRequest) -> CommandResponse:
if result is None:
result = LocalOrchestrator(root, request.workspace).handle_command(
request.text,
auto_approve=request.auto_approve,
auto_approve=False,
today=request.date,
)
ActivityRecordStore(root).append(result.events)
Expand Down
32 changes: 31 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import date

from sovereign_cortex.api import CommandRequest, build_report_result, create_app
from sovereign_cortex.events import EventType
from sovereign_cortex.events import EventType, TaskResult


def _endpoint(app, path: str):
Expand Down Expand Up @@ -54,6 +54,36 @@ def test_command_endpoint_runs_read_only_report_and_records_events(tmp_path):
assert records


def test_command_endpoint_does_not_accept_api_auto_approve(tmp_path, monkeypatch):
_write_demo_workspace(tmp_path)
calls: dict[str, object] = {}

class StubOrchestrator:
def __init__(self, repo_root, workspace):
calls["repo_root"] = repo_root
calls["workspace"] = workspace

def handle_command(self, text: str, *, auto_approve: bool, today):
calls["text"] = text
calls["auto_approve"] = auto_approve
calls["today"] = today
return TaskResult(status="no_action", message="stubbed", events=[])

monkeypatch.setattr("sovereign_cortex.api.LocalOrchestrator", StubOrchestrator)
app = create_app(tmp_path)
run_command = _endpoint(app, "/commands")
request = CommandRequest.model_validate(
{"text": "Create task Security review", "date": "2026-06-06", "auto_approve": True}
)

response = run_command(request)

assert not hasattr(request, "auto_approve")
assert calls["auto_approve"] is False
assert response.status == "no_action"
assert response.message == "stubbed"


def test_project_report_result_builds_api_events(tmp_path):
_write_demo_workspace(tmp_path)

Expand Down
Loading