feat(base2): add JavaScript Control-Flow Verification Rule to system prompt... - #872
feat(base2): add JavaScript Control-Flow Verification Rule to system prompt...#872chicagoist wants to merge 1 commit into
Conversation
…prompt Add a mandatory three-check rule to the General guidelines section: 1. DOM-selector cross-reference — verify querySelector targets exist 2. Execution-path trace — confirm addEventListener calls are reachable 3. boxes.length > 0 pattern — detect dead guards after UI migration Prevents the recurring class of bugs where JS is syntactically valid (node --check passes) but logically dead due to unreachable code wrapped in a falsy condition referencing removed DOM elements.
|
Thanks for the detailed writeup and the root-cause case study — that's a real class of bug (syntactically valid but logically dead code due to stale selectors) and worth thinking about. That said, I'd hold off on porting this as-is:
If you have eval numbers or several repro cases showing this rule reduces false 'fixed' declarations, that would make a much stronger case for landing something like this — possibly as a narrower, generalized rule (e.g., 'don't declare a fix complete based on static checks alone; verify the code path executes') rather than DOM/JS-specific mechanics. |
prompt...
Pull Request: Add JavaScript Control-Flow Verification Rule to Buffy Agent
Repository: CodebuffAI/codebuff
Target file:
agents/base2/base2.tsTarget section:
systemPrompt→# General guidelinesBranch:
mainTitle
Problem
When debugging JS in HTML files, the agent falls into a "syntax-blind loop":
it sees
node --checkfail, fixes brace imbalances mechanically, and declaressuccess when the parser passes — without verifying the code actually executes.
Real-world case study (30-round debugging cycle)
node --check→ SyntaxError (missing braces)node --checkpassed → agent declared "fixed"Root cause: quiz logic was wrapped in
if (boxes.length > 0)whereboxes = querySelectorAll('.answerbox[contenteditable]'). Those elements were removedduring a UI migration to checkboxes.
boxes.lengthwas always 0. Code wassyntactically valid but logically dead. The agent had grep, file reading,
and DOM analysis — but no mandatory checklist to use them.
This is a recurring class of bugs. The fix is not a new tool — it's a
mandatory methodology encoded in the system prompt.
Proposed Change
One new bullet in
# General guidelines, placed after the closing backtick ofthe Composio conditional block (
${ENABLE_COMPOSIO_TOOLS ? ... : ''}) andbefore the literal line
# Spawning agents guidelines.Unified diff
Rationale for single bullet
Existing guidelines use compact
- **Topic:** Actionable instructionformat.This follows the same style. The three sub-checks are inline for brevity while
remaining specific enough to execute.
The Three Rules (reference)
grep '<selector>' *.html→ at least 1 match must existaddEventListener— every wrappingifmust be reachableboxes.length > 0patternContribution Checklist
agents/(per CONTRIBUTING.md)systemPromptAlternatives Considered
instructionsPromptsectionLicense
By submitting this pull request, I confirm that my contribution is made under
the terms of the project's license.