@mortar-ai/skill 0.5.0 → 0.7.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.
@@ -0,0 +1,117 @@
1
+ # Schema migrations and resource artifacts
2
+
3
+ Read this reference when authoring backend source, reviewing a typed migration
4
+ plan, resolving revision/checksum conflicts, writing application data types, or
5
+ deciding whether a Mortar capability belongs in source at all.
6
+
7
+ ## One canonical plan, AI-owned application types
8
+
9
+ Mortar parses SQL into `mortar.migration-plan.v1`, a language-neutral JSON plan.
10
+ That plan—not TypeScript, Swift, Kotlin, or Dart code—is the execution contract.
11
+ Mortar does not generate project source. After apply, the AI Turn combines the
12
+ canonical live schema, the relevant operations from `references/openapi.yaml`,
13
+ and the project's runtime conventions to write application-owned models and
14
+ request/response code through Harness. Those files are downstream consumers;
15
+ never edit them to request a schema change.
16
+
17
+ Search the OpenAPI by stable operation ID, for example:
18
+
19
+ ```sh
20
+ rg -n 'operationId: (insertDatabaseRows|listDatabaseRows)' \
21
+ /tmp/skills/mortar/references/openapi.yaml
22
+ ```
23
+
24
+ Read the selected operation and every referenced component schema before
25
+ writing code. An operation marked `x-mortar-project-code: forbidden` belongs to
26
+ Harness/control-plane tooling and must never be called from a user app.
27
+
28
+ ## Versioned database SQL
29
+
30
+ Submit exact SQL through `mortar_migrate`:
31
+
32
+ ```sql
33
+ -- mortar:access public_insert
34
+ CREATE TABLE submissions (
35
+ email text NOT NULL,
36
+ score integer,
37
+ metadata jsonb
38
+ );
39
+
40
+ ALTER TABLE submissions ADD COLUMN reviewed boolean NOT NULL;
41
+ CREATE INDEX submissions_reviewed ON submissions (reviewed, created_at);
42
+ ALTER TABLE submissions SET ACCESS app_only;
43
+ ```
44
+
45
+ The parser accepts common PostgreSQL type spellings and canonicalizes them to
46
+ Mortar's logical types: `text`, `number`, `bool`, `json`, `timestamp`, and
47
+ `uuid`. `id`, `created_at`, and `updated_at` are server-owned row metadata, so
48
+ they are not declared as application columns; system timestamps may still be
49
+ used in an index, as above. `NOT NULL` enforces required-field presence. Logical
50
+ type names inform project-language types but do not currently runtime-validate
51
+ every row value. The parser rejects `DEFAULT`, `UNIQUE`, `CHECK`, foreign keys,
52
+ row data, backfills, triggers, stored procedures, transaction control, and calls
53
+ that pretend functions/storage/cron are SQL. Never invent unsupported DDL or
54
+ describe client validation as a database constraint.
55
+
56
+ Plan/apply guarantees:
57
+
58
+ - SHA-256 covers the exact SQL bytes written to source.
59
+ - `migration_id + checksum` is idempotent; reusing an id with different bytes is
60
+ a conflict.
61
+ - Every tenant has a monotonic schema revision. Apply fails if the reviewed
62
+ `expected_revision` is stale.
63
+ - All logical schema operations and the revision ledger row commit in one
64
+ tenant-scoped PostgreSQL transaction.
65
+ - Source is written with Fabric's source-revision CAS before apply. If apply
66
+ fails, the file remains an honest pending migration that can be fixed or
67
+ retried; no live mutation is wrapped afterwards as fake SQL.
68
+
69
+ `DROP TABLE` removes its rows and `DROP COLUMN` removes the schema declaration;
70
+ both are destructive plan diagnostics. Changing access must use `ALTER TABLE …
71
+ SET ACCESS`, never drop/recreate.
72
+
73
+ ## Non-database desired state
74
+
75
+ Use `mortar_resource` so Fabric writes the exact artifact before reconciling the
76
+ live resource:
77
+
78
+ | Source path | Managed desired state |
79
+ |---|---|
80
+ | `mortar/functions/<name>/index.js` or `index.py` | Runtime-specific function source |
81
+ | `mortar/functions/<name>/function.json` | Runtime and authoritative entrypoint |
82
+ | `mortar/storage/buckets/<name>.json` | Bucket access policy |
83
+ | `mortar/cron/<name>.json` | Schedule, target function, enabled state |
84
+
85
+ Deleting a function or cron removes its current-state artifact. These resources
86
+ may call external systems and do not join a database migration transaction.
87
+
88
+ ## Complete capability-to-source matrix
89
+
90
+ “Mortar supports it” does not imply it should be a source artifact:
91
+
92
+ | Capability | Source authority | Why |
93
+ |---|---|---|
94
+ | Database tables/columns/access/index intent | Versioned SQL migration | Durable ordered schema with atomic revision ledger |
95
+ | Functions | Function directory | Executable source plus runtime metadata, not SQL |
96
+ | Bucket policy | Bucket JSON | Durable access policy; object bytes are runtime data |
97
+ | Cron schedules | Cron JSON | Durable desired schedule; executions are runtime state |
98
+ | Auth users/sessions/OTP/reset | None | Identity and credentials are runtime/security state |
99
+ | Database rows and row transactions | None | Application data, not schema |
100
+ | Stored files and signed URLs | None | Runtime objects and ephemeral authorization |
101
+ | Realtime row changes/broadcast/presence | None | Events and presence are runtime/ephemeral state |
102
+ | Queue jobs/claims/retries | None | Runtime work state; enqueue may join a row transaction |
103
+ | Analytics events/summaries | None | Runtime observations and derived reporting |
104
+ | Email/SMS sends | None | External side effects; make business workflows idempotent |
105
+ | Secret values | Encrypted Mortar secret store only | Values must never enter project source; source may document names in application-owned docs |
106
+ | Usage, logs, billing ledger | None | Platform observations and accounting authority |
107
+ | Projects, keys, PATs, domains, plans, capacity | None | Account/control-plane state |
108
+
109
+ ## Legacy projects
110
+
111
+ Do not automatically replay or rewrite an existing migration history merely
112
+ because this workflow shipped. Old files can describe already-live schema, and
113
+ some projects may keep explicit operator SQL under `mortar/operations/` for
114
+ capabilities outside Mortar logical DDL. Treat those files as legacy history;
115
+ new supported schema changes start at the next migration id. Arbitrary operator
116
+ SQL remains a separately reviewed operational path and is not silently claimed
117
+ as replayable Mortar migration source.
@@ -23,6 +23,11 @@ retryable cleanup. Never construct, persist, or expose an internal physical
23
23
  object key. Application projects do not run or author the platform storage
24
24
  migration.
25
25
 
26
+ Set durable bucket access through `mortar_resource`; Fabric writes
27
+ `mortar/storage/buckets/<name>.json` before reconciling the live policy. Object
28
+ bytes, logical object keys, signed URLs, and cleanup jobs remain runtime state
29
+ and never enter this source artifact.
30
+
26
31
  This protocol prevents Mortar metadata from pointing at a partial upload, but a
27
32
  separate application row and an object upload are not one transaction. Generate
28
33
  an unguessable logical key. For a simple workflow, upload first and write the