@vegastack/skills 0.4.0 → 0.6.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 (64) hide show
  1. package/README.md +4 -2
  2. package/dist/index.js +38 -45
  3. package/package.json +1 -1
  4. package/skill/architect/SKILL.md +68 -0
  5. package/skill/architect/agents/openai.yaml +4 -0
  6. package/skill/architect/assets/adr-template.md +21 -0
  7. package/skill/architect/assets/arch-template.md +20 -0
  8. package/skill/architect/references/advisory.md +102 -0
  9. package/skill/architect/references/ai-agents.md +95 -0
  10. package/skill/architect/references/data.md +90 -0
  11. package/skill/architect/references/infra.md +128 -0
  12. package/skill/architect/references/mobile.md +78 -0
  13. package/skill/architect/references/pinned-facts.md +108 -0
  14. package/skill/architect/references/principles.md +91 -0
  15. package/skill/architect/references/project-profile.md +37 -0
  16. package/skill/architect/references/security.md +97 -0
  17. package/skill/architect/references/stack.md +38 -0
  18. package/skill/architect/references/web.md +152 -0
  19. package/skill/architect/refresh/REFRESH.md +29 -0
  20. package/skill/architect/refresh/sources.json +244 -0
  21. package/skill/skill-maintainer/references/release-ops.md +11 -15
  22. package/skill/skill-maintainer/refresh/REFRESH.md +3 -3
  23. package/skill-integrity.json +20 -44
  24. package/skill/arch-guardian/SKILL.md +0 -84
  25. package/skill/arch-guardian/agents/openai.yaml +0 -4
  26. package/skill/arch-guardian/assets/adr-template.md +0 -25
  27. package/skill/arch-guardian/assets/answers-example.json +0 -10
  28. package/skill/arch-guardian/assets/architecture-profile.json +0 -13
  29. package/skill/arch-guardian/assets/architecture-profile.schema.json +0 -31
  30. package/skill/arch-guardian/assets/deployment-review-template.md +0 -24
  31. package/skill/arch-guardian/assets/service-design-template.md +0 -33
  32. package/skill/arch-guardian/assets/threat-model-template.md +0 -34
  33. package/skill/arch-guardian/references/advisory-report.md +0 -65
  34. package/skill/arch-guardian/references/architecture/agent-product.md +0 -22
  35. package/skill/arch-guardian/references/architecture/ai-cost.md +0 -24
  36. package/skill/arch-guardian/references/architecture/ai-data-boundaries.md +0 -21
  37. package/skill/arch-guardian/references/architecture/ai-evals.md +0 -28
  38. package/skill/arch-guardian/references/architecture/connectors-sandbox.md +0 -39
  39. package/skill/arch-guardian/references/architecture/data-memory.md +0 -25
  40. package/skill/arch-guardian/references/architecture/delivery-operations.md +0 -34
  41. package/skill/arch-guardian/references/architecture/durable-execution.md +0 -45
  42. package/skill/arch-guardian/references/architecture/flutter.md +0 -26
  43. package/skill/arch-guardian/references/architecture/foundation.md +0 -31
  44. package/skill/arch-guardian/references/architecture/hosting-reliability.md +0 -37
  45. package/skill/arch-guardian/references/architecture/identity-tenancy.md +0 -37
  46. package/skill/arch-guardian/references/architecture/model-lifecycle.md +0 -20
  47. package/skill/arch-guardian/references/architecture/models-observability.md +0 -23
  48. package/skill/arch-guardian/references/architecture/realtime-channels.md +0 -16
  49. package/skill/arch-guardian/references/architecture/security-privacy.md +0 -27
  50. package/skill/arch-guardian/references/architecture/topology-monorepo.md +0 -47
  51. package/skill/arch-guardian/references/architecture/web.md +0 -29
  52. package/skill/arch-guardian/references/foundation-compatibility.json +0 -44
  53. package/skill/arch-guardian/references/golden-patterns.md +0 -43
  54. package/skill/arch-guardian/references/profile-governance.md +0 -40
  55. package/skill/arch-guardian/references/rule-model.json +0 -36
  56. package/skill/arch-guardian/references/workflows.md +0 -48
  57. package/skill/arch-guardian/refresh/REFRESH.md +0 -47
  58. package/skill/arch-guardian/refresh/sources.json +0 -1171
  59. package/skill/arch-guardian/scripts/lib.mjs +0 -48
  60. package/skill/arch-guardian/scripts/profile-tool.mjs +0 -217
  61. package/skill/arch-guardian/scripts/refresh-evidence.mjs +0 -366
  62. package/skill/arch-guardian/scripts/schema-validate.mjs +0 -63
  63. package/skill/arch-guardian/scripts/validate-profile.mjs +0 -65
  64. package/skill/arch-guardian/scripts/verify-corpus.mjs +0 -136
