@codyswann/lisa 2.166.4 → 2.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/package.json +5 -5
  2. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  3. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  4. package/plugins/lisa-agy/plugin.json +1 -1
  5. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  6. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  7. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  8. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  9. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  10. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  11. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  12. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  13. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  14. package/plugins/lisa-expo-agy/plugin.json +1 -1
  15. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  16. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  17. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  19. package/plugins/lisa-harper-fabric/skills/harper-schema-graphql/SKILL.md +68 -17
  20. package/plugins/lisa-harper-fabric/skills/harper-testing/SKILL.md +254 -0
  21. package/plugins/lisa-harper-fabric/skills/harper-testing/agents/openai.yaml +4 -0
  22. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  23. package/plugins/lisa-harper-fabric-agy/skills/harper-schema-graphql/SKILL.md +68 -17
  24. package/plugins/lisa-harper-fabric-agy/skills/harper-testing/SKILL.md +254 -0
  25. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-harper-fabric-copilot/skills/harper-schema-graphql/SKILL.md +68 -17
  27. package/plugins/lisa-harper-fabric-copilot/skills/harper-testing/SKILL.md +254 -0
  28. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-harper-fabric-cursor/skills/harper-schema-graphql/SKILL.md +68 -17
  30. package/plugins/lisa-harper-fabric-cursor/skills/harper-testing/SKILL.md +254 -0
  31. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  33. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  34. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  39. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  43. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  44. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  48. package/plugins/lisa-rails-agy/plugin.json +1 -1
  49. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  54. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  59. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/src/harper-fabric/skills/harper-schema-graphql/SKILL.md +68 -17
  62. package/plugins/src/harper-fabric/skills/harper-testing/SKILL.md +254 -0
@@ -16,28 +16,39 @@ the REST/GraphQL surface exposes.
16
16
  ## Defining tables
17
17
 
18
18
  A table is a GraphQL type. Harper-specific directives mark a type as a persisted
19
- table and control exposure, primary keys, and indexes. The exact directive set
20
- depends on the Harper version in use confirm against the live `schema.graphql`
21
- in this project and the Harper schema docs before adding new syntax. Common shape:
19
+ table and control exposure, primary keys, indexes, audit timestamps, sealed
20
+ records, and relationships. Lisa's Harper Fabric template pins `harperdb` to the
21
+ Harper 4 line (`^4.7.29`), so use this v4 directive reference for template
22
+ projects:
22
23
 
23
24
  ```graphql
24
- type Dog @table {
25
- id: ID @primaryKey
25
+ type Dog @table @export(name: "dogs") {
26
+ id: Long @primaryKey
26
27
  name: String @indexed
27
28
  breed: String
28
- owner: String
29
+ ownerId: Long @indexed
30
+ owner: Owner @relationship(from: ownerId)
31
+ createdAt: Long @createdTime
32
+ updatedAt: Long @updatedTime
29
33
  }
30
34
  ```
31
35
 
