Skip to content

feat(service-ai): ADR-0033 Phase A — draft-gate AI metadata authoring#1529

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr-0033-phase-a-draft-gating
Jun 2, 2026
Merged

feat(service-ai): ADR-0033 Phase A — draft-gate AI metadata authoring#1529
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr-0033-phase-a-draft-gating

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

What & why

Implements Phase A of ADR-0033AI-assisted metadata authoring. The design center: the AI authors metadata; the human confirms and publishes.

Today every AI metadata tool persists via metadataService.register(...), which publishes straight to the live schema — no draft, no review, no human gate (the requiresConfirmation flag existed but was never enforced). This PR closes that hazard structurally.

What changed (all in packages/services/service-ai)

  • AI never publishes — it drafts. Every metadata mutation routes through one helper applyDraft() that calls protocol.saveMetaItem({ …, mode:'draft' }) — the same draft path Studio's designer already uses. Nothing goes live until a human publishes. The draft is the approval gate; the unenforced requiresConfirmation comments are retired.
  • Type-agnostic apply surface (§3). New tools create_metadata / update_metadata / describe_metadata / list_metadata work for any type (view, dashboard, flow, …), not just objects. update_metadata applies an RFC-7386 JSON merge patch to the single draft (read-modify-write, never forks).
  • Per-type validation + error feedback. Reuses saveMetaItem's built-in Zod validation (getMetadataTypeSchema, ADR-0005) — 422 invalid_metadata issues are returned to the agent as a fixable string error, never thrown.
  • Object/field tools become thin draft-writing wrappers; reads are draft-first so repeated field ops stack into one draft.
  • Result envelope: { status:'drafted', type, name, summary, changedKeys }. Skill + agent instructions updated to "propose drafts, never publish."

Verification

  • 446 service-ai tests pass (117 in the rewritten __tests__/metadata-tools.test.ts), DTS build clean, changed files tsc-clean.
  • New tests assert the invariant: saveMetaItem called with mode:'draft', register never called, validation errors fed back, drafts stack into one body, writes refuse safely when no protocol is wired.
  • Confirmed object/field (allowRuntimeCreate:true) draft through the repo path; editing a code-shipped object intentionally 403s and is surfaced to the agent.

Scope

Phase A only (framework / OSS). Out of scope, unblocked by this: B (objectui review/diff), C (blueprint + view/dashboard tools), D (EE governance).

🤖 Generated with Claude Code

Route every AI metadata write through the ADR-0027 draft workspace via
protocol.saveMetaItem({mode:'draft'}) instead of metadataService.register()
(which published straight to the live schema). The draft is the approval
gate; the never-enforced requiresConfirmation flag is retired.

- Add type-agnostic tools: create_metadata / update_metadata /
  describe_metadata / list_metadata (work for any metadata type), validated
  against each type's Zod schema with errors fed back to the agent.
- Reroute create_object / add_field / modify_field / delete_field through a
  shared draft-write core (applyDraft); reads are draft-first so repeated
  field ops stack into one draft.
- Result envelope: { status:'drafted', type, name, summary, changedKeys }.
- Update skill + agent instructions: propose drafts, never publish.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/xl labels Jun 2, 2026
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 2, 2026 9:02am

Request Review

@xuyushun441-sys xuyushun441-sys merged commit 984ddff into main Jun 2, 2026
12 checks passed
@xuyushun441-sys xuyushun441-sys deleted the feat/adr-0033-phase-a-draft-gating branch June 2, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/xl tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants