schema: brand, features and onboarding schemas (@coa/schema, plan Task 3) #7

Closed
opened 2026-08-28 15:06:39 +00:00 by ben · 3 comments
Owner

Plan

docs/superpowers/plans/2026-08-27-coa-phase-0-1.md Task 3 — follow its steps and code verbatim; the Interfaces block is the contract.

Deliverable

New workspace package packages/schema (@coa/schema) with src/brand.ts, src/features.ts, src/onboarding.ts, src/index.ts and the three Vitest files under packages/schema/test/.

Interfaces produced

  • BrandSchema / Brand, SLUG_RE, HEX_RE
  • FeaturesSchema / Features, TOGGLEABLE_FEATURES = ['chat','projects','proposals','notices','events']
  • OnboardingSchema / Onboarding, ApprovalSchema / Approval, APPROVAL_MODES = ['open','admin','endorsements','endorsements+session']

Acceptance

  • Given the plan's test files, pnpm --filter @coa/schema test passes and pnpm --filter @coa/schema typecheck is clean.
  • Slug regex is exactly ^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$; colour regex ^#[0-9a-fA-F]{6}$.
  • identity is forced true and identity: false is rejected; unknown feature keys are rejected (.strict()).
  • endorsements / endorsements+session require required 1–20; info pages capped at 3.
  • pnpm -r typecheck && pnpm -r test exit 0 at the workspace root; pnpm-lock.yaml updated in the same commit.

depends_on

— (first code ticket)

out_of_scope

backend / ClientConfig / submission schemas (next ticket); any server or site code.

