Skip to content

Enforce lowercase identifier naming for HCL config block labels#106

Merged
mlund01 merged 1 commit into
mainfrom
claude/inspiring-jepsen-9d34cd
Jun 6, 2026
Merged

Enforce lowercase identifier naming for HCL config block labels#106
mlund01 merged 1 commit into
mainfrom
claude/inspiring-jepsen-9d34cd

Conversation

@mlund01
Copy link
Copy Markdown
Owner

@mlund01 mlund01 commented Jun 6, 2026

What

Adds validation so HCL config block labels may contain only lowercase letters, digits, and underscores, and must not start with a digit (pattern ^[a-z_][a-z0-9_]*$). Invalid names are rejected by squadron verify with a pointed error.

Why

Block labels become HCL reference identifiers — models.anthropic, agents.researcher, tasks.fetch. A label with uppercase, hyphens, spaces, or a leading digit either breaks reference resolution or silently misbehaves. Previously snake_case was only a documented convention; now it's enforced consistently across every block type.

What changed

  • config/blockname.go (new) — validateBlockName(kind, name) and (*Config).validateBlockNames(). Run first in Config.Validate(), so a bad name fails fast before other validation. Covers variable, model, agent, tool, plugin, mcp, skill, memory, mission, plus mission-scoped task, dataset, and agent blocks. Errors on mission sub-blocks are framed with the owning mission name.
  • config/config.go — removed the leftover shared_folder deprecation scaffolding (schema entry, collection branch, and the rejection error in the memory parse pass) now that the block is fully gone. The memory parse loop is simplified since only memory blocks reach it.
  • Testsconfig/blockname_internal_test.go (table-driven unit test over the full charset matrix) and config/blockname_test.go (end-to-end LoadAndValidate cases per block type: model, agent, variable, task, mission, dataset, scoped agent, memory, plus a valid case). Removed the obsolete shared_folder-rejection test.
  • Docs — documented the enforced naming rule in config/overview.mdx (new "Block Naming" section + validation list) and updated config/variables.mdx.

Reviewer notes

  • Digits are allowed (e.g. agent_2, task1) — only a leading digit is rejected. Existing digit-using test fixtures still pass.
  • Behavior change from removing the deprecation: the parser uses PartialContent, which silently ignores unknown block types. A stray shared_folder { ... } block is now silently ignored rather than producing the old "use memory" pointer. Flag if you'd prefer it hard-error as an unknown block.
  • The SharedFolders/SharedFolderInfo names in wsbridge/ are protocol types for the memory browser, unrelated to the HCL block — left untouched.

Testing

  • go build ./...
  • go test ./config/ ./wsbridge/ ./mission/ — all green
  • go test ./config/ -run TestValidateBlockName -v — 21 cases pass
  • Manual squadron verify against bad/good configs confirms the error and clean pass

Block labels become HCL reference identifiers (models.anthropic,
agents.researcher), so they must be valid identifiers. Add a centralized
validateBlockName check, run from Config.Validate before any other
validation, that rejects any named block whose label contains anything
other than lowercase letters, digits, and underscores (and must not start
with a digit). Covers variable, model, agent, tool, plugin, mcp, skill,
memory, and mission blocks, plus mission-scoped task, dataset, and agent
blocks — errors on sub-blocks are framed with the owning mission name.

Also remove the leftover `shared_folder` deprecation scaffolding (schema
entry, collection branch, and the rejection error in the memory parse
pass) now that the block is fully gone.

Tests: internal table-driven unit test over the full charset matrix, plus
end-to-end LoadAndValidate cases for each block type. Docs: document the
enforced naming rule in the config overview and variables pages.
@mlund01 mlund01 merged commit f2cde48 into main Jun 6, 2026
3 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