32
- - `@table` marks the type as a persisted Harper table.
33
- - `@primaryKey` marks the primary key field.
34
- - `@indexed` adds a secondary index for query/`search`.
35
- - Exposure of a type as an API endpoint is controlled by the schema/`rest`
36
- configuration see [[harper-config-yaml]].
37
-
38
- > Treat the directive names above as a starting point, not gospel verify against
39
- > the project's existing schema and current Harper docs, since directive syntax has
40
- > evolved across versions.
36
+ | Directive | Scope | Syntax | Use |
37
+ | --- | --- | --- | --- |
38
+ | `@table` | Type | `type Product @table { ... }` | Creates a persisted table named after the type. Optional arguments: `table: "products"` to override the table name, `database: "commerce"` to choose a database, `expiration: 3600` for TTL-style records, and `audit: true` to force audit logging. |
39
+ | `@export` | Type | `type Product @table @export(name: "products") { ... }` | Exposes the table as a resource endpoint for REST/MQTT and related surfaces. `name` is optional; without it the type name is the path segment. |
40
+ | `@sealed` | Type | `type Product @table @sealed { ... }` | Rejects undeclared properties. Omit it when the table intentionally accepts extra record fields. |
41
+ | `@primaryKey` | Field | `id: Long @primaryKey` | Marks the unique table key. If omitted on insert, Harper v4 can auto-generate a UUID for `String`/`ID` keys or an auto-incrementing integer for `Int`/`Long`/`Any` keys. Prefer `Long` or `Any` for generated numeric keys. |
42
+ | `@indexed` | Field | `sku: String @indexed` | Adds a secondary index used by REST filters, SQL, and NoSQL/search paths. Array fields index each element. For vectors in Harper v4.6+, use `embedding: [Float] @indexed(type: "HNSW")`. |
43
+ | `@createdTime` | Field | `createdAt: Long @createdTime` | Writes Unix epoch milliseconds when the record is created. |
44
+ | `@updatedTime` | Field | `updatedAt: Long @updatedTime` | Writes Unix epoch milliseconds whenever the record is updated. |
45
+ | `@relationship(from: field)` | Field | `owner: Owner @relationship(from: ownerId)` | The foreign key is on this table and references the target table primary key. If the foreign key field is an array, the relationship is many-to-many. |
46
+ | `@relationship(to: field)` | Field | `dogs: [Dog] @relationship(to: ownerId)` | The foreign key is on the target table. The relationship field must be an array. |
47
+ | `@relationship(from: field, to: field)` | Field | `product: Product @relationship(from: productSku, to: sku)` | Joins this table's field to a non-primary-key field on the target table. Index both join fields. |
48
+
49
+ Use v5 docs only when the downstream project has intentionally moved off the Lisa
50
+ template's Harper 4 dependency; do not mix v5-only syntax into a `harperdb`
51
+ `^4.7.29` project.
41
52
 
42
53
  ## How the schema drives the app
43
54
 
