Casey Knott
Menu

Project 07 · Secure platforms

Basaltborne

Know your gear. Run what works. — AI-assisted publishing with RLS and CI as controls.

AI-assisted platform engineering · DevelopingIndependent production-track platformDeveloping

Developing — phase-gated software lifecycle with a multi-layer CI suite

Mission

Build a public publishing platform where drafts cannot become public because a UI flag flipped, and where AI-authored changes cannot reach main without tests and review.

Problem

AI coding agents can produce a lot of surface area quickly. Without phase gates, RLS, and an independent CI suite, that speed becomes a way to ship unauthorized data and unreviewed behavior.

Constraints

  • AI output is treated as untrusted until validated.
  • Advancing a phase requires acceptance criteria, passing tests, human review, source authorization, and explicit security boundaries.
  • Privileged service-role credentials are never shipped to the browser.
  • The browser is untrusted by default.

My role

I direct AI coding agents through a phase-gated lifecycle: they can research, propose architecture, implement, write tests, document, and troubleshoot — they cannot advance a phase or publish on their own.

Architecture

Next.js / React / TypeScript public and admin surfaces; PostgreSQL / Supabase with Row-Level Security; versioned migrations; API/RPC boundaries; Zod at trust boundaries; GitHub Actions running Vitest, pgTAP, Playwright, lint/type gates, and migration replay.

Public user (browser)

Next.js public routes / UI

Service-role credentials stay server-only

API / RPC boundary

Server-only; validate every input

AI drafting agent

Validation agent

Human approval gate

Published content

Immutable, versioned

Private tables · RLS · service-role only

Public read API · RLS public-safe columns

CI/CD validation

ESLint, Vitest, pgTAP, Playwright, migrations, audit

Human-approved deploy

The browser is treated as untrusted by default; server-side RPCs, Row-Level Security, and a human approval gate stand between a draft and anything the public can read, with an independent CI/CD suite validating every change before deploy.
Public user (browser)
external
Next.js public routes / UI
application
API / RPC boundary
validation — Server-only; validate every input
Service-role credentials stay server-only
policy
AI drafting agent
agent
Validation agent
validation
Human approval gate
approval
Published content
data — Immutable, versioned
Private tables · RLS · service-role only
data
Public read API · RLS public-safe columns
data
CI/CD validation
validation — ESLint, Vitest, pgTAP, Playwright, migrations, audit
Human-approved deploy
approval

AI architecture

Agents
Drafting inside a non-public state; cannot publish
Validation
Separate validation path, then human approval
Lifecycle
Phase-gated: foundation, public experience, controlled published content

Security architecture

RLS
Database enforces who can read or write which rows
Private tables
Internal data never exposed as a general-purpose readable table
Fail closed
Invalid or unauthorized states do not fall back to insecure behavior
Information minimization
Publisher and approval identity do not leak through public APIs

Build process

  1. Phase 1: repository, database, authz, approval/audit concepts, admin scaffold, migrations, testing baseline.
  2. Phase 2: public site, navigation, responsive design, SEO, accessibility, methodology / affiliate / corrections pages as first-class content.
  3. Phase 3: draft versus approved/published content; immutable versioned publication; public-read boundaries; provenance; auditability.

Validation

  • Vitest — core Phase 3

    Unit tests for application logic

    97 / 97

  • pgTAP

    Database rules and RLS behavior tested inside Postgres

    120 / 120

  • Playwright

    End-to-end user-visible flows

    28 / 28, later 35 / 35 after Trail work

  • Vitest after Trail expansion

    Suite expansion after later Trail work

    109 tests

  • Merge gates

    ESLint, TypeScript compiler, migration replay, GitHub Actions as independent remote verification

    Main protected; AI-authored changes still require PR review against acceptance criteria

Challenges

AI agents will implement a publish flag in the UI if that is the shortest path. Publication has to be a server-enforced state transition.

Investigation

Each CI layer proves something different: unit tests for application logic, pgTAP for data-layer rules, Playwright for user-visible behavior, migration replay for reproducible deploys.

Resolution

Treat the pull request as the place where automated validation and human judgment both have to sign off. Rollback is planned before a migration or deploy ships.

