Skip to content

AA07: AuthorDraft / AuthorPatch schemas, draftToSpec, applyAuthorPatch - #851

Merged
LinuxDevil merged 2 commits into
mainfrom
fb-aa07-draft-patch
Nov 2, 2026
Merged

LinuxDevil merged 2 commits into
mainfrom
fb-aa07-draft-patch

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What changed

New apps/agent-forge/server/author/draft/ module — the zod contract and pure spec builders the Author's propose tools (AA08/AA09) will sit on.

schema.ts

  • authorDraftSchema: derived from the SDK's agentSpecV2Schema minus version, evals, flow (DRAFT_OMITTED_KEYS), strict. description is required and capped at 500 chars (stricter than the spec); instructions is a plain string 1–50,000 chars (never { file }); name and model stay required exactly where the spec requires them. Never re-declared by hand, so the schema cannot drift from the SDK.
  • authorPatchSchema: every draft key optional (omitted = keep); the spec-optional keys also accept null (reset to default) — NULLABLE_PATCH_KEYS is computed from the spec schema's optional fields minus description. Strict.
  • FIELD_DESCRIPTIONS: one sentence per draftable field; a coverage test pins it to exactly the schema keys.

toSpec.ts

  • draftToSpec(draft): { version: 2, ...draft } plus a chat-trigger backstop, validated with agentSpecV2Schema.
  • applyAuthorPatch(base, patch): undefined → keep, null → delete key, any other value → replace (lists replace wholesale, [] clears); same chat-trigger backstop and validation.
  • draftInvalidFailure(toolName, issues): the DRAFT_INVALID tool failure (first 10 issues as path: message).
  • deriveAgentId(name, taken): name → slug (lowercase, non-[a-z0-9] runs → -, 48-char cap, agent fallback) with -2, -3… collision suffixes; every output passes isValidAgentId.
  • Issues carry tools[2].builtin-style paths ([n] for array indexes).
  • Chat-trigger rule: appended only when no type: 'chat' entry exists, with the first unused t<N> id.

No wiring yet — AA08 is the first caller (test usage satisfies fallow until then).

Test summary

  • server/author/draft/__tests__/schema.test.ts + toSpec.test.ts: 125 tests — required/omitted/unknown keys, null rules, full patch-semantics table, t1 taken → t2, guardrails[0].name issue path, deriveAgentId cases (empty, unicode, 60-char, collisions).
  • typecheck:server, typecheck, test:server (69 files / 944 tests), test (85 files / 942 tests) — all pass.
  • Root tsc --noEmit, lint, fallow (no issues), docs:ratchet, api:check, docs:llms:check, size-check — all pass.
  • test:coverage: 11 pre-existing/environmental failures unrelated to this change — 6× templates.test.ts README startsWith checks fail under a CRLF checkout (core.autocrlf=true), 5× create-lousho tests need the package's dist/ build (not produced in this worktree). All other 7,152 tests pass; coverage report generated via --coverage.reportOnFailure so fallow could consume it.

Acceptance criteria

  • authorDraftSchema rejects version, evals, flow and unknown keys; requires name, description, model, instructions.
  • applyAuthorPatch(base, { tools: [] }) clears tools; { reasoning: null } removes reasoning; {} returns base unchanged (plus chat trigger).
  • { description: null } fails patch validation.
  • deriveAgentId('Support Triage!', new Set(['support-triage'])) → support-triage-2; every output passes isValidAgentId.
  • Every top-level key of both schemas has a description.

Generated with Devin

LinuxDevil and others added 2 commits November 2, 2026 21:30
…plyAuthorPatch

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ng caller input

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil merged commit ae5a096 into main Nov 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant