fix(registry): validate frontmatter thinkingLevel against the closed enum (#90) - #98
Merged
Merged
Conversation
…enum (#90) The bare cast let an invalid thinkingLevel (e.g. 'ultra', or a non-string) reach createAgentSession unvalidated and silently no-op — inconsistent with both the backend field (throws FrontmatterError) and the fleet-settings guard (#78 warns). - isThinkingLevel + THINKING_LEVELS move to registry/frontmatter.ts (canonical home, next to the type); fleet-settings re-exports for back-compat - parseAgentFile: invalid value -> FrontmatterError naming file, bad value, valid levels (discovery catches -> warning + skip, siblings still load); YAML-empty null counts as absent - 6 new tests (throws x2, back-compat x3, discovery integration x1); 819/819
…e message pin (#90) NIT 1: quoted padded values (' low') now trim before validating — genuinely the same contract as backend, as the comment claims. NIT 2: array value test pins the rendered message shape (["low"]). 821/821.
Merged
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.
Closes #90.
Problem
parseAgentFileparsed agent frontmatterthinkingLevelwith a bare cast — an invalid value (thinkingLevel: "ultra", or a non-string) reachedcreateAgentSessionunvalidated and silently no-op'd, while the identical typo in fleetsettings.jsonwarns (#78 guard). Inconsistent validation for the same value class.Design choice (the issue's micro-decision)
The issue offered "warnings-out param vs registry-load-time surface". Both miss the parser's own precedent:
backendis the same closed-enum value class and already throwsFrontmatterError— no warnings channel needed.discovery.tsalready catchesFrontmatterError→ actionable warning + skip that file, siblings still load. So:thinkingLevel→FrontmatterErrornaming file, bad value, valid levels — same contract asbackend, surfaced by discovery as a warning (consistent with enh: fleet.defaultSubagentThinking — fleet-wide subagent thinking-level default (split from #64) #78's "actionable warnings, never silent swallow" rule).thinkingLevel:→null) counts as absent — no error.Changes
src/registry/frontmatter.ts:THINKING_LEVELS+isThinkingLevel()move here (canonical home, next to the type — avoids a settings→registry inverted dependency);parseAgentFilevalidates before returning.src/settings/fleet-settings.ts: imports the guard from frontmatter, re-exportsisThinkingLevel/THINKING_LEVELSfor back-compat (zero external consumers in-repo today, but the package ships raw ts).Verification
pnpm typecheck✅ standalonepnpm test:run✅ 819/819 standalone