You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Daniel Covington ec189bb617 Merge branch 'html-adapter' преди 11 часа
app HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
core HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
db/migrations Durable ingestion jobs; transactions refuse to commit after a failed statement преди 13 часа
docs HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
public HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
scripts HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
tests HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
.gitattributes Document Phase 1 workflow and new AxonASP gotchas; keep LF in .sh преди 1 ден
.gitignore Embeddings: bounded waits inside web requests преди 14 часа
AGENTS.md HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
CLAUDE.md Run under AxonASP in Docker and fix dispatch quirks преди 1 ден
README.md HTML ingestion adapter: convert pages to Markdown before storing преди 11 часа
Universal-Agent-Memory-Specification.md Run under AxonASP in Docker and fix dispatch quirks преди 1 ден
docker-compose.yml Import keeps references valid; FK repair tool; JSON 500 for API action errors преди 13 часа

README.md

RouteKit Classic ASP - MVC Starter (AxonASP)

A clean starting point for Classic ASP applications on AxonASP, a Go-based Classic ASP / VBScript 5.8 runtime. It ships a small MVC framework (router, controllers, views, flash messages, CSRF helper), a SQLite data layer on the native G3DB library, migrations, and code generators for tables, repositories, HTML controllers and JSON APIs.

No sample modules are included: the first table you add is yours.

Quick start

Requires Docker.

docker compose up -d

Open http://localhost:8801. The compose file mounts this folder into the container and serves public/.

After editing ASP code, restart the container so cached scripts are recompiled: docker restart axonasp.

Project structure

public/            web root: Default.asp (front controller + routes), web.config (rewrite, settings)
core/              framework: mvc.asp, router, DAL (G3DB), migrations, JsonLite, helpers, lib.*.asp
app/
  controllers/     <Name>Controller.asp (HTML), Api<Name>Controller.asp (JSON), autoload_controllers.asp
  models/          POBO_<Table>.asp, <Table>Repository.asp (generated), autoload_models.asp
  views/           <Name>/ views; shared/ layout (header, footer); Home, Error, Docs
db/
  migrations/      YYYYMMDDHHMMSS_name.asp (Migration_Up / Migration_Down)
  app.sqlite       created by the first migration run (git-ignored)
scripts/           gen.cmd (generators), migrate.cmd, templates/
docker-compose.yml  the AxonASP container (mounts this folder at /opt/axonasp/site)

Adding a feature

All commands run from this folder on Windows and execute inside the container through the AxonASP CLI. Run gen.cmd controller from PowerShell or cmd (not Git Bash).

  1. Migration: scripts\gen.cmd migration create_things_table, edit Migration_Up / Migration_Down, then scripts\migrate.cmd up (also status, down).
  2. JSON API for the table: scripts\gen.cmd api /table:Things /pk:Id. This writes the model and repository, ApiThingsController.asp, wires the includes, controller whitelist and routes (/api/things), and creates public/api/things.openapi.json and api-tests/things.http.
  3. HTML pages: scripts\gen.cmd controller Things Index "Show(id)" NewForm Create "Edit(id)" "Update(id)" "Delete(id)" creates a stub controller and wires it; fill in the actions and add views under app/views/Things/.
  4. docker restart axonasp, then try it.

The Swagger UI at http://localhost:8801/api/docs lists every generated API spec and lets you call the endpoints.

Included

  • HomeController: welcome page at /
  • ErrorController: 404 page
  • DocsController: Swagger UI at /api/docs

Agent memory platform (status)

Implements Universal-Agent-Memory-Specification.md on top of this starter. API base /api/v1, spec in public/api/memory-v1.openapi.json (Swagger at /api/docs). Auth is Authorization: Bearer <key>; the tenant comes from the key. A caller without permission on a namespace gets 404.

