diff --git a/AGENTS.md b/AGENTS.md index 7c23ff3..dab935d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -170,7 +170,7 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `/o - **Static files under `public/`** (for example `public/api/*.openapi.json`) are served directly; the rewrite rule skips existing files and directories. Only routes in `public/Default.asp` go through the MVC dispatcher; a route needs the controller in `autoload_controllers.asp` **and** in `ControllerRegistry` (the generators do both). - **Swagger UI:** the multi-spec dropdown (`urls: [...]`) only works with `presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset]` and `layout: "StandaloneLayout"`. Without them the page says "No API definition provided". - **Git Bash:** `curl` sends non-ASCII literals as cp1252, not UTF-8 (use `\u00fc` escapes or a file with `--data-binary @file`); read CSRF tokens from the form with a cookie jar (`-c/-b`); strip `\r` from values printed by Python on Windows before putting them in URLs. Python on Windows also reads piped stdin as cp1252: tests that compare non-ASCII text must call `sys.stdin.reconfigure(encoding='utf-8')` (`python -I` ignores `PYTHONIOENCODING`). -- **No 405 from the router.** A known path with an unrouted method answers 404, like an unknown path. Tests assert 404 for now. +- **405 and API 404s come from the router.** `Router_Class.Resolve` returns `ErrorController.MethodNotAllowed` (with an `Allow` header) when the path is routed for other methods; `ErrorController` answers `/api/...` requests with the JSON error format and no layout. Routing happens before authentication, so a wrong method is 405 even without a key. - **`Api_ToInt` clamps** to its range instead of rejecting, so use it for limits and paging only; validate values that must be rejected when out of range (for example `?revision=`) explicitly. - **SQLite NOT NULL columns and the 8-parameter limit.** Every NOT NULL column without a default must be in the INSERT; when the parameters run out, inline server-generated values that cannot contain user input (for example `Api_Now()` timestamps) rather than moving them to the follow-up UPDATE. - **Include order matters for class methods.** A class method cannot see a global Function/Class defined in a file included *after* the class's file (`GetRouter()`, `Flash()` failed with "Object required" / "doesn't support this property or method"). `core/autoload_core.asp` therefore includes `mvc.asp` last. diff --git a/README.md b/README.md index 7803440..c6dca83 100644 --- a/README.md +++ b/README.md @@ -67,12 +67,11 @@ Implements [Universal-Agent-Memory-Specification.md](Universal-Agent-Memory-Spec - `scripts\provision.cmd` (tenant, principal, key, namespace, grant, revoke, list, purge); see AGENTS.md section 1. Quote permission lists in PowerShell: `'"read,write"'`. - `scripts\export-memories.ps1` / `scripts/export-memories.sh`: dump every readable memory (set `AMK_KEY`). - `scripts\embed.cmd status|run|reindex`: semantic index status, catch up on pending/failed items, or rebuild (after changing the model). -- Tests (containers must be running): `bash tests/phase1-api.sh` (74 checks), `bash tests/phase2-api.sh` (45), `bash tests/phase3-context.sh` (60), `bash tests/phase3-semantic.sh` (30; stops and restarts the ollama container once), `bash tests/phase3-learning.sh` (85). Each creates and purges its own tenants. +- Tests (containers must be running): `bash tests/phase1-api.sh` (79 checks), `bash tests/phase2-api.sh` (45), `bash tests/phase3-context.sh` (60), `bash tests/phase3-semantic.sh` (30; stops and restarts the ollama container once), `bash tests/phase3-learning.sh` (85). Each creates and purges its own tenants. **Next (not started)** 1. Use feedback in ranking (today it is recorded only), and consolidation of related experiences into candidates. 2. Import/export API, and management endpoints for namespaces, principals and grants (today only via `provision.cmd`). -3. 405 for a known path with the wrong method (the router answers 404 today). ## Configuration diff --git a/app/controllers/ErrorController.asp b/app/controllers/ErrorController.asp index 3cc2833..0057aed 100644 --- a/app/controllers/ErrorController.asp +++ b/app/controllers/ErrorController.asp @@ -6,10 +6,19 @@ Class ErrorController_Class m_useLayout = True End Sub + ' JSON API requests (/api/...) get JSON errors without the HTML layout Public Property Get useLayout - useLayout = m_useLayout + If IsApiRequest() Then + useLayout = False + Else + useLayout = m_useLayout + End If End Property + Private Function IsApiRequest() + IsApiRequest = (LCase(Left(GetRequestPath(), 5)) = "/api/") + End Function + Public Property Let useLayout(v) m_useLayout = v End Property @@ -19,18 +28,34 @@ Class ErrorController_Class End Sub Public Sub NotFound() + If IsApiRequest() Then + Api_Error 404, "not_found", "No such endpoint." + Exit Sub + End If Response.Status = "404 Not Found" %> <% End Sub + ' The path exists, but not for this HTTP method (resolved by Router_Class.AllowedMethods) + Public Sub MethodNotAllowed(allow) + If IsApiRequest() Then + Api_Error 405, "method_not_allowed", "Use one of: " & allow & "." + Else + Response.Status = "405 Method Not Allowed" + Response.Write "
Method not allowed. Use one of: " & Server.HTMLEncode(allow) & ".
" + End If + Response.AddHeader "Allow", allow + End Sub + ' Static action dispatch (AxonASP mishandles runtime-built Eval/Execute calls), ' called through