@@ -1,84 +0,0 @@
1
- ---
2
- name: arch-guardian
3
- description: Architecture advisor for VegaStack projects. Use when designing a new service or feature, reviewing architecture or a risky change (auth, tenancy, agents, jobs, connectors, data lifecycle, hosting), deciding between architectural options, writing an ADR or a .vegastack/architecture.json profile, threat modeling, planning a migration, or checking dependency and source drift. Advises contextually by declared tier (prototype, production, enterprise) and enabled capabilities; recommends the smallest architecture that meets the requirement and produces evidence-backed advisory reports, never CI gates. Covers web-only, Flutter, agentic and non-agentic, single- and multi-tenant, internal, client, and package projects.
4
- ---
5
-
6
- # VegaStack Architecture Guardian
7
-
8
- Act as the project's senior architecture advisor. Apply only enabled capabilities at the declared tier. Recommend; never gate. Never invent compliance or project facts. There is no exception machinery: a team that departs from a recommendation records the decision, and you keep reporting it honestly as accepted risk.
9
-
10
- ## Start every task
11
-
12
- 1. Identify the actual decision, its scope, and how expensive it is to reverse.
13
- 2. Read the profile (`.vegastack/architecture.json`) and repository evidence before asking questions. Keep read-only work read-only; never create a profile or artifact merely because it is absent.
14
- 3. Note the **tier** (`prototype` | `production` | `enterprise`) — it decides which concerns apply. If no profile exists, ask for the tier (or state the assumed one) before recommending.
15
- 4. Separate facts, constraints, assumptions, preferences, and recorded team decisions. Distinguish current, target, and migration state.
16
- 5. Ask at most three material questions at a time. If unanswered, proceed with bounded assumptions and the smallest architecture that meets stated requirements — every proposed moving service names the trigger that justifies it.
17
- 6. Read only the directly relevant references below. Use the committed profile, designs, and ADRs as architecture memory; never rely on hidden chat state.
18
- 7. Prioritize security/correctness, recovery, ownership, contracts, operability, delivery, then optional optimization. Make one primary recommendation and identify the rejected alternative.
19
-
20
- Script invocations below write `<skill-dir>` as a placeholder: replace it with the absolute path of the directory containing this SKILL.md before running (no environment variable is set for you).
21
-
22
- ## Answer at the right size
23
-
24
- - **Questions and explanations:** answer directly — the recommendation and at most one material risk. No section headers, no report.
25
- - **Design reviews, ADRs, migration plans:** use the [advisory report contract](references/advisory-report.md): per-area grades (`sound`/`attention`/`at-risk`), severity-ranked findings (`critical`/`production-gate`/`enterprise-gate`/`consider`), each with cited evidence and its principle ID, plus questions and not-verified items. No finding without evidence; detection is never a claim of absence.
26
-
27
- ## Route progressively
28
-
29
- | Need | Read |
30
- |---|---|
31
- | operating model, tiers, minimum viable architecture, profiles | [foundation](references/architecture/foundation.md), [profile and governance](references/profile-governance.md) |
32
- | greenfield, brownfield, review, migration workflows | [adaptive workflows](references/workflows.md) |
33
- | review output format and evidence recipes | [advisory report](references/advisory-report.md) |
34
- | topology, deployables, packages, contracts | [topology and monorepo](references/architecture/topology-monorepo.md) |
35
- | web/Next/OpenAPI/cache | [web](references/architecture/web.md) |
36
- | Flutter/mobile | [Flutter](references/architecture/flutter.md) |
37
- | identity, organizations, tenancy, RLS | [identity and tenancy](references/architecture/identity-tenancy.md) |
38
- | agent product and durable execution/jobs | [agent product](references/architecture/agent-product.md), [durable execution](references/architecture/durable-execution.md) |
39
- | connectors, MCP, webhooks, sandbox, egress | [connectors and sandbox](references/architecture/connectors-sandbox.md) |
40
- | data, knowledge, memory, objects | [data and memory](references/architecture/data-memory.md) |
41
- | PII, prompt injection, output moderation | [AI data boundaries](references/architecture/ai-data-boundaries.md) |
42
- | evals, prompt/model regression gates | [AI evals](references/architecture/ai-evals.md) |
43
- | model pinning, deprecations, canary, backpressure | [model lifecycle](references/architecture/model-lifecycle.md) |
44
- | model spend, budgets, cost attribution | [AI cost](references/architecture/ai-cost.md) |
45
- | realtime, notifications, channels | [realtime and channels](references/architecture/realtime-channels.md) |
46
- | models, BYOK, telemetry, audit | [models and observability](references/architecture/models-observability.md) |
47
- | security, privacy, secrets, threat model | [security and privacy](references/architecture/security-privacy.md) |
48
- | hosting, Cloudflare/OpenNext, SLO/recovery | [hosting and reliability](references/architecture/hosting-reliability.md) |
49
- | delivery, migration, verification | [delivery and operations](references/architecture/delivery-operations.md) |
50
- | fragile boundary implementation | [golden patterns](references/golden-patterns.md) |
51
-
52
- For current detail beyond a pinned claim, [refresh/sources.json](refresh/sources.json) is also the research index: fetch the affected source's `llms` or `docsIndex` URL (or use an available docs MCP). For design reviews and recommendations that lean on a **critical** source (`critical: true`), check freshness — `node <skill-dir>/scripts/refresh-evidence.mjs --topics <affected-topics>` when online, or report the claim as not verified when offline past its `thresholdDays`. Plain questions answer from the shipped snapshot with a one-line staleness caveat. Consult [foundation compatibility](references/foundation-compatibility.json) for version baselines.
53
-
54
- ## Execute the task-specific workflow
55
-
56
- - **Greenfield:** Follow the adaptive intake in [workflows](references/workflows.md): interview (tier first), recommend one capability set and topology sized by minimum viable architecture, name immediate/deferred decisions and triggers, and offer a slim profile draft after confirmation.
57
- - **Brownfield/review:** Inspect instructions, manifests/locks, deployables, schemas/migrations, auth, APIs, jobs, infra, ADRs, and runbooks before interviewing. Produce an advisory report; prefer controlled migration over rewrites.
58
- - **ADR/design/threat/deploy:** Use the relevant asset only after write authorization; an ADR is a decision record, never a waiver.
59
- - **Continuous work:** Load only affected references. Do not force absent capabilities or higher-tier concerns into scope.
60
- - **Source drift:** Follow [refresh/REFRESH.md](refresh/REFRESH.md). Refresh only affected topics.
61
-
62
- ## Profiles and mutation safety
63
-
64
- The committed profile lives at `.vegastack/architecture.json` (schema v4, ~12 lines; legacy names are discovered with a deprecation notice). Inspect or draft without mutation:
65
-
66
- ```sh
67
- node <skill-dir>/scripts/profile-tool.mjs inspect .
68
- node <skill-dir>/scripts/profile-tool.mjs scaffold answers.json --dir .
69
- node <skill-dir>/scripts/profile-tool.mjs migrate .vegastack/architecture.json --dir . # v3 -> v4 draft
70
- ```
71
-
72
- `inspect` prints a compact summary; `--json` for the full draft. The answers format is documented by example in `<skill-dir>/assets/answers-example.json`. Write only after explicit authorization; writes are atomic, refuse symlinks, stay inside `--dir`, and require `--force` to replace differing content (`--write` to apply). Validate with:
73
-
74
- ```sh
75
- node <skill-dir>/scripts/validate-profile.mjs .vegastack/architecture.json
76
- ```
77
-
78
- ## Guardrails
79
-
80
- - Tiers gate concerns, never tools. Never require a tool when only the invariant matters: the mechanism (platform secret store vs OpenBao, cron vs pg-boss, in-process loop vs EVE at prototype) is chosen by named triggers and recorded per project.
81
- - Never require SQL/RLS, Better Auth, Flutter, EVE, pg-boss, sandbox, connectors, enterprise identity, realtime, notifications, or knowledge when their activation condition is absent — and never surface enterprise-tier concerns as defects to a prototype/production project; report them as that tier's gate.
82
- - Challenge proposals and defaults when evidence warrants. Choose the smallest architecture meeting current requirements and measured objectives.
83
- - Never mutate a repository for an explanation or read-only review. Draft first and ask before writing.
84
- - Never create paid/cloud resources or claim live recovery, isolation, failover, credential-backed, or provider tests ran unless they actually ran.
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "VegaStack Architecture Guardian"
3
- short_description: "Tier-aware architecture advisor for VegaStack projects"
4
- default_prompt: "Use $arch-guardian to make one scoped architecture recommendation for this project at its declared tier, without assuming absent capabilities or requiring tools whose triggers are unmet."
@@ -1,25 +0,0 @@
1
- # ADR-NNN: Decision title
2
-
3
- An ADR is an optional decision record for consequential architecture choices — including deliberate departures from a guardian recommendation. Nothing gates on it; it exists so future readers know the decision was deliberate, who owns it, and when to revisit it.
4
-
5
- - Status: proposed | accepted | superseded | rejected
6
- - Date: YYYY-MM-DD
7
- - Owner: accountable person
8
- - Related-Principles: canonical rule IDs this decision touches, or `none`
9
- - Revisit: YYYY-MM-DD or a concrete event, or `none`
10
-
11
- ## Context and facts
12
-
13
- Separate observed facts, constraints, assumptions, preferences and prior accepted decisions. Identify current, target and migration states.
14
-
15
- ## Decision and rationale
16
-
17
- State the primary decision, ownership, boundaries and why it fits. State the rejected alternative and the reason — including, for any new moving service, the trigger that justifies it.
18
-
19
- ## Risks
20
-
21
- Describe each accepted risk, who accepts it, and what is affected. If this departs from a guardian recommendation, say so plainly; the guardian will keep reporting it as accepted risk in reviews.
22
-
23
- ## Verification and rollback
24
-
25
- What evidence supports the decision (label unverified claims honestly), how it would be rolled back or migrated away from, and any irreversible steps.
@@ -1,10 +0,0 @@
1
- {
2
- "project": { "name": "example-product", "kind": "saas", "tier": "production", "tenancy": "multi-tenant-shared-schema" },
3
- "hosting": "cloudflare-opennext",
4
- "capabilities": ["web", "jobs"],
5
- "notes": [
6
- "Better Auth is the identity library",
7
- "PostgreSQL is the system of record; RLS forced on tenant tables",
8
- "Secrets live in the platform's managed secret store (trigger review before enterprise tier)"
9
- ]
10
- }
@@ -1,13 +0,0 @@
1
- {
2
- "schemaVersion": 4,
3
- "foundationVersion": "0.4.0",
4
- "project": {
5
- "name": "REQUIRED-CONFIRMED-PROJECT-NAME",
6
- "kind": "REQUIRED-CONFIRMED-KIND",
7
- "tier": "REQUIRED-CONFIRMED-TIER",
8
- "tenancy": "REQUIRED-CONFIRMED-TENANCY"
9
- },
10
- "hosting": "REQUIRED-CONFIRMED-HOSTING",
11
- "capabilities": [],
12
- "notes": []
13
- }
@@ -1,31 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://raw.githubusercontent.com/vegastack/vegastack-skills/main/skills/arch-guardian/assets/architecture-profile.schema.json",
4
- "title": "VegaStack Architecture Profile v4",
5
- "description": "Slim advisor memory: confirmed project facts, the declared tier, and the enabled capability list. Versions are read from lockfiles and manifests at advice time, never duplicated here.",
6
- "type": "object",
7
- "additionalProperties": false,
8
- "required": ["schemaVersion", "project", "hosting", "capabilities"],
9
- "properties": {
10
- "schemaVersion": { "const": 4 },
11
- "foundationVersion": { "type": "string", "minLength": 1 },
12
- "project": {
13
- "type": "object",
14
- "additionalProperties": false,
15
- "required": ["name", "kind", "tier", "tenancy"],
16
- "properties": {
17
- "name": { "type": "string", "minLength": 1 },
18
- "kind": { "enum": ["saas", "internal-tool", "client-site", "api", "package"] },
19
- "tier": { "enum": ["prototype", "production", "enterprise"] },
20
- "tenancy": { "enum": ["none", "single-tenant", "multi-tenant-shared-schema", "multi-tenant-isolated"] }
21
- }
22
- },
23
- "hosting": { "enum": ["self-hosted", "vercel", "cloudflare-opennext", "external", "none"] },
24
- "capabilities": {
25
- "type": "array",
26
- "uniqueItems": true,
27
- "items": { "enum": ["web", "flutter", "agents", "jobs", "sandbox", "connectors", "knowledge", "models", "realtime", "notifications", "enterprise-identity"] }
28
- },
29
- "notes": { "type": "array", "items": { "type": "string", "minLength": 1 } }
30
- }
31
- }
@@ -1,24 +0,0 @@
1
- # Deployment review: release/profile
2
-
3
- Delete checklist items for absent capabilities; absence is not a failed control.
4
-
5
- ## Artifact identity
6
-
7
- - Commit:
8
- - OCI/image/package digests:
9
- - SBOM/provenance/signatures:
10
- - Database migration:
11
- - Architecture profile digest:
12
-
13
- ## Placement
14
-
15
- Verify each enabled owned deployable and each shared/external contract against the selected profile. For Cloudflare/OpenNext, verify owned EVE/jobs stay in external long-running Node/OCI placement.
16
-
17
- ## Safety gates
18
-
19
- - [ ] Backward-compatible API/events and expand/contract migration
20
- - [ ] Applicable runtime/protocol families are exact and atomically qualified
21
- - [ ] Applicable tenancy/authz paths are cache-safe and negatively tested
22
- - [ ] Applicable sandbox/connector/secret boundaries are qualified
23
- - [ ] Applicable backup/restore evidence is within confirmed RPO/RTO
24
- - [ ] Rollout, health, rollback, and incident ownership are explicit
@@ -1,33 +0,0 @@
1
- # Service design: name
2
-
3
- Keep only sections and fields activated by the service. Mark unknown material facts `NOT VERIFIED`; do not fill owners, data classes or objectives with placeholders presented as compliance.
4
-
5
- ## Ownership and purpose
6
-
7
- - Owner:
8
- - Runtime:
9
- - Hosting profiles:
10
- - Data classes:
11
- - SLO/RPO/RTO:
12
-
13
- ## Contracts
14
-
15
- List only applicable REST/OpenAPI, events, queue jobs, EVE hooks/streams, shared-service contracts and generated clients. Identify idempotency and compatibility rules.
16
-
17
- ## Tenancy and identity
18
-
19
- For shared-schema multi-tenancy, describe workspace derivation, composite keys, every tenant table's `ENABLE/FORCE RLS`, symmetric `USING/WITH CHECK`, transaction-local context, owner/BYPASSRLS separation and pool-reuse evidence. Otherwise state the actual access/tenancy boundary without adding RLS.
20
-
21
- For identity-facing services, record secure-cookie/session-cache policy, sensitive database validation, OAuth issuer/audience/code+PKCE/redirect allowlist/refresh rotation/revocation, SCIM organization mapping/deprovision/last-owner behavior, API-key scope, and internal short-lived identity.
22
-
23
- ## State and failure recovery
24
-
25
- Distinguish only state classes the service owns or consumes. Provide applicable retry, dedupe, DLQ, replay, recovery and reconciliation behavior.
26
-
27
- ## Security and observability
28
-
29
- Define secret references/broker lifetime, credential-bearing env/mount prohibitions, egress hosts/CIDRs/ports/DNS/redirect/header policy, logging-sink credential review, redaction, audit events, OTel signals, alerts, and abuse limits.
30
-
31
- ## Verification
32
-
33
- List tests only for enabled boundaries. Mark environment-bound qualification as NOT RUN with reason, risk, owner and next action.
@@ -1,34 +0,0 @@
1
- # Threat model: system or change
2
-
3
- Keep only enabled/exposed actors, assets and boundaries. Do not add agent, connector, sandbox, tenant or enterprise-identity threats to a project that lacks those surfaces.
4
-
5
- ## Scope and assets
6
-
7
- List trust zones, tenant data, credentials, durable state, and excluded systems.
8
-
9
- ## Actors and entry points
10
-
11
- List users, support operators, services, agents, connectors, webhooks, MCP servers, sandboxes, and supply-chain inputs.
12
-
13
- ## Data flows and boundaries
14
-
15
- Reference the system-context, identity, sandbox, and evidence diagrams.
16
-
17
- Record OAuth/session/SCIM trust transitions, database role and pool boundaries, support elevation, secret-broker exchange, sandbox env/mount/stdout/stderr paths, and every network redirect/DNS/header hop.
18
-
19
- ## Threats and controls
20
-
21
- | ID | Threat | Boundary | Impact | Prevent | Detect | Recover | Owner | Test |
22
- |---|---|---|---|---|---|---|---|---|
23
- | T-001 | Cross-tenant object reference | REST/RLS | Restricted data disclosure | Composite keys + authz + RLS | Audit anomaly | Revoke/export/notify | Security | Negative tenant test |
24
-
25
- ## Residual risk and review triggers
26
-
27
- Record accepted risks in linked ADRs and define review events.
28
-
29
- ## Required adversarial evidence
30
-
31
- - Cross-tenant object/join/bulk/export/background access and pool-role reuse
32
- - OAuth state/PKCE/replay/redirect, session revocation, SCIM deprovision/last-owner, and support expiry
33
- - Credential injection/logging, webhook replay, SSRF redirect/DNS rebinding/IPv6/link-local, and sandbox proxy/header exfiltration
34
- - Workflow lost acknowledgement, replayed effects, cancellation race, duplicate admission, and projector cursor rollback
@@ -1,65 +0,0 @@
1
- # Advisory report contract
2
-
3
- The advisory report is the guardian's review output. It is produced by the agent (not a checker script), is consumable by humans and by automation (a ship skill may parse the JSON block), and carries no gating semantics: findings inform decisions, the team decides.
4
-
5
- ## Severities
6
-
7
- | Severity | Meaning |
8
- |---|---|
9
- | `critical` | security, correctness, or data-loss defect — fix now at any tier |
10
- | `production-gate` | must be addressed before or at production tier |
11
- | `enterprise-gate` | required only at enterprise tier |
12
- | `consider` | improvement; explicitly optional |
13
-
14
- A finding's severity comes from the violated rule's tier floor relative to the project's declared tier: a rule at or below the current tier that is violated is `critical` when it is a security/correctness invariant, otherwise it reports at its own tier gate. Rules above the current tier report as that tier's gate, never as failures.
15
-
16
- ## Evidence discipline
17
-
18
- These rules are hard requirements; they exist to make false positives structurally difficult.
19
-
20
- 1. Every finding cites concrete evidence: `file:line`, a config key, a schema statement, or a fetched source URL. A claim without evidence is a **question**, listed separately — never a finding.
21
- 2. Every finding names the principle or rule ID it derives from, so "why does this apply to me" is always answerable from the report.
22
- 3. Detection is never a claim of absence. "No RLS statements found in `db/`" is a question unless every schema/migration file was actually read.
23
- 4. Behavior that cannot be verified in context (runtime, provider, recovery) is listed under `notVerified` with a reason and a suggested verification — never asserted either way.
24
- 5. Repeated identical findings are capped with a count; a report is a decision aid, not a wall of noise.
25
- 6. Grades summarize, they do not gate: `sound` / `attention` / `at-risk` per reviewed area, plus a one-line overall assessment. There is no REJECT vocabulary; a deliberate, recorded team decision the guardian disagrees with is reported as `accepted risk — guardian recommends revisiting`, with the reason.
26
-
27
- ## Report shape
28
-
29
- Markdown for humans, ending with one fenced `json` block for automation:
30
-
31
- ```json
32
- {
33
- "schemaVersion": 1,
34
- "project": "name",
35
- "tier": "production",
36
- "overall": "one-line assessment",
37
- "grades": { "identity": "sound", "tenancy": "attention" },
38
- "findings": [
39
- {
40
- "severity": "production-gate",
41
- "principle": "TEN-002",
42
- "summary": "one-sentence defect statement",
43
- "evidence": ["db/001-tenant.sql:14"],
44
- "suggestedAction": "what to change"
45
- }
46
- ],
47
- "questions": ["things the review could not determine from evidence"],
48
- "notVerified": [{ "claim": "PITR restore works", "reason": "not executed", "verify": "run a restore drill" }]
49
- }
50
- ```
51
-
52
- ## Evidence recipes
53
-
54
- Deterministic searches worth running during a review (read the hits before citing them — a match is a lead, not a finding):
55
-
56
- - **Tenant tables without RLS**: for each `CREATE TABLE` with a `workspace_id` column, confirm matching `ALTER TABLE … ENABLE ROW LEVEL SECURITY` and `FORCE ROW LEVEL SECURITY` statements exist, and that policies do not reduce to `USING (true)`.
57
- - **Composite tenant keys**: tenant-owned unique/foreign keys should include `workspace_id`; a bare `id` uniqueness on a tenant table is a lead for TEN-001.
58
- - **Plaintext secrets**: search tracked files for private key blocks, `Authorization: Bearer` literals, and provider key prefixes; check `.env*` files are gitignored and `.env.local` stays local-only.
59
- - **Session-state tenancy**: `SET (?!LOCAL)` / `set_config(..., false)` in SQL near tenant context is a lead for TEN-003 (context must be transaction-local).
60
- - **Runtime placement**: EVE/`@workflow/*` or `pg-boss` imports inside a web bundle or OpenNext worker source root are leads for RUN-001/RUN-002.
61
- - **Cookie/CSRF posture**: auth configuration disabling secure cookies, CSRF, or origin checks is a lead for AUTH-003.
62
- - **Sandbox egress**: sandbox configuration without an explicit allowlist (deny-by-default) is a lead for SBX-003.
63
- - **Unpinned models**: `latest` or alias model identifiers in production routes are leads for MLIFE-001.
64
-
65
- Respect `.guardianignore` (path prefixes, one per line) when the project provides one, and say in the report which paths were excluded or skipped.
@@ -1,22 +0,0 @@
1
- # Agent product
2
-
3
- Apply this reference only when the `agents` capability is enabled or agent authoring/execution is observed.
4
-
5
- ## Authoring and publication
6
-
7
- - **AGENT-001 — Immutable publication.** Instructions, model policy, tools, skills, connections, channels, schedules, memory, knowledge, structured output, approvals, and evals MAY change in a draft. Publishing **MUST** compile a normalized immutable version.
8
- - **AGENT-002 — Version-pinned execution.** Every run and conversation **MUST** pin the published agent version, policy version, tool schemas, model policy, knowledge policy, and EVE/Workflow protocol family. Draft edits **MUST NOT** mutate in-flight work.
9
- - **AGENT-003 — Deterministic compiler.** Compilation **MUST** use canonical ordering, explicit defaults, a schema version, and source digest; identical inputs must produce byte-identical output. Compilation **MUST NOT** resolve plaintext secrets.
10
- - **AGENT-004 — Risk-based publication.** Publishing **MUST** gate schema compatibility, secret references, permissions, capability escalation, external tools, EVE compatibility, eval regressions, output schemas, approval coverage, egress, quota, and migration impact.
11
-
12
- | Draft concern | Published output | Required gate |
13
- |---|---|---|
14
- | instructions and model policy | normalized prompt and route | schema and data-class policy |
15
- | tools, skills, connections | typed capabilities and scopes | risk, secret reference, approval |
16
- | schedules and channels | admission triggers | tenant, dedupe, timezone, owner |
17
- | output contract | versioned JSON Schema | conformance evaluation |
18
- | memory and knowledge | provenance and retention policy | tenant and data-class validation |
19
-
20
- Use the lifecycle `draft → preview → publish → production → rollback`. There is no separate staging state. Risk-increasing changes require review; a low-risk text change MAY use policy-approved automation. Rollback activates an earlier immutable version and never rewrites history.
21
-
22
- Support private and workspace sharing plus versioned templates. Template copies retain provenance but become independent drafts. Public marketplace moderation, discovery, and billing remain out of scope.
@@ -1,24 +0,0 @@
1
- # AI cost
2
-
3
- Apply this reference only when metered AI resources exist — model calls, sandbox runtime, embedding or knowledge processing. Cost here is an architecture concern: unattributed spend is an ownership gap, and an unbounded token path is a reliability defect. Billing, pricing, and Stripe remain out of foundation scope.
4
-
5
- Minimum viable form by tier — prototype: none required. Production: attribution logging (`COST-001`) plus a hard spend cap or alert. Enterprise: full budgets, cache economics, and the regression gate.
6
-
7
- - **COST-001 — Workspace attribution.** Every model, embedding, sandbox, and knowledge-processing call **MUST** record per-workspace attribution: tokens in/out, cached versus uncached, provider and model pin, feature or agent identity, and run correlation. Aggregate provider invoices are not attribution; the platform must be able to state what any workspace cost yesterday.
8
- - **COST-002 — Budgets and alerts.** Production AI features **MUST** define token or spend budgets per workspace and per feature, with alert thresholds and an explicit overrun behavior — shed, degrade, or pause visibly. Silent unlimited spend and silent hard-stop are both forbidden; the overrun behavior is a declared product decision.
9
- - **COST-003 — Cache economics.** Prompt/context caching **SHOULD** be a measured decision: record hit rate and cost delta per route, and structure prompts so stable prefixes actually cache. Caching **MUST NOT** weaken region, retention, or tenant policy (`MODEL-003`); a cache that saves money by crossing a policy boundary fails.
10
- - **COST-004 — Cost regression gate.** AI feature deploys **MUST** compare cost per interaction (or per run) against the current baseline, like a performance budget. A regression beyond the declared threshold blocks promotion until explained — an intended trade recorded with the change, or a defect fixed. Model swaps, prompt growth, retry amplification, and cache misses are the usual suspects.
11
-
12
- ## Measuring
13
-
14
- | Quantity | Source | Gate use |
15
- |---|---|---|
16
- | tokens per run | adapter attribution record | regression baseline |
17
- | cached share | adapter cache metadata | cache economics |
18
- | cost per interaction | tokens × pinned model price class | `COST-004` threshold |
19
- | workspace spend rate | attribution rollup | budget alerts |
20
- | shed/deferred work | admission records | overrun behavior audit |
21
-
22
- Estimate with the provider's published price class for the exact pin; reconcile estimates against provider usage reports on a fixed cadence and alarm on divergence, which usually means unattributed traffic.
23
-
24
- Budgets, quotas, and shedding compose with `MLIFE-004`: the same admission edge that protects the provider protects the budget. Retry and fallback paths carry their own attribution so a degraded week is explainable. Cost telemetry is metadata and follows `OBS-002` — amounts and counters, never prompt content.
@@ -1,21 +0,0 @@
1
- # AI data boundaries
2
-
3
- Apply this reference when personal data, knowledge ingestion, external model calls, or public-facing AI output exists. It concretizes `SEC-003` and `DATA-003` at the AI trust boundary: personal data moving outward, untrusted content moving inward.
4
-
5
- `PII-004` (injection quarantine) applies at every tier untrusted content reaches a prompt; `PII-001`/`PII-002` bind from production tier; `PII-003` moderation depth scales from a basic unsafe-content pass at production to full policy classes at enterprise.
6
-
7
- - **PII-001 — Ingestion redaction.** PII detection and classification **MUST** run before content enters embedding, chunking, or knowledge storage; detected PII is redacted, tokenized, or explicitly admitted under the data class policy of the target store. Record the classifier version and decision as provenance so re-scanning after a classifier upgrade is possible. Embeddings of unredacted PII are copies of it and inherit deletion propagation (`DATA-004`).
8
- - **PII-002 — Prompt boundary.** Before a prompt crosses the trust boundary to an external model provider, PII **MUST** be minimized to what the feature needs and stripped or masked where policy requires; the route's retention and region policy (`MODEL-001`) governs what may cross at all. Memory writes and eval/telemetry sampling are prompt-boundary crossings too — the same redaction applies.
9
- - **PII-003 — Output moderation.** Public-facing products **MUST** pass model output through a moderation policy before delivery: unsafe-content classes, PII leakage from context or memory, and impersonation of the platform. Internal tools MAY relax categories by declared policy, never by omission. Moderation outcomes are audited metadata; blocked output fails visibly, not silently.
10
- - **PII-004 — Injection mitigations.** Prompt injection is mitigated by structure, not instructions. Tool results, retrieved chunks, and connector content **MUST** be quarantined as data — spotlighted/delimited with an explicit untrusted marking the prompt template preserves — and **MUST NOT** be able to elevate capabilities: high-impact tool calls (irreversible, external-effect, privileged, or capability-escalating) require the `CONN-001` capability envelope and an approval gate regardless of what any content said. Instructions found inside untrusted spans are never followed into tool selection.
11
-
12
- ## Boundary placement
13
-
14
- | Crossing | Control | Failure mode prevented |
15
- |---|---|---|
16
- | document → embedding/knowledge store | `PII-001` classify/redact | PII copies in vectors and chunks |
17
- | context → external model | `PII-002` minimize/mask | retention outside policy |
18
- | model → public user | `PII-003` moderation | unsafe or leaking output |
19
- | tool/retrieval → prompt | `PII-004` quarantine + spotlight | injected instruction execution |
20
-
21
- Detection is preventive, not perfect: pair classifiers with data-class defaults (unknown source means restricted), negative tests that plant markers and verify they never reach a provider or a public response, and deletion reconciliation that includes vector stores and cached prompts. Treat retrieved text as untrusted data everywhere, matching `data-memory.md`; an approval gate that a model can talk its way around is prompt-enforced security and fails `SEC-003`.
@@ -1,28 +0,0 @@
1
- # AI evaluation
2
-
3
- Apply this reference only when agents, prompts, or other model-backed behavior ship to users. A project with no model-backed behavior needs no eval infrastructure.
4
-
5
- An eval is a versioned golden dataset plus a scoring method plus an explicit pass threshold, run against a pinned model and prompt. A demo transcript, a vibe check, or an unpinned notebook run is not an eval and produces no evidence.
6
-
7
- Minimum viable form by tier — prototype: none required. Production: one golden dataset and threshold for the main model-backed behavior, run before promoting prompt/model changes. Enterprise: the full regime below, including online sampling policy.
8
-
9
- - **EVAL-001 — Eval definition.** Every evaluated behavior **MUST** define a golden dataset with provenance and tenant-safe sourcing, a deterministic scoring method or declared judge configuration, and numeric pass/regression thresholds recorded before the run, not chosen after it.
10
- - **EVAL-002 — Promotion gate.** Changes to agent instructions, prompts, model policy, routed model, tool schemas, or knowledge policy **MUST** pass offline regression evals against the golden datasets before publish or promote. A threshold regression blocks promotion; overriding it is a project-owner accepted risk, not a pass.
11
- - **EVAL-003 — Versioned datasets.** Eval datasets, scoring configuration, and thresholds **MUST** be versioned alongside the prompts and agent versions they gate, so any historical eval result can be reproduced from its exact inputs. Dataset edits that change pass rates are behavior changes and go through the same review as prompt changes.
12
- - **EVAL-004 — Online sampling.** Production eval sampling **MUST** respect workspace data policy, retention, and redaction before any live interaction enters a dataset or judge prompt. Sampled cases feed dataset growth through review, never automatically.
13
-
14
- ## Judge models
15
-
16
- Model-as-judge scoring is permitted with declared caveats: pin the judge model and prompt version, measure judge agreement against a human-labeled slice before trusting it, and re-baseline whenever the judge model changes. Judge scores are relative evidence — they compare candidates under one fixed judge; they do not certify absolute quality. Do not use the model under test as its own judge, and do not let judge drift silently move a threshold.
17
-
18
- ## Operating the gate
19
-
20
- | Change | Required eval evidence |
21
- |---|---|
22
- | prompt or instruction edit | offline regression pass on affected datasets |
23
- | model or route change | full regression pass plus cost/latency comparison |
24
- | tool schema change | tool-selection and output-conformance pass |
25
- | knowledge policy change | retrieval-grounded answer pass |
26
- | dataset edit | reviewed diff and re-baselined thresholds |
27
-
28
- Keep datasets small enough to run in CI and grow them from triaged production failures, not synthetic bulk. Record every gate run with dataset version, model, prompt version, scores, and outcome so `AGENT-004` publication gates can cite it. Offline pass plus bounded online sampling is the evidence pair; neither alone qualifies a behavior change for tenants.
@@ -1,39 +0,0 @@
1
- # Connectors and sandbox
2
-
3
- Apply connector rules only to enabled/observed connectors, MCP or webhooks. Apply sandbox rules only to enabled/observed untrusted execution. Ordinary trusted application code does not activate a sandbox requirement.
4
-
5
- ## Connector boundary
6
-
7
- - **CONN-001 — Capability-bound tools.** Every tool call **MUST** carry an expiring capability bound to audience, resource, action, workspace, data class, risk class, and approval requirement. Subagents receive attenuated capabilities and no ambient credentials.
8
- - **CONN-002 — Connector credentials.** Access and refresh tokens **MUST** remain encrypted references outside agents and sandboxes. Refresh **MUST** be single-flight and revoke on disable, deprovision, or policy loss.
9
- - **CONN-003 — Trusted outbound fetch.** Connector and MCP HTTP **MUST** revalidate every redirect, couple DNS validation to the actual connection, reject private/loopback/link-local/metadata/multicast targets, strip cross-origin credentials, and bound method, port, path, body, response, and time.
10
- - **CONN-004 — MCP token separation.** MCP access tokens **MUST** be resource/audience-bound and validated on every request; because MCP `2026-07-28` accepts or rejects each request independently, validation **MUST NOT** rely on session or handshake state. An inbound token **MUST NOT** be forwarded to an upstream API; use a separate downstream credential and per-client consent. [MCP-SPEC]
11
- - **CONN-005 — Webhook admission.** Webhook ingress **MUST** verify a signature over the raw bounded body, enforce timestamp/replay windows and event dedupe, derive the workspace from server-owned mappings, and durably admit before acknowledgement.
12
-
13
- Classify tools as read-only, reversible write, irreversible/external effect, privileged administrative, or untrusted execution. Default-deny unknown tools. High-risk or capability-escalating calls require an EVE approval gate with reason, expiry, actor, decision, and immutable audit.
14
-
15
- Target MCP spec revision `2026-07-28`: each request declares its protocol version via `io.modelcontextprotocol/protocolVersion` in `_meta` (mirrored in the `MCP-Protocol-Version` header on Streamable HTTP), servers implement the mandatory `server/discover` RPC advertising supported versions, capabilities, and identity, and unsupported versions fail with `UnsupportedProtocolVersionError` for a retry at a mutually supported revision. <!-- source: MCP-SPEC --> Track the spec's deprecated-features registry; deprecated features carry a minimum twelve-month removal window (ninety days expedited), so plan migrations from it rather than from breakage. <!-- source: MCP-SPEC --> [MCP-SPEC]
16
-
17
- ## Sandbox boundary
18
-
19
- - **SBX-001 — Untrusted execution.** Production untrusted code **MUST** use a provider sandbox uniquely bound to workspace, run, and trust class. Local execution is trusted-development only.
20
- - **SBX-002 — Credential-free sandbox.** A sandbox **MUST NOT** receive database, secret-store, model-provider, connector-refresh, or ambient object-store credentials. Trusted broker code MAY inject an upstream credential only after validating a short-lived capability and must never return it. [tier: all]
21
- - **SBX-003 — Default-deny egress.** Egress **MUST** default deny. Trusted policy **MUST** constrain destination, method, path, headers, redirects, body, and response; discard sandbox-provided `Authorization`, cookies, and `Host` before reconstructing the request. [tier: all]
22
- - **SBX-004 — Disposable execution.** Enforce CPU, memory, disk, process, network, output, and time quotas plus cleanup and sweeper reconciliation. Correctness and durable state **MUST NOT** depend on sandbox process or filesystem survival.
23
- - **SBX-005 — Provider contract.** A provider **MUST** declare isolation, lifecycle, quotas, network controls, file transfer, streaming, cleanup, region/jurisdiction, and capability stability; conformance tests determine support.
24
-
25
- ```mermaid
26
- flowchart LR
27
- Eve["EVE with scoped capability"] --> Broker["Trusted broker"]
28
- Broker --> Policy["Tenant, action, destination policy"]
29
- Policy --> Sandbox["Disposable sandbox"]
30
- Sandbox --> Request["Credential-free request intent"]
31
- Request --> Broker
32
- Broker --> Upstream["Allowlisted upstream with injected credential"]
33
- Sandbox -. blocked .-> Private["Private, metadata, or arbitrary network"]
34
- Sandbox -. no access .-> Secrets["Database, OpenBao, provider keys"]
35
- ```
36
-
37
- Cloudflare Sandbox is preferred and Modal is the main alternative behind `SandboxProvider`. Cloudflare outbound Internet is open unless explicitly restricted: set `allowedHosts`, which becomes a deny-by-default allowlist once configured, plus `deniedHosts` for explicit blocks; route credentialed egress through outbound handlers, changeable at runtime via `setOutboundHandler()`; per-instance TLS interception (an ephemeral CA per sandbox, available since `@cloudflare/sandbox` 0.8.9) extends handler policy to HTTPS. <!-- source: CF-SANDBOX --> The API accepts glob patterns; SBX-003 still requires deny-by-default egress without wildcards, so allowlists pin exact hosts. Modal also requires explicit network restriction. [CF-SANDBOX] [MODAL-SANDBOX]
38
-
39
- Test IPv4/IPv6, DNS rebinding, redirect hops, header stripping, token expiry/replay, cross-tenant sandbox IDs, credential-bearing errors/responses, quota, timeout, cancellation, crash, and cleanup.
@@ -1,25 +0,0 @@
1
- # Data and memory
2
-
3
- Apply each rule only to its enabled/observed data capability. A stateless/shared-package project need not add PostgreSQL, knowledge, memory, object storage or Valkey.
4
-
5
- - **DATA-001 — System of record.** PostgreSQL **MUST** be the authoritative business store. Valkey MAY accelerate measured hot paths but correctness **MUST NOT** depend on it. [POSTGRES-DOCS]
6
- - **DATA-002 — Knowledge storage.** Default knowledge retrieval **MUST** use tenant-scoped PostgreSQL FTS plus pgvector; binary objects use an S3-compatible abstraction with checksums and version IDs. [PGVECTOR] [S3-SPEC]
7
- - **DATA-003 — Separate state classes.** EVE conversation state, curated durable memory, and provenance-bearing knowledge **MUST** remain distinct. Model-generated memory is a proposal that passes policy, dedupe, classification, provenance, and retention before persistence.
8
- - **DATA-004 — Lifecycle policy.** Every data class **MUST** define purpose, location, retention, export, deletion propagation, backup expiry, legal-hold behavior, and owner. Deletion **MUST** be tracked and reconciled across PostgreSQL, objects, indexes/vectors, caches, telemetry, and downstream connectors.
9
- - **DATA-005 — Object boundary.** Object upload/download **MUST** use short-lived scoped access, size/type validation, encryption, and applicable malware scanning. Production buckets and long-lived object credentials **MUST NOT** be mounted into a sandbox.
10
-
11
- | Data | Authoritative owner | Required metadata |
12
- |---|---|---|
13
- | business and tenant records | PostgreSQL | workspace, policy version, audit correlation |
14
- | agent execution | EVE/Postgres World | session, step/event cursor, published version |
15
- | curated memory | application PostgreSQL | provenance, classifier, retention, supersession |
16
- | knowledge chunks | PostgreSQL/pgvector | source, extraction and embedding versions, access policy |
17
- | binary objects | S3-compatible store | workspace, checksum, version, data class, retention |
18
-
19
- Authorize before retrieval and before producing snippets. Enforce workspace/data policy in SQL/RLS, include provenance and source timestamps, version extraction/chunking/embedding, and treat retrieved text as untrusted data rather than instructions.
20
-
21
- Residency claims require enforceable jurisdiction restrictions and tested placement; provider hints alone are insufficient. Legal hold suspends ordinary deletion only for the scoped records and must remain auditable.
22
-
23
- Add Valkey only after a measured cache or coordination benefit exists and the PostgreSQL-backed correctness path passes without it.
24
-
25
- The pinned baseline is the PostgreSQL 17.x series; PostgreSQL 18 (GA, 18.4 current minor) is the candidate upgrade horizon and adopting it requires re-qualifying RLS, pg-boss, and Workflow World behavior for the exact tuple. <!-- source: POSTGRES-DOCS -->
@@ -1,34 +0,0 @@
1
- # Delivery and operations
2
-
3
- Apply test and release boundaries only to enabled capabilities and declared deployables. Never report an absent capability as an untested control.
4
-
5
- - **DEL-001 — Boundary verification.** Tests **MUST** cover every applicable enabled boundary—contracts/code generation, RLS/tenant negatives, EVE replay/evals, pg-boss crash/retry, sandbox egress/secrets, web/mobile E2E, performance, restore, and dependency failure. Static sentinels never substitute for runtime qualification.
6
- - **DEL-002 — Compatible migrations.** Migrations **MUST** use expand, migrate, and contract: add backward-compatible schema, deploy compatible code, backfill idempotently with progress, verify, switch reads/writes, and remove only after the rollback window.
7
- - **DEL-003 — Migration safety.** Destructive migrations **MUST NOT** run as unreviewed application startup side effects. Estimate locks/rewrites, bound batches, verify backup/restore, expose progress, and define rollback or forward-fix.
8
- - **DEL-004 — Release identity.** Release artifacts **MUST** record source/lock/toolchain digests, exact dependencies, generated outputs, tests and skips, package/container digests, SBOM, provenance, signatures, migrations, profile/ADR identity, target, and rollback artifact. [tier: enterprise]
9
- - **DEL-005 — Relevant freshness.** For design reviews and recommendations leaning on pinned claims, stale or unavailable critical security, auth, tenancy, durability, secrets, and deployment evidence **MUST** be reported as not verified rather than asserted; plain questions answer from the shipped snapshot with a staleness caveat, and unrelated work stays on the fast path.
10
- - **DEL-006 — Honest verification.** Environment-bound replay, isolation, failover, restore, and provider tests **MUST** be reported as `NOT RUN` when not executed, with reason, risk, owner, and next action.
11
-
12
- ## Required test boundaries
13
-
14
- | Boundary | Minimum evidence |
15
- |---|---|
16
- | API/schema | Zod → OpenAPI → clients deterministic and compatible |
17
- | identity/tenancy | session/revocation, OAuth/PKCE, SCIM, composite keys, per-table RLS negatives |
18
- | execution | exact tuple, publication pin, approval, replay, waits, effects, cancellation |
19
- | admission/jobs | atomic enqueue, dedupe, retry/heartbeat, DLQ, ordinary job separation |
20
- | connectors/sandbox | SSRF/replay, capability scope, no credentials, egress, quota, cleanup |
21
- | clients/channels | reconnect, offline mutation, push/deep links, localization, accessibility |
22
- | operations | load, process/dependency/cell loss, PITR/restore, migration rollback |
23
-
24
- CI fails on hard-rule violations, nondeterministic generated output, broken references/source IDs, stale critical evidence, unsupported placement, incompatible migrations/contracts, or security/durability regressions. Flaky critical tests are defects and must not be silently retried to green.
25
-
26
- ## Rollout and maintenance
27
-
28
- Roll out by profile, cell, or cohort with health gates; preserve protocol compatibility during mixed versions; drain long-running workers; and keep code/config rollback independent where schema permits.
29
-
30
- Bootstrap by creating the slim profile, declaring the tier and hosting, validating the profile, refreshing affected sources, checking generated contracts, and completing threat/deployment review at the tier's depth.
31
-
32
- Doctor verifies Node availability, profile structure, and installed-skill integrity. It does not prove database connectivity/extensions, source freshness, secret-store identity, generated-contract drift, or live object/sandbox/model behavior.
33
-
34
- Use the bundled ADR, threat-model, service-design, and deployment-review templates when relevant. Maintain incident documentation at the tier's depth and revisit recorded deviations on their declared triggers; setup scripts never create paid or cloud resources implicitly.
@@ -1,45 +0,0 @@
1
- # Durable execution
2
-
3
- Apply EVE/Workflow/AgentRun rules only when agents are enabled or observed. Apply pg-boss rules only when owned agent admission or ordinary jobs are enabled or observed. A non-agentic project does not require EVE, Workflow World, AgentRun or pg-boss.
4
-
5
- Minimum viable form by tier — prototype: agents MAY run as simple in-process loops with at-least-once effects and a named migration path to durable execution; ordinary background work MAY use plain cron/queue primitives. The `DUR-*` ownership and qualification rules bind from production tier, where crash recovery and replay become real requirements — the trigger for EVE/pg-boss is durable multi-step agent work that must survive restarts, not the presence of agents alone.
6
-
7
- ## Exclusive ownership
8
-
9
- - **DUR-001 — One workflow owner.** EVE with its compatible PostgreSQL Workflow World **MUST** exclusively own durable agent sessions, steps, waits, approvals, continuations, hooks, streams, and tool-loop state. Do not introduce a second workflow engine, tool loop, HITL store, or execution queue.
10
- - **DUR-002 — Exact production tuple.** Production **MUST** pin `eve@0.29.5` and `@workflow/world-postgres@5.0.0-beta.30`; the lock **MUST** resolve its compatible `@workflow/world@5.0.0-beta.23` and `@workflow/world-local@5.0.0-beta.32`. Upgrade the family atomically. Local Workflow Worlds/files are development-only and forbidden in production. [EVE-PINNED] [WORKFLOW-PG]
11
- - **DUR-003 — Admission owner.** pg-boss **MUST** own transactional application admission and ordinary background jobs only. It **MUST NOT** model EVE execution state or use flow features as a second agent workflow engine. [PGBOSS-1227]
12
- - **DUR-004 — Product record.** AgentRun **MUST** retain authoritative product/audit inputs and a cursor-versioned projection of EVE events. Projection is required behavior in a trusted long-running plane, not a required standalone deployable. It **MUST** declare its source, direction, reconciliation, and monotonic update rule; it is not replay truth.
13
- - **DUR-005 — Transaction boundary.** The control plane **MUST** create AgentRun and one pg-boss admission job in the same PostgreSQL transaction when possible. The job carries the deterministic admission key and AgentRun records pending/accepted audit state plus the unique EVE session reference. Use an outbox only when a transaction or database boundary prevents atomic enqueue.
14
- - **DUR-006 — External effects.** Every retried external effect **MUST** use an idempotency/effect fence and reconciliation. Job claiming or step replay is not proof of exactly-once external side effects.
15
- - **DUR-007 — Replay qualification.** Before the production tier, durable execution **MUST** reproduce crash behavior before/after checkpoints and effects, completed-step replay, interrupted-step idempotency, approval persistence, wait/resume, cancellation, cursors, mixed-version migration, and PostgreSQL recovery for the exact tuple.
16
- - **DUR-008 — Tenant-qualified World.** Before shared-database production, every tenant-bearing Workflow World record and service role **MUST** satisfy `TEN-001` through `TEN-004`. A tuple that cannot preserve that boundary **MUST** fail qualification; RLS weakening, owner roles, and `BYPASSRLS` are forbidden.
17
- - **DUR-009 — Workflow exit contract.** Owning the workflow engine does not exempt it from provider neutrality: production durable execution **MUST** maintain an exit/migration contract naming the engine-specific constructs in use (sessions, steps, waits, approvals, hooks, streams), an exportable schema for durable session and event state, a drain/quiesce procedure, and a documented migration path with rollback to a replacement engine or major version. The contract is reviewed with the same cadence as the pinned tuple; a lock without an exit plan is accepted risk, not neutrality.
18
-
19
- ```mermaid
20
- sequenceDiagram
21
- participant API as Control plane
22
- participant PG as PostgreSQL and pg-boss
23
- participant Eve as EVE worker
24
- participant World as Postgres Workflow World
25
- participant Tool as External effect
26
- API->>PG: AgentRun and admission job in one transaction
27
- PG->>Eve: dispatch workspace and admission key
28
- Eve->>World: create or find durable session
29
- Eve->>Tool: approved, fenced effect
30
- Tool-->>Eve: result
31
- Eve->>World: checkpoint and emit event
32
- World-->>PG: trusted projection handler advances AgentRun cursor
33
- ```
34
-
35
- ## Admission and recovery
36
-
37
- Use `(workspace_id, admission_key)` as the logical start key. After a lost acknowledgement, look up the same EVE session before retrying; a retry never creates another logical run. The trusted EVE-event projection handler, not the admission job, supplies terminal execution state; it MAY run inside an existing trusted long-running deployable.
38
-
39
- Use pg-boss groups/priority plus measured wait age for ordinary tenant fairness. Add a separate selector/lease table only when reproduced strict global quota or starvation requirements exceed pg-boss semantics; that extraction needs an ADR and must not model EVE execution.
40
-
41
- Configure bounded retries/backoff, heartbeats, dedupe, attempt history, DLQ/redrive, inspect/cancel operations, and graceful shutdown. Redrive reuses the same admission key and effect fence. LISTEN/NOTIFY MAY reduce latency, but polling remains the safety path. [PGBOSS-1227]
42
-
43
- Do not assume same-session FIFO unless reproduced for the exact tuple.
44
-
45
- Qualification evidence remains tuple-specific and environment-specific. The pinned `eve@0.29.5` tuple is beta; <!-- source: EVE-PINNED --> `@workflow/world-postgres` remains a `5.0.0-beta` line, and the workflow SDK reaching GA is a mandatory human re-review trigger for `DUR-002` and `DUR-009` — re-evaluate the pin, the migration path, and the exit contract at that point rather than upgrading silently. <!-- source: WORKFLOW-PG -->