Done

  • Phase 1: tenants, principals, hashed API keys, namespaces, grants (read/write/delete/verify/admin); memories with revisions, correction (If-Match), retire/forget, idempotency keys, duplicate detection, audit events; sessions with checkpoints; health.
  • Phase 2: Markdown/text ingestion with chunking and source locators (core/lib.Search.asp), documents/chunks/jobs, lexical search over chunks (FTS5), POST /recall over memories, verification (POST /memories/:id/verifications), content_trust labelling.
  • Phase 3 (part): POST /context assembles a task briefing under a token budget: constraints loaded by scope (required; 422 context_budget_exceeded when they do not fit), working state from a session checkpoint, preferences, disputed items as conflicts, decisions/lessons/knowledge and reference passages by hybrid match, optional unverified items; deduplicated and trust-labelled.
  • Phase 3 (part): semantic retrieval. Embeddings from a local Ollama model (nomic-embed-text), vectors in Qdrant, both as containers in docker-compose.yml. /recall, /search and /context fuse lexical and vector ranks (reciprocal rank fusion) and fall back to lexical with a warning when the provider is off or down. SQLite stays the source of truth: embedding_index tracks model, dimensions, revision and status per memory/chunk, writes index after commit (never failing the write), and scripts\embed.cmd status|run|reindex catches up or rebuilds. Common English stopwords are dropped from lexical queries. The embed-worker container retries pending/failed items every 30 seconds; GET /health/ready reports degraded (still 200) and the backlog when the provider or vector store is down.
  • Phase 3 (part): learning loop. Agents record experiences in a session (POST /sessions/:id/events) and propose knowledge with evidence (POST /learn: a new memory, or a new revision of target_memory_id at base_revision). Another principal with verify reviews it (POST /candidates/:id/review); the author cannot approve its own candidate without admin. Accepting creates the memory (an identical active one is reused), or revises the target if it has not changed meanwhile (else 409 stale_candidate), copies the evidence with pinned target revisions and, with "verify": true, records a verification. GET /memories/:id/sources shows evidence and verifications per revision (evidence the caller cannot read is shown as available: false, without its id). Recall, search and context return a query_id and record the returned results and revisions (the query text is kept only as a hash); POST /feedback rates one result (useful, not_useful, incorrect, harmful). Ratings on a result's current revision adjust its rank in recall, search and context (useful raises it, incorrect/harmful halve its score per rating); results show their feedback counts and a warning names demoted results. A corrected memory starts without feedback. Forgetting a memory removes its evidence, verifications, feedback and telemetry rows.
  • Durable ingestion jobs: POST /ingestion/jobs stores the job and its input before processing, so nothing acknowledged is lost. By default it is processed inside the request (201, or 200 when unchanged); with "async": true the answer is 202 with the job and the embed-worker publishes it. A job interrupted mid-ingest (lease of 5 minutes) or failed with an internal error is retried by the worker, at most 3 attempts; other failures (unreadable input, namespace gone, permission lost, re-checked at processing time) wait for POST /jobs/:id/retry. Identical text is a no-op and publishing happens in one transaction with the job update, so retries and duplicate submissions never publish duplicate chunks. GET /jobs/:id shows state, attempts, auto_retry and the error.
  • Portability: POST /exports writes a canonical JSON document (format agent-memory-export, schema_version 1, SHA-256 integrity.digest over the exact data text) with every namespace the caller can read, or the namespace_ids asked for: memories with all revisions and verifications, documents with revisions and chunks, and evidence links (links to targets the caller cannot read are left out and counted). Ids, revision numbers, timestamps and principal ids are kept. POST /imports takes that document unchanged (max 8 MiB): it needs admin on every target namespace (matched by path; they must exist), rebuilds content hashes and lexical indexes and queues embeddings, and is all-or-nothing (409 import_conflict when an id exists, 422 for a wrong format, unsupported_schema_version or integrity_mismatch). Re-exporting imported data gives the same data. Not in version 1: sessions, experiences, candidates, feedback, telemetry, audit events.
  • HTML ingestion (phase 4): "format":"html" on POST /ingestion/jobs converts the page to Markdown before it is stored (core/lib.HtmlAdapter.asp): script, style, comments, nav and other invisible content are removed, headings become heading paths, lists, tables and pre blocks are kept, entities are decoded, and nothing the page references is fetched. The title defaults to the page's <title>; the document is stored as markdown and the response says "source_format":"html". Markup-only changes re-ingest as unchanged. kb.sh ingest page.html uses it.
  • Consolidation: POST /consolidations groups the experiences of a namespace that describe the same situation (shared significant words, Jaccard similarity, no generative model) and returns a draft per group built from the experiences’ own text: what did not work, what worked, when and how often. With "propose": true each group with enough experiences not yet cited by a candidate becomes a proposed candidate (tag consolidated) that cites them as evidence, reviewed like any other. kb.sh session, kb.sh event and kb.sh consolidate [propose] use it from the command line.
  • Management API: GET /me; GET|POST /namespaces; GET|POST /principals, GET|PATCH /principals/:id, POST /principals/:id/keys, DELETE /keys/:id; GET|POST /grants, DELETE /grants/:id. admin on a namespace lets a caller create namespaces below it and grant or revoke access there; a principal's keys and status can only be managed by someone who holds admin wherever that principal has access, so a new key never widens the caller's access (see docs/decisions.md ADR-011). New keys are returned once. Tenants, top-level namespaces and purges stay with provision.cmd / ops.sh provision.
  • Backup and restore: scripts\backup.cmd (see Operations below).
  • Observability: every API response carries X-Request-Id (a caller's own X-Request-Id of 8-64 characters [A-Za-z0-9._:-] is kept for correlation; it also appears in error bodies and audit events) and writes one JSON access-log line to stdout: request id, method, controller action, status, duration, tenant and principal ids. Bodies, query strings and keys are never logged. GET /api/v1/metrics serves Prometheus text: request counters and a latency histogram per action (in process memory, reset by a restart), and installation-wide counts of memories, candidates, jobs, embedding index states, retrieval calls (with empty results and total time) and feedback. It needs the AMK_METRICS_TOKEN bearer token and answers 404 while that is unset.

Known limitation

  • Characters above U+FFFF (emoji) are rejected with 422 unsupported_character: the pinned AxonASP build cannot hold them (see AGENTS.md section 8).

Tooling

  • scripts\provision.cmd (tenant, principal, key, namespace, grant, revoke, list, purge); see AGENTS.md section 1. Needed for tenants, the first admin of a tenant and top-level namespaces; the rest can go through the management API. Quote permission lists in PowerShell: '"read,write"'.
  • scripts\export-memories.ps1 / scripts/export-memories.sh: dump every readable memory (set AMK_KEY).
  • pwsh scripts/smoke-prod.ps1: post-deploy check of a running server (readiness, the API key via /me, a consolidation dry run); reads .amk.env, or -BaseUrl -Key -NamespaceId. Writes nothing.
  • scripts/ops.sh: the same tools for a Linux server (migrate, provision, embed, backup, verify, restore, repair).
  • 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 (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 (93), bash tests/phase3-portability.sh (47), bash tests/backup-restore.sh (21; starts a throw-away container on port 8802), bash tests/phase3-jobs.sh (41; stops the embed-worker container while it runs), bash tests/observability.sh (25; restarts the container; the metrics checks need AMK_METRICS_TOKEN), bash tests/admin-api.sh (91), bash tests/phase3-consolidation.sh (42), bash tests/phase4-html.sh (30), bash tests/retrieval-benchmark.sh (5 threshold checks over 56 labelled queries; stops and restarts the ollama container). Each creates and purges its own tenants.
  • Acceptance: docs/acceptance.md maps every MVP acceptance criterion (AC-01 to AC-18) to its automated checks and a manual verification, with the benchmark results and what is not tested. Architecture decisions: docs/decisions.md.

Next (not started): rest of roadmap phase 4: PDF (needs a text extractor; the runtime's G3PDF only writes PDFs), an administration and review UI, graph relationships.

Operations: backup and restore

SQLite (db/app.sqlite) is the only source of truth. The Qdrant vectors are derived and rebuilt from it; the Ollama model is downloaded again with ollama pull.

  • Backup (server keeps running): scripts\backup.cmd backup writes db\backups\app-YYYYMMDD-HHMMSS.sqlite with SQLite VACUUM INTO (a consistent, compacted copy), then checks it (integrity_check, foreign_key_check, latest migration) and compares row counts per table with the live database. The last line is RESULT: ok or RESULT: failed; trust that line, not the exit code. db/backups/ is git-ignored and lives on the same disk, so copy the files elsewhere (another disk or machine, object storage) and keep several generations.
  • Verify a stored copy: scripts\backup.cmd verify db/backups/<file>.sqlite.
  • Restore: scripts\restore.cmd db/backups/<file>.sqlite. It stops axonasp and embed-worker, verifies the backup (nothing changes if that fails), keeps the current database as db\backups\pre-restore-<timestamp>.sqlite, copies the backup into place, starts both containers and runs scripts\embed.cmd reindex. If the backup is older than the code's schema, run scripts\migrate.cmd up afterwards (once per pending migration).
  • Recovery objectives: the recovery point (RPO) is the backup interval; schedule scripts\backup.cmd backup (for example hourly with Task Scheduler or cron) to match the loss you can accept. The recovery time (RTO) is the restore plus the reindex. The drill bash tests/backup-restore.sh restores a fresh backup into an isolated container (own db folder, port 8802; the live database is not touched), checks that the restored server returns the same export as the live one, and fails if it takes longer than RTO_SECONDS (default 120). Measured here: about 70 to 100 seconds, almost all of it the first start of a new container; restore.cmd restarts the existing containers instead. The reindex time grows with the data and does not block reads: lexical retrieval works at once, semantic ranking catches up.
  • Repair after an import: an import keeps the author ids of the source installation. Since this version it creates a placeholder principal (status imported, no keys or grants, cannot sign in) for each unknown one, so references stay valid. For data imported earlier, scripts\backup.cmd repair (Linux: bash scripts/ops.sh repair) lists the foreign key violations; repair apply creates the placeholders and deletes verifications whose memory no longer exists, then reports what is left. Take a backup first.
  • An export (POST /exports) is a portable copy per caller and namespace, not a full backup: it leaves out tenants, principals, keys, grants, sessions, feedback and audit events.

Configuration

  • public/web.config: ConnectionString (sqlite:/opt/axonasp/site/db/app.sqlite), environment and UI settings, and the Embedding* / VectorStoreUrl settings (EmbeddingProvider none turns semantic retrieval off). Settings are cached per process: docker restart axonasp after editing.
  • First start of the semantic stack: docker compose up -d, then docker exec ollama ollama pull nomic-embed-text once (the model lives in the ollama-models volume). The ollama image is about 6 GB.
  • Metrics: put AMK_METRICS_TOKEN=<random, 16+ characters> in a .env file in the repo root (git-ignored; compose reads it), then docker compose up -d. Scrape http://<host>:8801/api/v1/metrics with Authorization: Bearer <token>. Access logs: docker logs axonasp 2>&1 | grep -o '{"log":"access".*' (each line has a runtime timestamp prefix); ApiAccessLog in web.config turns them off.
  • Any web.config setting can be overridden by an environment variable APPSETTING_<key> (read by GetAppSetting). Compose passes APPSETTING_Environment: put APPSETTING_Environment=Production in the server's .env so that API errors never include internal details (SQL, error text). In development an unexpected error inside an API action is answered with a JSON 500 that includes the detail; in production only the request id, and the detail goes to docker logs ({"log":"action_error",...}).
  • Never open db/app.sqlite from the host (sqlite3, a GUI, Python) while the containers run: the database is in WAL mode, and -wal/-shm files created by the host user are not writable by the container user, which makes every write fail (“attempt to write a readonly database”). Use scripts/ops.sh / the .cmd tools, which run inside the container as axonasp.
  • /opt/axonasp/config/axonasp.toml (inside the container): server settings; any key can be overridden with an environment variable (see docker-compose.yml).

Rules for developers and AI agents

See AGENTS.md at the repository root: language rules, AxonASP quirks verified in this project, security checklist and working rules.

Powered by TurnKey Linux.