Skip to content

fix(workspace): verification strategy keyed off the file extension, not the declared type - #67

Open
minerva-sky wants to merge 1 commit into
codenamev:mainfrom
minerva-sky:fix/verify-strategy-by-extension
Open

minerva-sky wants to merge 1 commit into
codenamev:mainfrom
minerva-sky:fix/verify-strategy-by-extension

Conversation

@minerva-sky

Copy link
Copy Markdown
Collaborator

What

Workspace#verify_artifact chose its strategy from artifact.type, which is whatever the generating model declared. A .rb artifact labelled :markdown skipped RubyArtifactVerificationStrategy entirely. Same shape as the sanitizer spoof: the declared type is model input, not a fact about the file.

  • New ArtifactVerificationStrategy.for_artifact(artifact) maps File.extname(artifact.name) (case-insensitive) to the strategy: .rb, .js, .py, else basic.
  • Workspace#verify_artifact uses it. for_type stays for callers that only have a type.
  • A declared type that disagrees with the extension is logged at warn, not raised. The write is still gated on the extension-chosen strategy.

Tests

  • for_artifact: .rb declared :markdown → Ruby strategy; README.md declared :ruby_class → basic; Script.PY → Python; mismatch warns; .txt/:text stays quiet.
  • Workspace: add_artifact on a spoofed .rb instantiates the Ruby strategy.
  • bundle exec rspec spec/integration/workspace_integration_spec.rb spec/agentic/workspace_spec.rb spec/agentic/verification/: 208 examples, 0 failures. standardrb clean.

Out of scope

validate_artifact still passes artifact.type to Security::Sanitizer.sanitize_file_content. Once #32's type-scoped denylists land, that call should key off the extension the same way; separate PR so the two don't tangle.

🤖 Generated with Claude Code

…n, not the declared type

Workspace#verify_artifact dispatched on artifact.type, which the generating
model declares. A `.rb` artifact labelled `:markdown` therefore skipped the
Ruby strategy entirely. Add ArtifactVerificationStrategy.for_artifact, keyed
off File.extname(artifact.name), and use it from the workspace. The declared
type still works for for_type callers; a mismatch is logged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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