Default script entrypoint by kind when frontmatter omits it #91
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: Audit section 3.
Spec:
specs/frontmatter.alliumScriptFrontmatter andspecs/schema.alliumScript: entrypoint default is "render" for macros, "main" otherwise.engine/script.rscreate_scriptgets this right.Current behaviour (RuDS):
crates/bds-core/src/util/frontmatter.rsdeserialize_entrypoint/default_entrypointfall back to "render" regardless of kind — a legacy .lua file without an entrypoint field for a utility/transform script rebuilds with entrypoint "render" instead of "main", so execution then fails to find the function.Task: Kind-aware default: after parsing ScriptFrontmatter, when the entrypoint field was absent, resolve the default from the parsed kind (macro→render, utility/transform→main). Since serde field-level defaults can't see sibling fields, do the fixup in
read_script_fileor at the rebuild call sites (script_rebuild.rs). Check what bDS2 does for legacy files (../bDS2/lib/bds/scripts.ex/ frontmatter.ex) and match. Add tests for both kinds without entrypoint.Acceptance: Utility script file without entrypoint rebuilds with entrypoint "main"; macro with "render".
Implemented in
a1c04ff. Script frontmatter now resolves a missing entrypoint after parsing kind: macro defaults to render, while utility and transform default to main. The fix lives in ScriptFrontmatter::from_yaml, so every shared reader (rebuild, desktop, CLI, TUI, metadata diff, rendering, and Blogmark paths) gets the same behavior; explicit entrypoints remain unchanged. Added a filesystem rebuild regression covering all three kinds without entrypoint fields. Neutral review verified specs/frontmatter.allium, specs/schema.allium, and specs/script.allium. bDS2 creation is kind-aware, while its legacy file rebuild currently hardcodes main; the implemented behavior follows the issue acceptance and authoritative Allium contract rather than that bDS2 rebuild inconsistency. Verified with cargo clippy --workspace --all-targets -- -D warnings, cargo build --workspace, and cargo test --workspace (532 passed core tests plus the new regression = 533 total, 1 explicitly ignored; all workspace tests passed).