Skip to content

feat(config): add on_event.failed_run, serve JSON schema, and publish repo config reference#123

Merged
neekolas merged 13 commits intomainfrom
04-22-config_file_schema
Apr 22, 2026
Merged

feat(config): add on_event.failed_run, serve JSON schema, and publish repo config reference#123
neekolas merged 13 commits intomainfrom
04-22-config_file_schema

Conversation

@neekolas
Copy link
Copy Markdown
Contributor

@neekolas neekolas commented Apr 22, 2026

Summary

Extends .code-factory/config.toml with a new [[on_event.failed_run]] section, serves a machine-readable JSON Schema at GET /schema.json for editor integration, and publishes a human-readable reference at docs/repo-config.md. No consumer of on_event.failed_run is added in this PR — this is schema plumbing plus docs only.

What ships

Schema extensions (src/config/repo-config-schema.ts)

  • New StoredFailedRunEventSchema / StoredOnEventSchema on the sparse (write-side) shape. workflows and branches are required non-empty arrays; prompt_additions is optional.
  • New ResolvedOnEventSchema on the resolved (read-side) shape, wired with .prefault({}) + inner .default([]) so consumers always see on_event.failed_run: [] when the section is absent.
  • Secret-leak invariant preserved: error messages are still built from issue.path + issue.message only, never issue.input.

GET /schema.json endpoint (src/main.ts)

  • Generated at module load via z.toJSONSchema(RepoConfigSettingsSchema, { io: "input", target: "draft-2020-12" }) so optional-with-default fields carry a default keyword.
  • Served with content-type: application/schema+json; charset=utf-8 and cache-control: public, max-age=300.
  • $id set to https://task-action.xmtp.team/schema.json.
  • Narrow post-process fixes a Zod v4.3.6 quirk: VolumeSizeSchema uses .transform() which causes z.toJSONSchema to drop the default keyword on sandbox.volumes[].size. The workaround re-injects default: \"10Gi\" and throws loudly at module load if the shape ever drifts.

Reference docs (docs/repo-config.md)

  • Every config section and field documented with type, default, required/optional status.
  • Editor integration snippets for Taplo #:schema directive and .taplo.toml.
  • Linked from README.md (new Per-repo configuration subsection) and AGENTS.md (Reference list).
  • .code-factory/config.toml now carries a #:schema directive so editors fetch the schema automatically.

Non-goals (deliberately deferred)

  • No consumer of on_event.failed_run — no event router, no failed-run handler workflow. The block validates today; dispatch is a follow-up.
  • No Taplo x-taplo extension keywords, no build-time static schema asset, no version migration.

Test plan

  • npm run check — 401 tests across 32 files, typecheck/lint/format clean
  • New parseRepoConfigToml — on_event.failed_run coverage: full entry, optional prompt_additions, multiple entries (full-shape assertion), unknown-key stripping, four required/non-empty error paths, and a type-mismatch secret-leak regression guard using expect.assertions(2)
  • New resolveRepoConfigSettings — on_event defaults coverage: undefined, {}, sparse on_event: {}, and entry passthrough
  • New JSON_SCHEMA export coverage (11 tests): metadata, all default keywords, minItems: 1, required-field sets, prompt_additions NOT required, serializability
  • New GET /schema.json coverage (3 tests): 200 + headers, body deep-equals JSON_SCHEMA, non-GET falls through to 404
  • Existing regression anchors intact: unknown-top-level-key stripping, volume size normalization, POST /webhooks/github dispatch, the main.test.ts unknown-route 404 test

Spec / task list

  • Design: docs/plans/2026-04-22-repo-config-schema-extensions-design.md
  • Decomposition: docs/plans/2026-04-22-repo-config-schema-extensions-tasks.md

All 19 EARS requirements validated by final spec review.

🤖 Generated with Claude Code

Note

Add on_event.failed_run schema to repo config and serve it at /schema.json

  • Added [[on_event.failed_run]] support to repo-config-schema.ts: each entry requires non-empty workflows and branches arrays, with an optional prompt_additions field; resolved configs default on_event.failed_run to [].
  • Added a JSON_Schema export generated from the resolved schema in input mode, with $schema, $id, title, and description set; a workaround injects the sandbox.volumes[].size default lost during the zod transform, and throws on module load if the path is missing.
  • Added a GET /schema.json route in main.ts that returns the schema with content-type: application/schema+json and a 5-minute public cache.
  • Added documentation in docs/repo-config.md covering the full .code-factory/config.toml format and editor integration via the served schema.
  • Risk: module load throws if the expected sandbox.volumes[].size schema path is absent, which would prevent worker startup if the schema structure changes.

Macroscope summarized 3ba222e.

Copy link
Copy Markdown
Contributor Author

neekolas commented Apr 22, 2026

@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages Bot commented Apr 22, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
task-action 3ba222e Apr 22 2026, 10:30 PM

@neekolas neekolas changed the title feat(config): add on_event.failed_run sparse schema feat(config): add on_event.failed_run, serve JSON schema, and publish repo config reference Apr 22, 2026
@neekolas neekolas marked this pull request as ready for review April 22, 2026 22:29
Copy link
Copy Markdown
Contributor Author

neekolas commented Apr 22, 2026

Merge activity

  • Apr 22, 10:29 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 22, 10:30 PM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 22, 10:31 PM UTC: @neekolas merged this pull request with Graphite.

@neekolas neekolas changed the base branch from 04-22-update_to_use_new_code-factory-issue_skill to graphite-base/123 April 22, 2026 22:29
@neekolas neekolas changed the base branch from graphite-base/123 to main April 22, 2026 22:29
@macroscopeapp
Copy link
Copy Markdown

macroscopeapp Bot commented Apr 22, 2026

Approvability

Verdict: Needs human review

This PR adds schema definitions for a future on_event.failed_run config option (explicitly no consumer yet), a read-only /schema.json endpoint, and documentation. The schema-only addition and read-only endpoint pose minimal risk.

You can customize Macroscope's approvability policy. Learn more.

@neekolas neekolas force-pushed the 04-22-config_file_schema branch from 27e55e4 to 3ba222e Compare April 22, 2026 22:30
@neekolas neekolas merged commit c6191ea into main Apr 22, 2026
6 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