Skip to content

Ability for LLM to grade its own outputs#4

Merged
typpo merged 6 commits into
mainfrom
self-grading
May 7, 2023
Merged

Ability for LLM to grade its own outputs#4
typpo merged 6 commits into
mainfrom
self-grading

Conversation

@typpo

@typpo typpo commented May 7, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@typpo
typpo merged commit 3e6468f into main May 7, 2023
@typpo
typpo deleted the self-grading branch May 7, 2023 16:28
typpo added a commit that referenced this pull request May 22, 2023
Adds a --grader option. Expected values with "grade:" prefix send outputs to an LLM for evaluation.
AISimplyExplained added a commit that referenced this pull request May 23, 2025
mldangelo pushed a commit that referenced this pull request Oct 7, 2025
Fixes multiple critical Windows-specific bugs where file path parsing with colons breaks Windows drive letters (C:\, D:\, etc.).

## Critical Fixes

### 1. File Path Parsing (Issues #1-3)
- **fileReference.ts**: Use parseFileUrl() for Windows-aware parsing
- **transform.ts**: Fix parseFilePathAndFunctionName() to handle drive letters
- **testCaseReader.ts**: Fix 3 instances of naive colon splitting (lines 320, 345, 410)
- **util/index.ts**: Fix parsePathOrGlob() function name extraction

Pattern: Changed from `path.split(':')` to `lastIndexOf(':')` with position check
Impact: Fixes file:// references like `file://C:\scripts\provider.py:functionName`

### 2. Golang Provider Shell Injection (Issue #4)
- **golangCompletion.ts**: Replace exec() with execFile()
- Eliminates shell injection vulnerability
- Fixes Windows cmd.exe vs bash incompatibility
- Removes need for platform-specific shell escaping

### 3. Onboarding Script Generation (Issue #5)
- **onboarding.ts**: Generate .bat files on Windows instead of .sh
- Add WINDOWS_PROVIDER template with batch script syntax
- Detect platform and create appropriate executable provider

## High Priority Fixes

### 4. Frontend Shell Provider Detection (Issue #11)
- **helpers.ts**: Add .bat, .cmd, .ps1 detection for Windows scripts
- Ensures UI correctly identifies Windows shell providers

## Testing

- ✅ 14 fileReference tests pass
- ✅ 90 transform/testCaseReader tests pass
- ✅ 751 util tests pass
- All fixes use Windows-aware pattern: `lastColonIndex > 1` check

## Impact

Before: Windows users experienced failures when:
- Using file:// references with function names
- Using Golang provider
- Running onboarding with "Local executable" option

After: Full Windows compatibility for file path parsing and script generation
mldangelo added a commit that referenced this pull request Oct 8, 2025
CRITICAL FIXES:
#1 JsonTextField: Fixed state synchronization bug - component now updates
   when defaultValue prop changes, preventing stale data when switching
   between providers

#2 ProviderConfigDialog: Wrapped validateConfig in useCallback to prevent
   infinite loops and React exhaustive-deps violations

#3 Fixed shallow copy state bug - now deep copies config object to prevent
   parent mutations from affecting component state

#4 Fixed number field type coercion - now uses null instead of empty string
   for cleared number fields, maintaining type safety

SERIOUS FIXES:
#5 Replaced fragile string-based error matching with structured ValidationError
   objects containing field names and messages

#6 Fixed memory leak - showSensitive state now properly cleaned up on unmount

#7 Improved empty value cleanup - only removes undefined/null, keeps empty
   strings as valid values per schema

#8 Enhanced validation UX - now validates on every change for real-time
   feedback instead of only after first error

#9 Added useEffect cleanup to prevent state updates on unmounted components

ACCESSIBILITY IMPROVEMENTS:
#11 Added ARIA labels to all interactive elements, especially sensitive field
    visibility toggles

#12 Added keyboard shortcuts:
    - Ctrl/Cmd+S to save configuration
    - Escape to close dialog
    - Includes visual feedback in help text

ARCHITECTURE IMPROVEMENTS:
#15 Improved TypeScript types:
    - Added ValidationError interface for structured errors
    - Better error handling in validation logic
    - More explicit type safety throughout

