浏览代码

Document Phase 1 workflow and new AxonASP gotchas; keep LF in .sh

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pull/1/head
Daniel Covington 1 天前
父节点
当前提交
2207edc3ee
共有 2 个文件被更改,包括 13 次插入 和 0 次删除
  1. +2
    -0
      .gitattributes
  2. +11
    -0
      AGENTS.md

+ 2
- 0
.gitattributes 查看文件

@@ -0,0 +1,2 @@
# Shell scripts must keep LF line endings (they run under bash)
*.sh text eol=lf

+ 11
- 0
AGENTS.md 查看文件

@@ -29,6 +29,12 @@ When unsure about an object, ProgID, method or config key, check `/opt/axonasp/w
- Swagger UI for the JSON APIs: http://localhost:8801/api/docs (needs internet: loads Swagger UI from the jsDelivr CDN).
- The AxonASP manual is inside the container: `docker exec axonasp ls /opt/axonasp/www/manual/md` (libraries/, asp/, runtime/, ...). There is no `deploy/` folder in this repo.

### Memory API (Phase 1) workflow

- Provision with `scripts\provision.cmd` (tenant, principal -> API key printed once, namespace, grant, revoke, list, purge). API calls use `Authorization: Bearer <key>`; the tenant comes from the key.
- Controllers `ApiMemoriesController`, `ApiSessionsController`, `ApiHealthController` are hand-written (the generators cover one-table CRUD only); routes under `/api/v1/...` are in `public/Default.asp`.
- Regression suite: `bash tests/phase1-api.sh` (needs the container running; creates and purges its own tenants; ends with a container restart).

### Adding a table end to end (the workflow that was verified)

1. `scripts\gen.cmd migration create_<table>_table`, then fill in `Migration_Up`/`Migration_Down` by hand (the generator leaves TODOs), then `scripts\migrate.cmd up`.
@@ -154,6 +160,11 @@ Create objects with `Server.CreateObject("ProgID")` using exact ProgIDs from `/o
- **Call sites bind to the first class.** `CurrentController.Invoke ...` in one place was bound to the first controller's `Invoke` and reused for every later controller (the first dispatched action's body appeared on every route; title/layout were right). Each controller therefore exposes a global `<Name>Controller_Invoke(actionName, args)` and the dispatcher calls it through `GetRef` (`MVC_InvokeAction`). New controllers must define `Invoke` and `<Name>Controller_Invoke` (the generators emit both).
- **Single-line `If x Then a = b Else a = c` swallowed the rest of a Sub** under `On Error Resume Next`. Always use multi-line `If`.
- **Migrator: one migration per process.** `migrate.cmd up` with two or more pending migrations failed on the second one (`Runtime error: Migrator '800A0002'`; an AxonASP VM panic "assignment to entry in nil map" when reproduced in a plain script). Run `migrate.cmd up` once per pending migration. Even a successful apply/rollback currently ends with `Object required` from `core/helpers.asp` and exit code 1 (reproduced on the original unmodified framework, so not caused by local changes); check `migrate.cmd status` rather than the exit code.
- **Close a result set before running another statement.** Running a query inside a loop over an open G3DB result set hung the request (script timeout), and a write executed while a result set was still open was silently lost (the `provision key` action created no key). Copy the values you need, `rs.Close`, then query/write.
- **G3DB takes at most 8 parameters per statement** ("Too many parameters (12); the maximum is 8"). Split wide INSERTs into an INSERT plus an UPDATE inside one transaction (see `InsertRevision` in `ApiMemoriesController.asp`).
- **Non-BMP characters:** AxonASP strings hold whole code points. `ChrW(128512)` is one character; building it from a UTF-16 surrogate pair stores two U+FFFD. `Api_Utf8Decode` and `JsonLite` (for surrogate-pair `\u` escapes) combine accordingly.
- **Run CLI tools as the server user.** The HTTP server runs as `axonasp`; a database file first created by a root `docker exec` was read-only to it ("attempt to write a readonly database"). `gen.cmd`, `migrate.cmd` and `provision.cmd` use `docker exec -u axonasp`.
- **PowerShell splits `read,write` into two arguments.** Quote lists passed to `provision.cmd grant`: `'"read,write"'`.
- **Class member vs local name clash.** Avoid a local `Dim controllerName` inside a class that also has a `ControllerName` property.
- **`Empty Is Nothing` raises "Object required".** Test with `IsObject` / `IsEmpty` first, then `Is Nothing`.
- **`Server.Execute(file)` runs the file as a separate page.** It does not define procedures in the caller's scope. To load a script's Subs, read the file and `ExecuteGlobal` the text (strip `<%`/`%>`), as the migrator does.


正在加载...
取消
保存

Powered by TurnKey Linux.