contract-change
Change a Cloudhal domain contract (JSON Schema in packages/core-contracts) and regenerate TypeScript and Rust types without drift. Use when adding or changing a node type, field, enum value or shared definition.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- contract-change
- license
- Apache-2.0
- metadata
- { "cloudhal.area": "area:graph", "cloudhal.kind": "repo-skill" }
- description
- Change a Cloudhal domain contract (JSON Schema in packages/core-contracts) and regenerate TypeScript and Rust types without drift. Use when adding or changing a node type, field, enum value or shared definition.
03 SKILL.md 正文
Contract change
Contracts are JSON Schema 2020-12 files in packages/core-contracts/schemas/. Both src/generated/*.ts and crates/cloudhal-schema/src/generated/*.rs are produced from them and committed; CI rejects drift.
Steps
- Decide the version impact. Adding an optional field is non-breaking. Removing/renaming a field, changing a type, or adding a required field is breaking → bump
SchemaVersionenum incommon.schema.jsononly with an accepted RFC (write-rfc), and keep the old version's fixtures. - Edit the schema. Shared shapes go in
common.schema.json#/$defs; root-specific helpers in that root's$defs. Stay inside the generator-safe subset:- unions:
oneOf+ inline object variants + a one-value enum discriminator,"kind": {"type":"string","enum":["one"]}unless the domain says otherwise (field definitions usetype, ADR-0043), listed inrequired - no
default,$dynamicRef,unevaluatedProperties,dependentSchemas,if/then - cross-file refs only
common.schema.json#/$defs/Xor<root>.schema.json(top level) additionalProperties: falseon objects; maps useadditionalProperties: {schema}- string
patterns must be valid in both JS and the Rustregresscrate (ECMAScript syntax; avoid lookbehind)
- unions:
- Add fixtures. At least one
fixtures/valid/<schema>/*.jsonexercising the new shape and onefixtures/invalid/<schema>/*.jsonas{"reason": "...", "data": {...}}. - Regenerate and test.
If Rust round-trip fails, the usual causes arepnpm gen pnpm check && cargo test --workspace && cargo clippy --workspace --all-targets -- -D warningsdefault(serde skips defaults) or a union shape typify turned intountagged. Fix the schema, not the generated code. - Check the generated diff reads as intended (
git diff packages/core-contracts/src/generated crates/cloudhal-schema/src/generated). Unexpected renames mean atitlechanged. - Commit schema + fixtures + generated files together; add a changeset for
@cloudhal/core-contracts; reference the RFC/ADR in the commit body.
References
docs/adr/0001-contract-pipeline.md— why this pipeline, tool pinsdocs/rfcs/0001-site-graph.md— the model and its invariants- https://github.com/oxidecomputer/typify (supported schema subset) · https://github.com/bcherny/json-schema-to-typescript
04 同仓库更多 Skills
stale-review
Review a few published articles that have not been updated for a long time, make small safe fixes in drafts, and leave them as one proposed release for a person to schedule - never publishing anything. Built for a weekly scheduled agent task (begin_run, then end_run) that does not read visitor text. Use for a periodic content review or when asked which old articles need attention.
site-design
Design or redesign Cloudhal pages that look modern and follow the site's own design rules (DESIGN.md). Use when asked to build, design, restyle or improve a page, a landing page or a home page, or to write the site's design rules.
site-bootstrap
Set up a new Cloudhal site's first pages and navigation from a short brief. Use when a site is empty or the user asks to "set up", "scaffold" or "bootstrap" a site.
safe-edit
Make a reviewable change to an existing page or article - snapshot first, edit, preview, report the diff. Use for any edit request on existing content, including re-filing an article under other categories or tags.
rollback
Restore a site to an earlier snapshot after confirming the target with the user. Use when something published is wrong and the user asks to revert, undo or roll back.
publish-article
Check a draft article, file it under the site's categories and tags, produce a preview and submit it for publication now or at a set time, optionally under an embargo or with an expiry. Use when the user asks to publish, release, schedule or go live with an article.