@@ -48,6 +59,45 @@ type Dog @table {
48
59
  or removal in the schema is a breaking change for every resource and verify path
49
60
  that references it.
50
61
 
62
+ ## Schema evolution
63
+
64
+ Schema changes are deploy-time data-model changes, not just type edits. Harper's
65
+ `graphqlSchema` extension ensures declared tables and attributes exist when the
66
+ component loads, but it does not perform semantic data migrations such as
67
+ renaming tables, copying field values, or rewriting existing rows for you.
68
+
69
+ Classify each change before editing:
70
+
71
+ | Change | Compatibility | What Harper does | Required agent work |
72
+ | --- | --- | --- | --- |
73
+ | Add optional field | Usually safe | Adds the declared attribute shape; existing rows read as missing/`null` until written. | Update resources, seeds, and verification that should include the field. |
74
+ | Add required/non-null field | Breaking for existing rows and writers | The schema can declare the field, but existing records do not magically gain valid values. | Backfill first or deploy as optional, populate, then tighten in a later deploy. |
75
+ | Add `@indexed` | Usually safe, operationally sensitive | Creates/uses a secondary index for the attribute. Large tables may pay rebuild cost. | Verify filtered REST/search paths and note index build risk in the deploy runbook. |
76
+ | Add `@sealed` | Breaking when rows or writers use extra properties | Future writes with undeclared properties are rejected. | Audit current data/writers, declare needed fields, or migrate callers before sealing. |
77
+ | Rename field | Breaking | Treated as a new field; the old field and its values are not transformed. | Add the new field, copy values with a migration, update code, verify, then remove old usage. |
78
+ | Rename type/table | Breaking | Harper v4 does not rename tables; changing the type name creates a new empty table and leaves the old table/data untouched. | Create the new table, copy data, update resources/routes, verify both read/write paths, then retire the old table intentionally. |
79
+ | Change field type | Breaking | Existing stored values are not coerced into the new type in a controlled migration. | Add a replacement field/table, transform data with code, verify, then remove old usage. |
80
+ | Remove field/type | Breaking | Schema no longer declares it, but dependent resources, routes, queries, seeds, and clients can still reference it. | Delete references first, run a migration/cleanup if needed, and verify old API paths fail or redirect intentionally. |
81
+
82
+ Migration recipe for production data:
83
+
84
+ 1. Add the new schema shape in a backward-compatible way: new table or nullable
85
+ replacement field, keeping the old field/table available.
86
+ 2. Write a one-shot migration using a Harper resource method or Operations
87
+ API/script that reads old rows, transforms values, and writes the new shape.
88
+ Make it idempotent; reruns should skip rows already migrated or compare a
89
+ migration marker.
90
+ 3. Deploy to one Fabric environment and run the migration before switching
91
+ readers/writers. For replicated Fabric deployments, assume every node may see
92
+ the new code/schema at slightly different times; keep old and new reads
93
+ compatible until replication and smoke checks are green.
94
+ 4. Update resources, REST/GraphQL queries, data-loader seeds, and verify scripts
95
+ in the same PR. A schema PR is incomplete if `bun run verify` or the project
96
+ smoke path cannot prove the migrated read/write behavior.
97
+ 5. Roll back by reverting code/schema only when the old field/table remains
98
+ intact. Once cleanup drops old data or callers, rollback needs a reverse
99
+ migration and a restored compatibility path.
100
+
51
101
  ## Project conventions
52
102
 
53
103
  - `schema.graphql` is **source** and lives at the component root that Fabric
@@ -68,5 +118,6 @@ Run any verify path that asserts row counts or joins against the changed model.
68
118
 
69
119
  ## Sources
70
120
 
71
- - [Components overview](https://docs.harperdb.io/reference/v5/components/overview)
72
- - [Applications](https://docs.harperdb.io/docs/developers/applications)
121
+ - [Harper v4 Schema](https://docs.harperdb.io/reference/v4/database/schema)
122
+ - [Components overview](https://docs.harperdb.io/reference/v4/components/overview)
123
+ - [Operations API](https://docs.harperdb.io/reference/v4/operations-api/operations)
@@ -0,0 +1,254 @@
1
+ ---
2
+ name: harper-testing
3
+ description: This skill should be used when adding, repairing, or designing tests for a Harper (HarperDB/Fabric) component app — Vitest unit tests for pure functions and Resource methods, local Harper integration tests that boot/symlink/seed/assert real endpoints, Playwright e2e tests against REST/GraphQL routes, and schema/verify-script coupling. Use it when a Harper app needs its first test suite, endpoint coverage, seed isolation, or a local smoke/verify path. Pairs with harper-build-and-deploy, harper-schema-graphql, and e2e-coverage-gaps.
4
+ ---
5
+
6
+ # Harper Testing
7
+
8
+ ## Overview
9
+
10
+ Test Harper apps at the layer that proves the risk:
11
+
12
+ 1. **Pure unit tests** for TypeScript helpers and data transforms.
13
+ 2. **Resource unit tests** for `Resource` methods with mocked Harper runtime globals.
14
+ 3. **Integration tests** against a running local Harper component with real schema,
15
+ resources, seed data, and REST/GraphQL responses.
16
+ 4. **Playwright e2e tests** against the same HTTP surface a user or client calls.
17
+
18
+ Harper application source lives in TypeScript under `src/`; deployable
19
+ `harper-app/resources.js`, `harper-app/resource-*.js`, and `harper-app/web/**` are
20
+ generated. Build before integration or e2e tests so the runtime loads the code you
21
+ just changed. See [[harper-build-and-deploy]].
22
+
23
+ ## Test pyramid
24
+
25
+ | Layer | Tool | Use when | Avoid |
26
+ | --- | --- | --- | --- |
27
+ | Pure unit | Vitest | Validating transforms, validators, serializers, query builders, and other code with no Harper runtime dependency. | Mocking HTTP or tables for logic that can stay pure. |
28
+ | Resource unit | Vitest | Exercising `get`, `post`, `search`, `patch`, or permission/error logic in a resource class without booting Harper. | Treating mocked tables as proof that `config.yaml`, `schema.graphql`, or REST exposure works. |
29
+ | Integration | Vitest or shell smoke | Proving Harper boots, schema loads, `jsResource` registers code, data seeds, and endpoints respond. | Replacing this with resource mocks after config, schema, or generated artifact changes. |
30
+ | E2E | Playwright | Verifying client-observable REST/GraphQL behavior, auth states, error paths, and browser workflows. | Re-testing every pure branch through the browser. |
31
+
32
+ Use [[e2e-coverage-gaps]] after a suite exists to find missing routes and
33
+ non-happy paths. Use this skill when creating or repairing the test patterns
34
+ themselves.
35
+
36
+ ## Pure unit tests
37
+
38
+ Keep business transforms importable without Harper globals:
39
+
40
+ ```typescript
41
+ import { describe, expect, it } from 'vitest';
42
+ import { normalizePetName } from '../src/pets/normalize';
43
+
44
+ describe('normalizePetName', () => {
45
+ it('trims and title-cases names', () => {
46
+ expect(normalizePetName(' ada LOVELACE ')).toBe('Ada Lovelace');
47
+ });
48
+ });
49
+ ```
50
+
51
+ If a resource method contains complex transformation logic, extract the pure part
52
+ and test it directly. Leave a thinner resource test for runtime wiring,
53
+ authorization, and persistence behavior.
54
+
55
+ ## Resource unit tests
56
+
57
+ Harper injects runtime globals such as `Resource` and `tables` when it loads
58
+ `resources.js`. Unit tests do not get those globals automatically. Test resource
59
+ methods by importing code through a seam that accepts mocks, or by setting the
60
+ minimal globals before importing the resource module.
61
+
62
+ Prefer dependency injection for new code:
63
+
64
+ ```typescript
65
+ import { describe, expect, it, vi } from 'vitest';
66
+ import { createPetsResource } from '../src/resources/pets';
67
+
68
+ describe('PetsResource.get', () => {
69
+ it('adds adoption status from the table record', async () => {
70
+ const table = {
71
+ get: vi.fn(async () => ({ id: 'pet-1', name: 'Mina', adoptedAt: null })),
72
+ };
73
+ const Pets = createPetsResource({ Resource: class {}, table });
74
+
75
+ await expect(Pets.get({ id: 'pet-1' })).resolves.toMatchObject({
76
+ id: 'pet-1',
77
+ name: 'Mina',
78
+ adoptionStatus: 'available',
79
+ });
80
+ expect(table.get).toHaveBeenCalledWith({ id: 'pet-1' });
81
+ });
82
+ });
83
+ ```
84
+
85
+ When existing code must extend `tables.X` directly, isolate the runtime globals in
86
+ a test helper and import the module after setup:
87
+
88
+ ```typescript
89
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
90
+
91
+ describe('Pets resource', () => {
92
+ beforeEach(() => {
93
+ vi.resetModules();
94
+ vi.stubGlobal('Resource', class {});
95
+ vi.stubGlobal('tables', {
96
+ Pets: class {
97
+ static async get(target: { id: string }) {
98
+ return { id: target.id, name: 'Mina' };
99
+ }
100
+ },
101
+ });
102
+ });
103
+
104
+ it('wraps the runtime table', async () => {
105
+ const { Pets } = await import('../src/resources/pets');
106
+ await expect(Pets.get({ id: 'pet-1' })).resolves.toMatchObject({
107
+ id: 'pet-1',
108
+ name: 'Mina',
109
+ });
110
+ });
111
+ });
112
+ ```
113
+
114
+ Keep mocks narrow. Mock only the table methods, `Resource` base behavior,
115
+ `server.resources`, or external fetch calls the method actually uses. If the test
116
+ starts recreating Harper's schema, REST routing, or auth behavior, move it to an
117
+ integration test.
118
+
119
+ ## Integration tests with local Harper
120
+
121
+ Use integration tests to prove the component runs as Harper will load it:
122
+
123
+ 1. Install dependencies and build TypeScript: `bun install --frozen-lockfile`
124
+ when needed, then `bun run build`.
125
+ 2. Start a local Harper process against the component, usually
126
+ `harper dev harper-app` for watch mode or `harper run harper-app` for a
127
+ one-shot test process. Use the project's wrapper command when present.
128
+ 3. If the test lives outside the app repo, symlink the built component into
129
+ Harper's component directory rather than copying generated artifacts by hand.
130
+ Clean the symlink in teardown.
131
+ 4. Seed data through `dataLoader` fixtures when the project owns static fixtures,
132
+ or through REST/Operations API calls when each test needs dynamic setup.
133
+ 5. Assert the real REST/GraphQL endpoint and response body.
134
+ 6. Stop Harper and remove test data, temp components, and symlinks.
135
+
136
+ Shell smoke tests are acceptable when the project already has that convention.
137
+ Keep them strict: exit non-zero on boot failure, seed failure, missing endpoint,
138
+ wrong status, or wrong response shape.
139
+
140
+ Example integration skeleton:
141
+
142
+ ```bash
143
+ #!/usr/bin/env bash
144
+ set -euo pipefail
145
+
146
+ bun run build
147
+
148
+ HARPER_APP_DIR="${PWD}/harper-app"
149
+ HARPER_HOME="${HARPER_HOME:-${PWD}/.harper-test}"
150
+ BASE_URL="${BASE_URL:-http://127.0.0.1:9926}"
151
+
152
+ mkdir -p "$HARPER_HOME/components"
153
+ ln -sfn "$HARPER_APP_DIR" "$HARPER_HOME/components/pets"
154
+
155
+ HARPER_HOME="$HARPER_HOME" harper run "$HARPER_APP_DIR" > /tmp/harper-test.log 2>&1 &
156
+ HARPER_PID=$!
157
+ trap 'kill "$HARPER_PID" 2>/dev/null || true; rm -f "$HARPER_HOME/components/pets"' EXIT
158
+
159
+ for _ in {1..30}; do
160
+ curl -fsS "$BASE_URL/health" >/dev/null && break
161
+ sleep 1
162
+ done
163
+
164
+ curl -fsS -X POST "$BASE_URL/Pets" \
165
+ -H 'content-type: application/json' \
166
+ --data '{"id":"pet-it-1","name":"Mina"}' >/dev/null
167
+
168
+ curl -fsS "$BASE_URL/Pets/pet-it-1" | jq -e '.name == "Mina"'
169
+ ```
170
+
171
+ Adjust the health path, component name, port, and endpoint names to the project.
172
+ Do not commit local `HARPER_HOME`, logs, generated component copies, or secrets.
173
+
174
+ ## Seeding and isolation
175
+
176
+ Use deterministic test data that cannot collide with developer or CI data:
177
+
178
+ - Prefix IDs with the test name and a run ID, for example
179
+ `pet-${process.env.GITHUB_RUN_ID ?? Date.now()}`.
180
+ - Prefer per-test setup/teardown through REST or Operations API when tests mutate
181
+ records.
182
+ - Prefer `dataLoader` fixtures for stable baseline data that every local boot
183
+ should have.
184
+ - Make teardown idempotent; deleting a record that is already gone should not fail
185
+ the suite.
186
+ - Keep seed fixtures aligned with [[harper-schema-graphql]]. A field or type rename
187
+ must update fixtures, resource tests, verify scripts, and Playwright assertions in
188
+ the same PR.
189
+
190
+ `dataLoader` is good for fast, declarative baseline rows. REST seeding is better
191
+ when the test must exercise validation, defaults, auth, or generated IDs exactly as
192
+ clients see them.
193
+
194
+ ## Playwright endpoint tests
195
+
196
+ Use Playwright for HTTP behavior that needs browser tooling, request contexts,
197
+ storage state, tracing, or cross-browser/project coverage. A first endpoint spec
198
+ should cover one happy path and one non-happy path:
199
+
200
+ ```typescript
201
+ import { expect, test } from '@playwright/test';
202
+
203
+ test.describe('Pets REST endpoint', () => {
204
+ test('creates and reads a pet', async ({ request }) => {
205
+ const id = `pet-pw-${Date.now()}`;
206
+
207
+ const create = await request.post('/Pets', {
208
+ data: { id, name: 'Mina' },
209
+ });
210
+ expect(create.ok()).toBe(true);
211
+
212
+ const read = await request.get(`/Pets/${id}`);
213
+ expect(read.status()).toBe(200);
214
+ await expect(read).toHaveJSON(expect.objectContaining({ id, name: 'Mina' }));
215
+ });
216
+
217
+ test('rejects invalid payloads', async ({ request }) => {
218
+ const response = await request.post('/Pets', {
219
+ data: { name: '' },
220
+ });
221
+
222
+ expect(response.status()).toBeGreaterThanOrEqual(400);
223
+ await expect(response).toHaveJSON(
224
+ expect.objectContaining({
225
+ error: expect.any(String),
226
+ }),
227
+ );
228
+ });
229
+ });
230
+ ```
231
+
232
+ If the project uses custom auth, set `storageState`, headers, or a request fixture
233
+ in Playwright config instead of embedding credentials in specs. Never commit
234
+ tokens or local `.env` values.
235
+
236
+ ## Schema and verify coupling
237
+
238
+ A schema rename or resource route change is a breaking change for every verify
239
+ path that names that table, field, endpoint, fixture, or response shape.
240
+
241
+ In the same PR as a schema/resource change:
242
+
243
+ - Update `schema.graphql`, TypeScript resources, fixtures, and data loaders.
244
+ - Update Vitest resource tests and Playwright endpoint specs.
245
+ - Update shell smoke or `scripts/verify*` paths that assert row counts, joins, or
246
+ response keys.
247
+ - Run `bun run build`, `bun run typecheck`, and the smallest relevant test command.
248
+ - For deploy-affecting changes, boot local Harper or run the project smoke command
249
+ against the deployed endpoint. See [[harper-build-and-deploy]].
250
+
251
+ Do not report a Harper test change done only because mocks pass. At least one
252
+ verify path must prove the generated app still boots and exposes the expected
253
+ surface whenever config, schema, resources, generated artifacts, or endpoints are
254
+ part of the change.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "2.166.4",
3
+ "version": "2.167.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -16,28 +16,39 @@ the REST/GraphQL surface exposes.
16
16
  ## Defining tables
17
17
 
18
18
  A table is a GraphQL type. Harper-specific directives mark a type as a persisted
19
- table and control exposure, primary keys, and indexes. The exact directive set
20
- depends on the Harper version in use confirm against the live `schema.graphql`
21
- in this project and the Harper schema docs before adding new syntax. Common shape:
19
+ table and control exposure, primary keys, indexes, audit timestamps, sealed
20
+ records, and relationships. Lisa's Harper Fabric template pins `harperdb` to the
21
+ Harper 4 line (`^4.7.29`), so use this v4 directive reference for template
22
+ projects:
22
23
 
23
24
  ```graphql
24
- type Dog @table {
25
- id: ID @primaryKey
25
+ type Dog @table @export(name: "dogs") {
26
+ id: Long @primaryKey
26
27
  name: String @indexed
27
28
  breed: String
28
- owner: String
29
+ ownerId: Long @indexed
30
+ owner: Owner @relationship(from: ownerId)
31
+ createdAt: Long @createdTime
32
+ updatedAt: Long @updatedTime
29
33
  }
30
34
  ```
31
35
 
32
- - `@table` marks the type as a persisted Harper table.
33
- - `@primaryKey` marks the primary key field.
34
- - `@indexed` adds a secondary index for query/`search`.
35
- - Exposure of a type as an API endpoint is controlled by the schema/`rest`
36
- configuration see [[harper-config-yaml]].
37
-
38
- > Treat the directive names above as a starting point, not gospel verify against
39
- > the project's existing schema and current Harper docs, since directive syntax has
40
- > evolved across versions.
36
+ | Directive | Scope | Syntax | Use |
37
+ | --- | --- | --- | --- |
38
+ | `@table` | Type | `type Product @table { ... }` | Creates a persisted table named after the type. Optional arguments: `table: "products"` to override the table name, `database: "commerce"` to choose a database, `expiration: 3600` for TTL-style records, and `audit: true` to force audit logging. |
39
+ | `@export` | Type | `type Product @table @export(name: "products") { ... }` | Exposes the table as a resource endpoint for REST/MQTT and related surfaces. `name` is optional; without it the type name is the path segment. |
40
+ | `@sealed` | Type | `type Product @table @sealed { ... }` | Rejects undeclared properties. Omit it when the table intentionally accepts extra record fields. |
41
+ | `@primaryKey` | Field | `id: Long @primaryKey` | Marks the unique table key. If omitted on insert, Harper v4 can auto-generate a UUID for `String`/`ID` keys or an auto-incrementing integer for `Int`/`Long`/`Any` keys. Prefer `Long` or `Any` for generated numeric keys. |
42
+ | `@indexed` | Field | `sku: String @indexed` | Adds a secondary index used by REST filters, SQL, and NoSQL/search paths. Array fields index each element. For vectors in Harper v4.6+, use `embedding: [Float] @indexed(type: "HNSW")`. |
43
+ | `@createdTime` | Field | `createdAt: Long @createdTime` | Writes Unix epoch milliseconds when the record is created. |
44
+ | `@updatedTime` | Field | `updatedAt: Long @updatedTime` | Writes Unix epoch milliseconds whenever the record is updated. |
45
+ | `@relationship(from: field)` | Field | `owner: Owner @relationship(from: ownerId)` | The foreign key is on this table and references the target table primary key. If the foreign key field is an array, the relationship is many-to-many. |
46
+ | `@relationship(to: field)` | Field | `dogs: [Dog] @relationship(to: ownerId)` | The foreign key is on the target table. The relationship field must be an array. |
47
+ | `@relationship(from: field, to: field)` | Field | `product: Product @relationship(from: productSku, to: sku)` | Joins this table's field to a non-primary-key field on the target table. Index both join fields. |
48
+
49
+ Use v5 docs only when the downstream project has intentionally moved off the Lisa
50
+ template's Harper 4 dependency; do not mix v5-only syntax into a `harperdb`
51
+ `^4.7.29` project.
41
52
 
42
53
  ## How the schema drives the app
43
54
 
@@ -48,6 +59,45 @@ type Dog @table {
48
59
  or removal in the schema is a breaking change for every resource and verify path
49
60
  that references it.
50
61
 
62
+ ## Schema evolution
63
+
64
+ Schema changes are deploy-time data-model changes, not just type edits. Harper's
65
+ `graphqlSchema` extension ensures declared tables and attributes exist when the
66
+ component loads, but it does not perform semantic data migrations such as
67
+ renaming tables, copying field values, or rewriting existing rows for you.
68
+
69
+ Classify each change before editing:
70
+
71
+ | Change | Compatibility | What Harper does | Required agent work |
72
+ | --- | --- | --- | --- |
73
+ | Add optional field | Usually safe | Adds the declared attribute shape; existing rows read as missing/`null` until written. | Update resources, seeds, and verification that should include the field. |
74
+ | Add required/non-null field | Breaking for existing rows and writers | The schema can declare the field, but existing records do not magically gain valid values. | Backfill first or deploy as optional, populate, then tighten in a later deploy. |
75
+ | Add `@indexed` | Usually safe, operationally sensitive | Creates/uses a secondary index for the attribute. Large tables may pay rebuild cost. | Verify filtered REST/search paths and note index build risk in the deploy runbook. |
76
+ | Add `@sealed` | Breaking when rows or writers use extra properties | Future writes with undeclared properties are rejected. | Audit current data/writers, declare needed fields, or migrate callers before sealing. |
77
+ | Rename field | Breaking | Treated as a new field; the old field and its values are not transformed. | Add the new field, copy values with a migration, update code, verify, then remove old usage. |
78
+ | Rename type/table | Breaking | Harper v4 does not rename tables; changing the type name creates a new empty table and leaves the old table/data untouched. | Create the new table, copy data, update resources/routes, verify both read/write paths, then retire the old table intentionally. |
79
+ | Change field type | Breaking | Existing stored values are not coerced into the new type in a controlled migration. | Add a replacement field/table, transform data with code, verify, then remove old usage. |
80
+ | Remove field/type | Breaking | Schema no longer declares it, but dependent resources, routes, queries, seeds, and clients can still reference it. | Delete references first, run a migration/cleanup if needed, and verify old API paths fail or redirect intentionally. |
81
+
82
+ Migration recipe for production data:
83
+
84
+ 1. Add the new schema shape in a backward-compatible way: new table or nullable
85
+ replacement field, keeping the old field/table available.
86
+ 2. Write a one-shot migration using a Harper resource method or Operations
87
+ API/script that reads old rows, transforms values, and writes the new shape.
88
+ Make it idempotent; reruns should skip rows already migrated or compare a
89
+ migration marker.
90
+ 3. Deploy to one Fabric environment and run the migration before switching
91
+ readers/writers. For replicated Fabric deployments, assume every node may see
92
+ the new code/schema at slightly different times; keep old and new reads
93
+ compatible until replication and smoke checks are green.
94
+ 4. Update resources, REST/GraphQL queries, data-loader seeds, and verify scripts
95
+ in the same PR. A schema PR is incomplete if `bun run verify` or the project
96
+ smoke path cannot prove the migrated read/write behavior.
97
+ 5. Roll back by reverting code/schema only when the old field/table remains
98
+ intact. Once cleanup drops old data or callers, rollback needs a reverse
99
+ migration and a restored compatibility path.
100
+
51
101
  ## Project conventions
52
102
 
53
103
  - `schema.graphql` is **source** and lives at the component root that Fabric
@@ -68,5 +118,6 @@ Run any verify path that asserts row counts or joins against the changed model.
68
118
 
69
119
  ## Sources
70
120
 
71
- - [Components overview](https://docs.harperdb.io/reference/v5/components/overview)
72
- - [Applications](https://docs.harperdb.io/docs/developers/applications)
121
+ - [Harper v4 Schema](https://docs.harperdb.io/reference/v4/database/schema)
122
+ - [Components overview](https://docs.harperdb.io/reference/v4/components/overview)
123
+ - [Operations API](https://docs.harperdb.io/reference/v4/operations-api/operations)