Part 2 — Core Concepts
2.1 The IR (intermediate representation)#
Every kind of thing you design has a JSON Schema in kernel-schemas/ and is wrapped in a common
envelope (artifact-envelope.schema.json). The schemas are authoritative.
| Kind | Schema | Designed in |
|---|---|---|
| Entity | entity.schema.json |
Data model |
| Form | form.schema.json |
Forms |
| Page, Component library, Design system | page, componentlibrary, designsystem |
Page designer, Design system |
| Process | process.schema.json |
Process designer |
| Decision | decision.schema.json |
Decision designer |
| Glossary | glossary.schema.json |
Glossary designer |
| Flow, Connection, Policy | flow, connection, policy |
Integration designer |
| Content, Dashboard | content, dashboard |
Content / dashboard editors |
| Contract | contract.schema.json |
Contract between apps (version-pinned, drift detectable) |
| App, Bundle, Group | app, bundle, group |
Project page, Deployment Center |
| Workspace, Security | workspace, security |
People & access, Environments |
| Work Portal config | workportalconfig.schema.json |
Process/Work Portal settings |
Two renderers, one spec. A designer draws the spec; a generator turns it into running code. When they disagree, parity tests catch it; when they agree and are both wrong, nothing does — which is why both are changed together.
2.2 The Kernel#
The Kernel is an event store. A change is an event appended to an artifact's history; the
current spec is a fold over its events (foldEvents, one function for both backends).
- Backends. Postgres (
kernel-pg.js,store-pg.js; the real one, :5437) and a JSONL file backend (kernel.js,store.js) for offline work. They must agree; parity tests run the same sequences through both. - Compositions. A group of tool calls applied as one step. Undo/redo operate on compositions.
- Tombstones. Deletions are recorded, not erased.
- Lifecycle. Draft → publish → promote (live) → archive/restore. Stored as columns, not events.
- Upsert guard. Re-running a seed never silently replaces an edit: a three-way compare of the
last imported spec, the stored spec and the incoming one (
upsert-guard.js). Edited-and-changed is refused (EDITED_SINCE_IMPORT).
- Facade.
http-server.jsserves the tools over HTTP on 127.0.0.1 (default :4500; the dev launch config uses :4600). It authenticates, authorizes per workspace, and validates arguments.mcp-server.jsserves the same tools over stdio, andPOST /mcpover HTTP with a bearer token.
2.3 The artifact graph#
Artifacts reference each other (page → entity, process node → form, flow → connection, decision →
glossary term). graph.js and kernel_impact answer "what depends on this?" so a change or a delete
can show what it would break. References are recognised only where the schema declares one
(refSites), never in free text.
2.4 The typed tool layer#
All changes, from the Workbench, from scripts, and from Veda, go through typed tools — one module
per artifact kind under kernel-poc/src/tools/ (the exact count is derived by test-tool-schemas.js,
not written down here). Properties that matter:
The Authorize step checks workspace bindings only when KERNEL_ENFORCE_BINDINGS is true (default false).
- Each tool has a declared
inputSchema; every call is validated bytool-args.jsbefore authorization and before the handler runs. - Read-only tools are listed by name (
READ_ONLY_TOOLS); everything else needs an established identity and the right verb in the target's workspace. - A tool refuses rather than guesses (a rename is never inferred from a diff; a destructive migration is not emitted).
2.5 Design principles#
These principles are load-bearing: each exists because breaking it once produced a bug that looked like something else.
| Principle | What it means in practice |
|---|---|
| Fail closed | A row policy that cannot be enforced returns 503, not every row. A migration that cannot complete does not record its version. |
| Refuse rather than guess | Unknown variant → no class; blocked migration → not emitted even with --allow-destructive. |
| One parser per language | Expressions: compile-expr.js. FEEL: compile-feel.js. A second parser would be a second dialect. |
| Every SQL value is a bind parameter; every identifier is quoted | Applies to generators and row policies alike. |
| Generated output is never edited | Regenerate. Hand-written config lives beside it (e.g. .env.local). |
| Parity is proved by execution | The in-app and Hub runtimes are compared by sending the same input to both. |
| The design system is the dictionary | Generators emit markup from component contracts; the HTML importer reads it back through the same contracts. |
| Secrets are never in artifacts | Connections hold names; values live in the vault (Part 6). |