Skip to content

Commit b0318ad

Browse files
docs: route agent guidance by task (#1213)
The root `AGENTS.md` had grown into an always-loaded mix of repository policy, subsystem contracts, command reference, and troubleshooting history. That made the rules that apply to every task harder to find and allowed copied documentation to drift. This change keeps safety, delivery, completion, and publishing rules in the root file, then routes storage, testing, frontend, build, and background-work tasks to focused guides. It also corrects the stale DuckDB schema-lifecycle note found during the split. The main tradeoff is that agents must follow the routing table before editing a matching part of the repository; the root keeps the critical SQLite preservation warning as a safeguard. <sup>generated by a clanker</sup> Co-authored-by: Marius van Niekerk <mariusvniekerk@users.noreply.github.com>
1 parent fcd9e0c commit b0318ad

7 files changed

Lines changed: 231 additions & 320 deletions

File tree

AGENTS.md

Lines changed: 83 additions & 319 deletions
Large diffs are not rendered by default.

docs/agents/background-work.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Background Work and Memory
2+
3+
Read this file before changing watchers, polling, sync scheduling, or other
4+
long-running background work. Also read it before investigating memory growth.
5+
6+
- Keep passive daemon memory within a few hundred megabytes on macOS, Linux, and
7+
Windows. Treat sustained growth beyond that range as a regression.
8+
- Bound watcher, polling, and sync work by the changed batch, not the full
9+
archive. Do not scan or load every stored session for each filesystem event.
10+
- Declare costly scheduling inputs as provider capabilities. Compute them only
11+
for providers that use them, and default new capabilities to unsupported.
12+
- Add cardinality-scaling regressions for background paths. Compare small and
13+
large archives and prove that unchanged work per event stays bounded. Cover
14+
deletion, tombstones, and persistent archives in the same tests.
15+
- Diagnose long-running memory with allocation and CPU profiles, live heap,
16+
forced-GC heap, and operating-system physical or dirty memory. Raw RSS does
17+
not prove live memory because it includes clean reclaimable mappings.
18+
- Profile branch binaries only against isolated, production-scale database and
19+
source clones. Never use live archives or agent transcripts.
20+
- Observe retention long enough to reproduce the reported growth window. On
21+
macOS, record `vmmap` physical footprint and dirty memory. Use portable Go
22+
allocation and heap metrics on Linux and Windows.

docs/agents/build.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Build and Dependency Rules
2+
3+
Read this file before changing build commands, toolchain setup, CI build tags,
4+
or frontend dependencies. Use the `Makefile` as the command reference.
5+
6+
## Go and SQLite
7+
8+
- Build with `CGO_ENABLED=1`; the SQLite driver requires CGO.
9+
- Use the `fts5` build tag for full-text search.
10+
- Do not add the `kit_posthog_disabled` tag to `go test`. The telemetry reporter
11+
disables itself under `testing.Testing()`. E2E binaries run as real
12+
processes, so their build keeps the tag.
13+
14+
## Frontend
15+
16+
- The embedded Svelte frontend requires Node.js and the frontend toolchain. Read
17+
`frontend/AGENTS.md` before working in that directory.
18+
- `@kenn-io/kit-ui` is a public git dependency pinned to a commit in
19+
`frontend/package.json`.
20+
- The lockfile records the GitHub dependency as an SSH URL because npm uses that
21+
canonical form. npm still fetches it anonymously over HTTPS. Do not rewrite
22+
the lockfile URL.
23+
- To update kit-ui, change the commit hash in `frontend/package.json` and run
24+
`npm install`.

docs/agents/storage.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Storage Rules
2+
3+
Read this file before changing SQLite, PostgreSQL, CockroachDB, DuckDB, archive
4+
resync, or storage queries.
5+
6+
## SQLite Archive
7+
8+
SQLite is the persistent archive. Never delete, drop, truncate, or recreate it
9+
to handle a data-version change.
10+
11+
Use non-destructive schema migrations such as `ALTER TABLE` and `UPDATE`. A
12+
parser change that needs a full resync must build a fresh database, sync source
13+
files, copy orphaned sessions from the old database, and swap the files
14+
atomically. Preserve sessions even when their source files no longer exist.
15+
16+
## Backend Parity
17+
18+
- Keep observable behavior and query shape aligned between SQLite and
19+
PostgreSQL/CockroachDB when practical. Match queries, indexes, aggregations,
20+
filters, and ordering unless a documented constraint requires a difference.
21+
- Do not fix correctness or performance in only one primary backend unless the
22+
user limits the task to that backend. If implementations must differ,
23+
explain why and preserve the same behavior.
24+
- DuckDB is a derived mirror and is not part of this parity rule.
25+
26+
## DuckDB Mirror
27+
28+
- Treat DuckDB as a disposable read mirror of SQLite, never as a system of
29+
record. Deleting the mirror must lose nothing.
30+
- Do not add in-place mirror migrations. A schema or source-data version change
31+
must bump `internal/duckdb.SchemaVersion`, rebuild a fresh file, validate
32+
it, and swap it atomically. Do not add `ALTER` migrations, version-bridging
33+
reads, or compatibility shims for old mirrors.
34+
- Store every DuckDB push cursor and version in the mirror's `sync_metadata`.
35+
Never store DuckDB sync state in SQLite.
36+
- Replace whole sessions during incremental updates and gate them with
37+
per-session fingerprints. Do not add per-table, per-column, or diff-based
38+
updates.
39+
- Keep Quack read-only. `duckdb push` writes the local mirror; it never writes
40+
to a remote DuckDB service.
41+
- Replace a file only after identifying it as an agentsview DuckDB mirror. Fail
42+
closed for unknown files.
43+
44+
## PostgreSQL Integration Tests
45+
46+
Run PostgreSQL integration tests only against a dedicated test database. The
47+
tests create and drop the `agentsview` schema.
48+
49+
Use `make test-postgres` to start the test container and run the suite. It
50+
leaves the container running. If you started that container, use
51+
`make postgres-down` when it is no longer needed.
52+
53+
To use an existing dedicated instance, run:
54+
55+
```bash
56+
TEST_PG_URL="postgres://user:pass@host:5432/dbname?sslmode=disable" \
57+
CGO_ENABLED=1 go test -tags "fts5,pgtest" ./internal/postgres/... -v
58+
```

docs/agents/testing.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Testing Rules
2+
3+
Read this file before adding or changing tests.
4+
5+
## Coverage
6+
7+
- Add unit tests for every new feature and bug fix.
8+
- Run the smallest relevant test set before committing. State which checks you
9+
could not run.
10+
- Keep tests fast and isolated.
11+
12+
## Go Tests
13+
14+
- Prefer table-driven tests.
15+
- Use `github.com/stretchr/testify` for assertions.
16+
- Use `require.X` when failure must stop the test, such as setup errors, nil
17+
values, or length checks before indexing.
18+
- Use `assert.X` for independent checks that can continue after failure.
19+
- Do not add `if got != want { t.Fatalf(...) }` comparisons.
20+
- Test helpers must use testify for their own assertions.
21+
- Use the existing `testDB(t)` helper for database tests.
22+
- Use `t.TempDir()` for temporary directories.
23+
24+
## Frontend and End-to-End Tests
25+
26+
- Keep frontend unit tests beside the code in `*.test.ts` files.
27+
- Put Playwright tests in `frontend/e2e/`.
28+
29+
## Shell Tests
30+
31+
Run scripts against controlled input and assert their output, exit code, or side
32+
effects. Do not read a script and assert that it contains an implementation
33+
line, flag, or snippet.

frontend/AGENTS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ https://viteplus.dev/guide/.
3333
typeahead/combobox components for single-choice selectors unless the native
3434
control is explicitly justified.
3535
- Existing native selects are legacy exceptions, not examples to copy.
36+
37+
## Localization
38+
39+
- Keep the message catalogues in `messages/*.json` in sync. When you add,
40+
remove, or rename a user-facing key, update every locale listed in
41+
`project.inlang/settings.json` and keep their key sets identical.
42+
- After changing a message catalogue or localized component, run
43+
`npm run i18n:compile` and `npm run check` when practical.

internal/duckdb/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ tunnel/proxy.
1717
The DuckDB schema intentionally avoids `TIMESTAMP DEFAULT current_timestamp`
1818
columns because current Quack attach rejects catalogs with those dynamic
1919
defaults. Writers supply `current_timestamp` explicitly where the mirror needs a
20-
created timestamp. Existing mirrors are additively migrated by `EnsureSchema`.
20+
created timestamp. A schema-version change builds a fresh mirror, validates it,
21+
and swaps it into place atomically. `EnsureSchema` initializes fresh mirrors; it
22+
is not an in-place production migration path.
2123

2224
Search currently keeps substring/regex fallback behavior. The DuckDB FTS
2325
extension is available locally in the pinned runtime, but BM25 lookup does not

0 commit comments

Comments
 (0)