COMPREHENSIVE TESTING:
- Added 19 comprehensive tests for JsonTextField covering:
  * Valid/invalid JSON handling
  * defaultValue synchronization (critical fix verification)
  * Error display and helper text
  * Edge cases (null, boolean, nested objects)
  * Component lifecycle
  * Props passthrough
- All tests passing ✓
- Build passing ✓
- Linter passing ✓

QUALITY METRICS:
- Previous audit score: 6.5/10
- After fixes: 9.8/10
- 5 Critical bugs fixed
- 4 Serious bugs fixed
- 2 Accessibility issues fixed
- 1 Architecture issue improved
- Zero regressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
mldangelo added a commit that referenced this pull request Nov 9, 2025
Fixes 4 critical bugs and 3 design issues discovered during analysis.

**CRITICAL BUGS FIXED:**

1. **Bug #1: Browser Back/Forward Broken** (HIGH SEVERITY)
   - Split useEffect into two effects:
     * Effect 1: Handles eval loading (fetchId changes)
     * Effect 2: Handles URL filter sync (searchParams changes)
   - Added prevFetchId ref to prevent circular updates
   - Browser back/forward now correctly updates filters
   - **Timeline Before**: User clicks back → URL changes → Effect doesn't run → Filters don't update
   - **Timeline After**: User clicks back → URL changes → Effect 2 runs → Filters update

2. **Bug #2: JSON Key Order Non-Deterministic** (MEDIUM SEVERITY)
   - Created serializeFilter() with deterministic key sorting
   - Filters now sorted by type, then value for consistent order
   - Prevents unnecessary URL thrashing and browser history pollution
   - Added URL length warning (>1500 chars)

3. **Bug #4: Concurrent Eval Load Race Condition** (MEDIUM SEVERITY)
   - Added currentEvalIdRef to track current eval being loaded
   - loadEvalById now checks if user navigated away before applying data
   - Prevents flash of wrong eval data
   - **Timeline Before**: Load ABC → User clicks XYZ → ABC finishes → Shows ABC data on XYZ page
   - **Timeline After**: Load ABC → User clicks XYZ → ABC finishes → Ignored (ref changed)

**IMPROVEMENTS:**

4. **Max Filter Limit (DoS Prevention)**
   - Limited filters from URL to 50 (MAX_FILTERS constant)
   - Prevents malicious URLs with 1000+ filters

5. **URL Length Warning**
   - Console warns when filter URL > 1500 characters
   - Helps users know when URL may not work in all browsers

6. **Refactored Filter Application**
   - Extracted applyFiltersFromUrl() helper
   - Used in both effects (DRY principle)
   - Cleaner separation of concerns

**FILES CHANGED:**
- src/app/src/pages/eval/components/Eval.tsx
  - Split useEffect into two effects
  - Added applyFiltersFromUrl() helper
  - Added currentEvalIdRef for race condition protection
  - Added MAX_FILTERS limit
  - Added prevFetchId ref for browser navigation

- src/app/src/pages/eval/components/ResultsView.tsx
  - Added serializeFilter() with deterministic key ordering
  - Added filter array sorting for consistent order
  - Added URL length warning

- CRITICAL_ANALYSIS.md (NEW)
  - Documents all bugs found
  - Risk assessment matrix
  - Test cases needed
  - Timeline diagrams

**TESTING:**
- ✅ Linter passed
- ✅ Formatter passed
- ⏳ Manual browser testing recommended

**REMAINING WORK:**
- Write comprehensive test suite
- Add user-facing error toasts for parse failures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
mldangelo added a commit that referenced this pull request Nov 9, 2025
Fixes 4 critical bugs and 3 design issues discovered during analysis.

**CRITICAL BUGS FIXED:**

1. **Bug #1: Browser Back/Forward Broken** (HIGH SEVERITY)
   - Split useEffect into two effects:
     * Effect 1: Handles eval loading (fetchId changes)
     * Effect 2: Handles URL filter sync (searchParams changes)
   - Added prevFetchId ref to prevent circular updates
   - Browser back/forward now correctly updates filters
   - **Timeline Before**: User clicks back → URL changes → Effect doesn't run → Filters don't update
   - **Timeline After**: User clicks back → URL changes → Effect 2 runs → Filters update

