You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add per-folder DESIGN.md navigation for resources/ and server/
Add resources/DESIGN.md with a section index for the 4744-line Table.ts
(grouped by responsibility: setup, authz, read, write, search, pub/sub,
validation, stats, history) and a Resource.ts member table with line
numbers. Add server/DESIGN.md mapping the three HTTP stacks (native HTTP,
Operations API on Fastify, legacy Custom Functions on Fastify), the
http.ts section index, and middleware ordering.
Expand AGENTS.md with a repository map for all 19 top-level folders and
a "Detailed navigation" pointer table to the new docs. Correct the
existing "two HTTP stacks" claim to three.
Goal: reduce the overhead of starting a task in this repo. Agents
spending time grepping the wrong folders or top-to-bottom reading
megafiles can now jump to the right place via path + line number.
Generated by Claude Opus 4.7 (1M context).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+62-6Lines changed: 62 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,19 +59,20 @@ The plugin/application loader. Applications export a `handleApplication(scope)`
59
59
Files within a component are discovered via micromatch glob patterns and automatically mapped to URL paths.
60
60
61
61
**Server** (`server/`)
62
-
Two HTTP stacks coexist:
62
+
Multiple HTTP entry points coexist:
63
63
64
-
-**Native layer** (`server/http.ts`) — direct socket handling for HTTP/1.1, HTTPS, HTTP/2, and WebSockets in one path; highest performance
65
-
-**Fastify layer** (`server/fastifyRoutes.ts`) — used for legacy custom functions; wraps Fastify with autoload
64
+
-**Native layer** (`server/http.ts`) — direct socket handling for application-level HTTP/1.1, HTTPS, HTTP/2, and WebSockets in one path; highest performance. Most user traffic goes through here.
-**Custom Functions (legacy)** (`server/fastifyRoutes.ts`) — legacy Fastify autoload for user-defined routes. Don't add new code here.
66
67
67
-
All inbound protocols (REST, GraphQL, MQTT, NATS, WebSockets) eventually resolve to the same **Resource interface**.
68
+
All inbound protocols (REST, GraphQL, MQTT, NATS, WebSockets) eventually resolve to the same **Resource interface**. See `server/DESIGN.md` for the file-by-file map and the `http.ts` section index.
68
69
69
70
**Resources** (`resources/`)
70
71
The universal abstraction. Everything that can be queried or mutated — database tables, caches, message topics, custom endpoints — extends `Resource` (`resources/Resource.ts`).
71
72
72
73
Static methods (`Resource.get`, `Resource.put`, `Resource.post`, `Resource.delete`, `Resource.patch`, `Resource.subscribe`) are the entry points and are automatically wrapped with `transactional()` for transaction management. Override instance methods (`get`, `put`, etc.) for custom behavior.
73
74
74
-
`Table.ts` is the database table implementation (~177KB) — the most complex file in the codebase.
75
+
`Table.ts` is the database table implementation (4744 lines, one giant `makeTable()` factory) — the most complex file in the codebase.**Use `resources/DESIGN.md` as a section index instead of reading top-to-bottom.**
75
76
76
77
**Data Layer** (`dataLayer/`)
77
78
Legacy translation modules plus SQL translation (`sqlTranslator/`) via AlaSQL; these should be avoided. The storage engine is selectable via `HARPER_STORAGE_ENGINE=lmdb`.
@@ -80,7 +81,62 @@ Legacy translation modules plus SQL translation (`sqlTranslator/`) via AlaSQL; t
-**`bin/`** — CLI entry points. `harper.js` is the executable; `run.js` initializes and runs the server; `cliOperations.js` translates CLI args → API operations. Tests: `unitTests/bin/`. **Don't look here for** business logic.
104
+
-**`security/`** — auth, authz, certificate handling, context. Entry: `jsLoader.ts` exposes `getContext()`, `getResponse()`, `getUser()`; `user.ts` for User/Role; `certificateVerification/` for TLS validation; `data_objects/` for permission/role models. Tests: `unitTests/security/`.
105
+
-**`sqlTranslator/`** — SQL → internal operations via AlaSQL AST. Entry: `sqlTranslator/index.js` exports `evaluateSQL`, `processAST`, `convertSQLToAST`, `checkASTPermissions`. **Legacy — avoid for new code.** Tests: `unitTests/sqlTranslator/`.
-**`launchServiceScripts/`** — thin launchers that delegate to `server/operationsServer.ts`. `checkNodeVersion.js` is the pre-flight Node version check.
109
+
-**`json/`** — system schema definitions. `systemSchema.json` defines built-in tables (`hdb_user`, `hdb_role`, `hdb_permission`). Loaded at startup; no code.
110
+
111
+
### Non-source
112
+
113
+
-**`bin/`** — covered above (it's source).
114
+
-**`benchmarks/`** — HNSW vector-search benchmark only (`hnsw-search.js`). Stand-alone; not part of CI.
115
+
-**`build-tools/`** — shell scripts for the build pipeline (`build.sh`, `build-studio.sh`, `download-prebuilds.js`). No tests.
116
+
-**`dev/`** — single dev utility (`sync-commits.js`) for cross-repo commit syncing. Not runtime.
117
+
-**`integrationTests/`** — end-to-end tests against a built distribution. Run with `npm run test:integration` / `npm run test:integration:all`. Subdirs mirror source. See `integrationTests/README.md`.
118
+
-**`unitTests/`** — Mocha unit tests; subdir per source layer. Run with `npm run test:unit:<layer>`.
-**[DESIGN.md](DESIGN.md)** — running list of non-obvious internals (RecordObject prototype, getFromSource timing, blob orphan cleanup). Read this before debugging anything record-store-related.
124
+
-**[dependencies.md](dependencies.md)** — rationale for every npm dependency. Required reading before adding a new package.
0 commit comments