Expand description
Scaffold writes — decided new, decided init, decided quickstart,
decided migrate metadata (PORT-CONTRACT.d/16).
Ports of src/rac/core/idgen.py (generate_id), src/rac/core/ templates.py (load_template), src/asdecided/services/init.py
(init_repository, load_repository_config, write_mcp_configs via
src/asdecided/services/profiles.py), src/asdecided/services/create.py
(create_artifact), src/asdecided/services/quickstart.py (quickstart),
and src/asdecided/services/migrate.py (migrate_metadata).
The packaged template bodies are embedded verbatim from
rust/decided-engine/assets/templates/, vendored byte-identical copies of
the Python package files — a unit test below pins that identity, because
the written artifact must be byte-identical to what the oracle writes.
Minted ids are wall-clock + CSPRNG derived (the oracle has no external
seam); the parity harness masks them (mask-ids) on stdout AND captured
file bytes, so this module uses the real clock and /dev/urandom.
Structs§
- Created
Artifact - Result of one artifact creation (
bytes_writtenis in the oracle’s dataclass but deliberately absent from its JSON, so it is not carried). - File
Migration - Migration outcome for one Markdown file.
- Init
Result - Outcome of one
decided initrun (stable JSON contract, ADR-007). - Migration
Report - Repository-level migration result (stable JSON contract, ADR-007).
- Quickstart
Result - Outcome of one
decided quickstartrun. - Repository
Config - A discovered repository identity configuration.
Enums§
- Scaffold
Error - The scaffold failure contract, message-shaped like the oracle’s
exception
str(). Exit-code routing lives with each command handler, because the SAME error class maps to different exits per command (OutputPathExistsis usage exit 2 undernewbut a refusal exit 1 underquickstart— measured).
Constants§
- ID_
ALPHABET - Crockford base32: no I, L, O, U (visually ambiguous).
- MCP_
JSON - The AsDecided MCP server wiring, identical for Claude Code (
.mcp.json) and Cursor (.cursor/mcp.json). - STATUS_
ALREADY_ CANONICAL - STATUS_
MIGRATED - Stable per-file statuses (part of the JSON contract, ADR-007).
- STATUS_
SKIPPED_ UNKNOWN
Functions§
- create_
artifact create_artifact(artifact_type, output_path)— write one new artifact with assigned identity. The path is taken literally: no slug derivation, no directory creation, never overwrite.- generate_
id generate_id(repository_key)—<KEY>-+ 8-char millisecond-timestamp segment + 4-char random segment, Crockford base32.- init_
repository init_repository(directory, key, ticketing, profile, org_endpoint)— establish (or confirm) the identity namespace.ticketingandprofilearrive argparse-choice-validated; both apply only on a FRESH init.org_endpoint(ADR-117) is an explicit operator action and applies on fresh AND already-initialized repositories alike.- load_
repository_ config load_repository_config(start_dir)— the nearest.decided/config.yamlat or above the RESOLVEDstart_dir, read strictly, or None.- load_
template load_template(artifact_type)— the canonical body, orTemplateNotFoundfor an unregistered type.TemplateResourceMissing(a broken Python installation) has no Rust equivalent: embedded resources cannot be absent from a linked binary.- migrate_
metadata migrate_metadata(directory, dry_run, recursive)— prepend the canonical envelope to every recognized artifact without frontmatter, body bytes untouched. ANY frontmatter presence — valid, malformed, or unterminated — isalready-canonical(validation owns broken envelopes); documents that do not classify areskipped-unknown.- quickstart
quickstart(directory, key, artifact_type)— validate the type first, refuse a non-empty corpus BEFORE any write, establish identity, then scaffold<dir>/decisions/<type>s/first-<type>.md.- render_
frontmatter render_frontmatter(artifact_id, artifact_type)— canonical generated envelope, stable key order (v0.7.11 contract).