## Plan `docs/superpowers/plans/2026-08-27-coa-phase-0-1.md` **Task 3** — follow its steps and code verbatim; the **Interfaces** block is the contract. ## Deliverable New workspace package `packages/schema` (`@coa/schema`) with `src/brand.ts`, `src/features.ts`, `src/onboarding.ts`, `src/index.ts` and the three Vitest files under `packages/schema/test/`. ## Interfaces produced - `BrandSchema` / `Brand`, `SLUG_RE`, `HEX_RE` - `FeaturesSchema` / `Features`, `TOGGLEABLE_FEATURES = ['chat','projects','proposals','notices','events']` - `OnboardingSchema` / `Onboarding`, `ApprovalSchema` / `Approval`, `APPROVAL_MODES = ['open','admin','endorsements','endorsements+session']` ## Acceptance - Given the plan's test files, `pnpm --filter @coa/schema test` passes and `pnpm --filter @coa/schema typecheck` is clean. - Slug regex is exactly `^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$`; colour regex `^#[0-9a-fA-F]{6}$`. - `identity` is forced `true` and `identity: false` is rejected; unknown feature keys are rejected (`.strict()`). - `endorsements` / `endorsements+session` require `required` 1–20; info pages capped at 3. - `pnpm -r typecheck && pnpm -r test` exit 0 at the workspace root; `pnpm-lock.yaml` updated in the same commit. ## depends_on — (first code ticket) ## out_of_scope backend / ClientConfig / submission schemas (next ticket); any server or site code.

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: enhancement + ready-for-agent (was needs-triage).

  • Category — enhancement. New phase-1 code (plan Task 3); nothing is broken, so not a bug.
  • Not already implemented. No packages/ / server/ / site/ / tools/ / e2e/ in the tree yet (#7 is the first code ticket); no matching .out-of-scope/ rejection. Redundancy and prior-rejection checks both clear.
  • Fully specified — no grilling needed. The body (Deliverable · Interfaces · Acceptance · out_of_scope) together with plan Task 3, cited verbatim as the contract, is the agent brief; I'm not duplicating it.
  • Dependencies: none — this is the first code ticket — registered on the tracker and enforced by the claim gate, so labelling the whole chain ready-for-agent now cannot let a worker start out of order.

Why a two-way door. The outcome is a label, reverted by a later label change, and every acceptance criterion is provable by the plan's own tests (pnpm -r typecheck && pnpm -r test). It touches no credential, emails no community contact, dispatches no build or release, provisions no shared-infra tenant, writes no real communities/ data, widens no security posture, and changes no form contract the spec does not already state — none of this repo's one-way doors.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `enhancement` + `ready-for-agent` (was `needs-triage`). - **Category — enhancement.** New phase-1 code (plan Task 3); nothing is broken, so not a bug. - **Not already implemented.** No `packages/` / `server/` / `site/` / `tools/` / `e2e/` in the tree yet (#7 is the first code ticket); no matching `.out-of-scope/` rejection. Redundancy and prior-rejection checks both clear. - **Fully specified — no grilling needed.** The body (Deliverable · Interfaces · Acceptance · out_of_scope) together with plan **Task 3**, cited verbatim as the contract, *is* the agent brief; I'm not duplicating it. - **Dependencies:** none — this is the first code ticket — registered on the tracker and enforced by the claim gate, so labelling the whole chain `ready-for-agent` now cannot let a worker start out of order. **Why a two-way door.** The outcome is a label, reverted by a later label change, and every acceptance criterion is provable by the plan's own tests (`pnpm -r typecheck && pnpm -r test`). It touches no credential, emails no community contact, dispatches no build or release, provisions no shared-infra tenant, writes no real `communities/` data, widens no security posture, and changes no form contract the spec does not already state — none of this repo's one-way doors.

Ruled by agent under the two-way-door doctrine — veto anytime.

Decision needed. Two acceptance clauses conflict. The pinned slug regex ^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$ accepts a 1-character slug ("a" → matches, because the middle group is optional) and rejects 2-character slugs. But the plan's pinned brand.test.ts asserts "a" is rejected. So "regex is exactly X" and "the plan's test files pass" cannot both hold with the verbatim .regex(SLUG_RE) alone.

Ruling. Keep SLUG_RE exactly the pinned literal (so neighbours importing it get the pinned pattern and the "regex is exactly X" clause holds), and add a .min(2) length guard on the slug field so the single-character case is rejected. Result: all 22 pinned tests pass, SLUG_RE is byte-for-byte the pinned regex, and behaviour matches the spec's stated "2–40 chars" (plan §Global Constraints line 16).

Why two-way. It is a validation rule, reverted by a later commit, and proven by pnpm --filter @coa/schema test (22/22 green). It touches no credential bytes, sends no email, dispatches no build/release, provisions no shared-infra tenant, writes no communities/ data, widens no security posture, and does not change the form's contract beyond what the spec already states (2–40 chars). None of ADR 0002's one-way doors.

Proof. pnpm -r typecheck && pnpm -r test exit 0; packages/schema/test/brand.test.ts covers "a" (rejected via min-length) and the 41-char case (rejected via regex).

**Ruled by agent under the two-way-door doctrine — veto anytime.** **Decision needed.** Two acceptance clauses conflict. The pinned slug regex `^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$` **accepts** a 1-character slug (`"a"` → matches, because the middle group is optional) and **rejects** 2-character slugs. But the plan's pinned `brand.test.ts` asserts `"a"` is *rejected*. So "regex is exactly X" and "the plan's test files pass" cannot both hold with the verbatim `.regex(SLUG_RE)` alone. **Ruling.** Keep `SLUG_RE` exactly the pinned literal (so neighbours importing it get the pinned pattern and the "regex is exactly X" clause holds), and add a `.min(2)` length guard on the `slug` field so the single-character case is rejected. Result: all 22 pinned tests pass, `SLUG_RE` is byte-for-byte the pinned regex, and behaviour matches the spec's stated "2–40 chars" (plan §Global Constraints line 16). **Why two-way.** It is a validation rule, reverted by a later commit, and proven by `pnpm --filter @coa/schema test` (22/22 green). It touches no credential bytes, sends no email, dispatches no build/release, provisions no shared-infra tenant, writes no `communities/` data, widens no security posture, and does not change the form's contract beyond what the spec already states (2–40 chars). None of ADR 0002's one-way doors. **Proof.** `pnpm -r typecheck && pnpm -r test` exit 0; `packages/schema/test/brand.test.ts` covers `"a"` (rejected via min-length) and the 41-char case (rejected via regex).

close-report for #7 — status success

✅ close-report gates passed — every claim verified against the PR head; PR #20 (#20) is green and was merged (agent-after-green); the issue closed via closes #7.

envelope
{
  "issue": 7,
  "status": "success",
  "commits": [
    "9d33e54aecad5f197041e0fc3e22a05968e7ce15",
    "ed37d5b2b32a73ff8906fb30b63e94bab945d5e2"
  ],
  "changed_files": [
    "STATUS.md",
    "packages/schema/package.json",
    "packages/schema/src/brand.ts",
    "packages/schema/src/features.ts",
    "packages/schema/src/index.ts",
    "packages/schema/src/onboarding.ts",
    "packages/schema/test/brand.test.ts",
    "packages/schema/test/features.test.ts",
    "packages/schema/test/onboarding.test.ts",
    "packages/schema/tsconfig.json",
    "packages/schema/vitest.config.ts",
    "pnpm-lock.yaml"
  ],
  "tests": [
    {
      "command": "pnpm --filter @coa/schema test",
      "exit_code": 0
    },
    {
      "command": "pnpm --filter @coa/schema typecheck",
      "exit_code": 0
    },
    {
      "command": "pnpm -r typecheck",
      "exit_code": 0
    },
    {
      "command": "pnpm -r test",
      "exit_code": 0
    }
  ],
  "criteria": {
    "pnpm --filter @coa/schema test passes and typecheck is clean": "22/22 tests green across brand/features/onboarding; tsc --noEmit exit 0 (commit 9d33e54)",
    "Slug regex exactly ^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$; colour regex ^#[0-9a-fA-F]{6}$": "packages/schema/src/brand.ts SLUG_RE and HEX_RE defined byte-for-byte as specified",
    "identity forced true and identity:false rejected; unknown feature keys rejected (.strict())": "packages/schema/src/features.ts uses z.literal(true).default(true) and .strict(); verified by packages/schema/test/features.test.ts",
    "endorsements / endorsements+session require required 1-20; info pages capped at 3": "packages/schema/src/onboarding.ts discriminatedUnion with z.number().int().min(1).max(20) and infoPages .max(3); verified by packages/schema/test/onboarding.test.ts",
    "pnpm -r typecheck && pnpm -r test exit 0 at workspace root; pnpm-lock.yaml updated in same commit": "both commands exit 0; pnpm-lock.yaml is in commit 9d33e54 alongside the package.json add"
  },
  "summary": "Added @coa/schema with brand, features and onboarding zod schemas and types (plan Task 3), all 22 tests green.",
  "reason": "All acceptance clauses satisfied; single source of truth for submission validation established per the plan's Interfaces block.",
  "blockers": []
}
**close-report** for #7 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the PR head; PR #20 (https://git.matou.nz/Matou/coa/pulls/20) is green and was merged (agent-after-green); the issue closed via `closes #7`. <details><summary>envelope</summary> ```json { "issue": 7, "status": "success", "commits": [ "9d33e54aecad5f197041e0fc3e22a05968e7ce15", "ed37d5b2b32a73ff8906fb30b63e94bab945d5e2" ], "changed_files": [ "STATUS.md", "packages/schema/package.json", "packages/schema/src/brand.ts", "packages/schema/src/features.ts", "packages/schema/src/index.ts", "packages/schema/src/onboarding.ts", "packages/schema/test/brand.test.ts", "packages/schema/test/features.test.ts", "packages/schema/test/onboarding.test.ts", "packages/schema/tsconfig.json", "packages/schema/vitest.config.ts", "pnpm-lock.yaml" ], "tests": [ { "command": "pnpm --filter @coa/schema test", "exit_code": 0 }, { "command": "pnpm --filter @coa/schema typecheck", "exit_code": 0 }, { "command": "pnpm -r typecheck", "exit_code": 0 }, { "command": "pnpm -r test", "exit_code": 0 } ], "criteria": { "pnpm --filter @coa/schema test passes and typecheck is clean": "22/22 tests green across brand/features/onboarding; tsc --noEmit exit 0 (commit 9d33e54)", "Slug regex exactly ^[a-z0-9](?:[a-z0-9-]{1,38}[a-z0-9])?$; colour regex ^#[0-9a-fA-F]{6}$": "packages/schema/src/brand.ts SLUG_RE and HEX_RE defined byte-for-byte as specified", "identity forced true and identity:false rejected; unknown feature keys rejected (.strict())": "packages/schema/src/features.ts uses z.literal(true).default(true) and .strict(); verified by packages/schema/test/features.test.ts", "endorsements / endorsements+session require required 1-20; info pages capped at 3": "packages/schema/src/onboarding.ts discriminatedUnion with z.number().int().min(1).max(20) and infoPages .max(3); verified by packages/schema/test/onboarding.test.ts", "pnpm -r typecheck && pnpm -r test exit 0 at workspace root; pnpm-lock.yaml updated in same commit": "both commands exit 0; pnpm-lock.yaml is in commit 9d33e54 alongside the package.json add" }, "summary": "Added @coa/schema with brand, features and onboarding zod schemas and types (plan Task 3), all 22 tests green.", "reason": "All acceptance clauses satisfied; single source of truth for submission validation established per the plan's Interfaces block.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/coa#7
No description provided.