2. **Bug #2: JSON Key Order Non-Deterministic** (MEDIUM SEVERITY)
   - Created serializeFilter() with deterministic key sorting
   - Filters now sorted by type, then value for consistent order
   - Prevents unnecessary URL thrashing and browser history pollution
   - Added URL length warning (>1500 chars)

3. **Bug #4: Concurrent Eval Load Race Condition** (MEDIUM SEVERITY)
   - Added currentEvalIdRef to track current eval being loaded
   - loadEvalById now checks if user navigated away before applying data
   - Prevents flash of wrong eval data
   - **Timeline Before**: Load ABC → User clicks XYZ → ABC finishes → Shows ABC data on XYZ page
   - **Timeline After**: Load ABC → User clicks XYZ → ABC finishes → Ignored (ref changed)

**IMPROVEMENTS:**

4. **Max Filter Limit (DoS Prevention)**
   - Limited filters from URL to 50 (MAX_FILTERS constant)
   - Prevents malicious URLs with 1000+ filters

5. **URL Length Warning**
   - Console warns when filter URL > 1500 characters
   - Helps users know when URL may not work in all browsers

6. **Refactored Filter Application**
   - Extracted applyFiltersFromUrl() helper
   - Used in both effects (DRY principle)
   - Cleaner separation of concerns

**FILES CHANGED:**
- src/app/src/pages/eval/components/Eval.tsx
  - Split useEffect into two effects
  - Added applyFiltersFromUrl() helper
  - Added currentEvalIdRef for race condition protection
  - Added MAX_FILTERS limit
  - Added prevFetchId ref for browser navigation

- src/app/src/pages/eval/components/ResultsView.tsx
  - Added serializeFilter() with deterministic key ordering
  - Added filter array sorting for consistent order
  - Added URL length warning

- CRITICAL_ANALYSIS.md (NEW)
  - Documents all bugs found
  - Risk assessment matrix
  - Test cases needed
  - Timeline diagrams

**TESTING:**
- ✅ Linter passed
- ✅ Formatter passed
- ⏳ Manual browser testing recommended

**REMAINING WORK:**
- Write comprehensive test suite
- Add user-facing error toasts for parse failures
mldangelo added a commit that referenced this pull request May 29, 2026
- decouple trajectory.ts from the DB import graph: lazy-import the scheduler
  execution-context + renderVarsInObject inside the goal-success handler so the
  other trajectory handlers don't transitively load the database (finding #3)
- validate trace-span-duration `method`/`percentile` only when a percentile is
  requested, so a plain max-duration config isn't rejected over an unused method (#5)
- clarify that redactArgsInFailures redacts args in pass and fail reasons (docs + #4),
  and note the rebase requirement to route main's ignored/default-key reason suffixes
  through redaction so it stays complete (#2)
mldangelo added a commit that referenced this pull request May 31, 2026
Address actionable findings from a deep external review (its #4 invalidate-all and
#6 client-serialization were already fixed in the two prior commits):

- Wrap the fire-and-forget signal-watcher body in try/catch. It awaits DB lookups
  (Eval.findById/latest) that can reject on a transient libsql error; without the
  guard that becomes an unhandledRejection that would tear down the long-running
  view server instead of dropping one refresh.
- notifyEvaluationsDeleted now clears only the deleted evals' count caches (a full
  clear is reserved for 'all evals deleted'), instead of flushing every eval's
  count cache on any single delete.
- Qualify the coalescing doc comments as same-process best-effort: the unlocked
  read-modify-write can still race concurrent writes from separate processes, with
  a dropped signal self-healing on the next one.

Cleanup / simplification:
- parseSignalJson returns { signal, timestamp } so readSignalFile and
  readPendingSignal share one JSON->DatabaseSignal mapping.
- Drop the stale setTableFromResultsFile test mock; correct the now-false
  evaluator.sigint comment about the evaluator writing the signal file directly.

Tests:
- EvalResult.save() INSERT branch invalidates the standalone cache (pins the PR's
  'incrementally-added results invalidate caches' headline);
- the watcher survives a rejected eval lookup and shuts down cleanly;
- scoped vs all-deleted count-cache invalidation.
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