From 8066975a0c57dcff944dccac2c398e76180285c2 Mon Sep 17 00:00:00 2001 From: Nalajmah <55954113+Alajmah@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:59:05 +0300 Subject: [PATCH 1/2] Disable API-controlled auto approval --- src/sovereign_cortex/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sovereign_cortex/api.py b/src/sovereign_cortex/api.py index 21b0dfa..61c9ab5 100644 --- a/src/sovereign_cortex/api.py +++ b/src/sovereign_cortex/api.py @@ -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 @@ -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) From 3afd98f2574198b8e807a08ef79e8752715ff115 Mon Sep 17 00:00:00 2001 From: Nalajmah <55954113+Alajmah@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:59:15 +0300 Subject: [PATCH 2/2] Add API auto approval regression test --- tests/test_api.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/test_api.py b/tests/test_api.py index 1d1be92..390788c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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): @@ -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)