Enforce lowercase identifier naming for HCL config block labels#106
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bysquadron verifywith 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 inConfig.Validate(), so a bad name fails fast before other validation. Coversvariable,model,agent,tool,plugin,mcp,skill,memory,mission, plus mission-scopedtask,dataset, andagentblocks. Errors on mission sub-blocks are framed with the owning mission name.config/config.go— removed the leftovershared_folderdeprecation 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 onlymemoryblocks reach it.config/blockname_internal_test.go(table-driven unit test over the full charset matrix) andconfig/blockname_test.go(end-to-endLoadAndValidatecases per block type: model, agent, variable, task, mission, dataset, scoped agent, memory, plus a valid case). Removed the obsoleteshared_folder-rejection test.config/overview.mdx(new "Block Naming" section + validation list) and updatedconfig/variables.mdx.Reviewer notes
agent_2,task1) — only a leading digit is rejected. Existing digit-using test fixtures still pass.PartialContent, which silently ignores unknown block types. A strayshared_folder { ... }block is now silently ignored rather than producing the old "usememory" pointer. Flag if you'd prefer it hard-error as an unknown block.SharedFolders/SharedFolderInfonames inwsbridge/are protocol types for the memory browser, unrelated to the HCL block — left untouched.Testing
go build ./...go test ./config/ ./wsbridge/ ./mission/— all greengo test ./config/ -run TestValidateBlockName -v— 21 cases passsquadron verifyagainst bad/good configs confirms the error and clean pass