Lessons

  • Publication is privileged

    Publication is treated as a privileged state transition enforced server-side — not a boolean flag flipped in the UI.

  • Branch protection is an approval control

    The pull request is where automated validation and human judgment both have to sign off before anything reaches main.

Cybersecurity equivalent

  • Row-Level Securitymaps toAuthorization enforced at the data layer
  • Server-only service rolemaps toCredential protection / no secret in the client
  • CI as independent checksmaps toPreventive and detective controls on change
  • Human-approved deploymaps toPrivileged change authorization

AI principles applied

  • Human-in-the-loop

    Consequential actions require a person. The loop is a state machine, not a polite request in a prompt.

    Where learned: Publishing, packaging, containment, and deploy all use explicit gates.

    See in the AI map

  • Trusted retrieval / source timing

    Normalize and timestamp sources before the model sees them. Forum consensus is not a specification.

    Where learned: TinyClaw freshness path; Jeep source-verification instruction.

    See in the AI map

  • Validation and evaluation

    Happy path is not enough. Missing, malformed, stale, contradictory, injected, and timed-out inputs are the real suite.

    Where learned: Triage functional plus adversarial layers; Clearward 49 automated checks; Basaltborne CI layers.

    See in the AI map

  • Authority boundaries

    Collection, analysis, and remediation are different privileges. Drafting and publishing are different privileges.

    Where learned: Triage and Basaltborne both make that separation structural.

    See in the AI map

  • AI-assisted development

    Agents draft under persistent instructions and phase gates. They do not merge, package, or deploy themselves.

    Where learned: Clearward AGENTS.md; Basaltborne phase-gated lifecycle with PR review of AI-authored changes.

    See in the AI map

Concepts exercised in this project

  • AI-assisted development
  • Agent supervision
  • Human-in-the-loop
  • Validation / evaluation

Security principles applied

  • IAM / authorization

    Who can do what is assigned outside the model and enforced at the boundary that matters.

    Where learned: Basaltborne RLS and RPCs; Clearward human-only credential boundary; triage least-privilege account.

    See in the security map

  • Secure SDLC

    Phase gates, PR review, protected main, and tests that run somewhere other than a laptop.

    Where learned: Basaltborne feature branches, acceptance-criteria commits, CI-protected main.

    See in the security map

  • Logging and accountability

    Decisions, tool calls, retries, and approvals have to be reconstructable.

    Where learned: Triage adversarial study scored whether attempts appeared in the audit log.

    See in the security map

  • Validation

    Schema, hashes, required fields, RLS tests, and visual review — not the generator marking its own homework.

    Where learned: Clearward formula/package QA; Basaltborne Zod + pgTAP; TinyClaw source checks.

    See in the security map

  • Change control

    Publication, packaging, and deploy are privileged transitions with a human on the gate.

    Where learned: Clearward release architecture; Basaltborne draft vs published; Self Help human review.

    See in the security map

  • Secrets management

    Credentials are a human-only boundary. Service roles stay server-side. Prompts are not a vault.

    Where learned: Clearward AGENTS.md; Basaltborne server-only privilege.

    See in the security map

  • Incident response / recovery

    Recommended actions include expected results, validation, operational risk, and rollback. Checkpoints revert test cycles.

    Where learned: Triage recommendations and Hyper-V checkpoints; Basaltborne planned undo for migrations.

    See in the security map

  • Application security

    Untrusted browser, validated RPCs, private tables, fail closed, information minimization.

    Where learned: Basaltborne database-security and public-API design.

    See in the security map

Controls exercised in this project

  • Row-Level Security
  • Authentication & authorization
  • Trust boundaries
  • Fail closed
  • Secrets management
  • Secure SDLC
  • Least privilege

Technologies

  • Next.js
  • React
  • TypeScript
  • PostgreSQL
  • Supabase
  • Zod
  • GitHub Actions
  • Playwright
  • Vitest
  • pgTAP
  • ESLint
  • Docker
  • PowerShell

Skills demonstrated

  • Systems Architecture
  • Next.js
  • TypeScript
  • React
  • PostgreSQL
  • Supabase
  • Row-Level Security
  • Database Migrations
  • Schema Validation (Zod)
  • CI/CD
  • Unit / Integration / E2E Testing
  • Database-Security Testing (pgTAP)