feat: Startup scripts and path-based file verbs#382
Conversation
Change the default system root search order to: 1. FRONTIER_ROOT environment variable (if set) 2. Frontier.root7 in current working directory 3. Frontier.root in current working directory 4. Frontier.root7 in executable directory 5. Frontier.root in executable directory 6. Legacy paths (~/Library/Application Support/Frontier/) This allows running the CLI from the dist/ directory without needing to set FRONTIER_ROOT or specify --system-root. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change default behavior so system.startup scripts run automatically when loading a system root database. Scripts can be skipped via: - --skip-startup command line flag - FRONTIER_HEADLESS_RUN_STARTUP=0 environment variable This prepares for testing mainResponder and Manila databases which require startup initialization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
frontier-cli can access /tmp - there is no macOS sandbox restriction. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
file.open/read/write/close now use path-based lookup instead of refnum: - file.open(path) opens file and registers in internal table, returns boolean - file.read(path, count) reads from already-opened file at current position - file.write(path, data) writes to already-opened file at current position - file.close(path) closes file by path lookup Key changes: - Added path-based file handle registry with case-insensitive matching - file.read now handles infinity count to read remaining bytes - Updated integration tests to use path-based API - Added regression tests for sequential reads, infinity, and error cases - Removed legacy refnum-based functions - Fixed startup script loading (frontierStartupCommands.txt now readable) This matches the original Frontier semantics documented in docs/usertalk/docserver/file/read.txt and related files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Modern systems benefit from larger I/O buffers that reduce syscall overhead. Matches the buffer sizes used by macOS copyfile() and Linux cp. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Code Review - PR #382Critical Issues
|
- Fix setbinaryvalue() parameter to use bytesread instead of OSType - Move variable declarations to top of blocks for C89 compliance - Add USERTALK_INFINITY constant for clarity - Add stack size justification for 128KB buffer comment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: PR #382 - Startup scripts and path-based file verbsThis PR makes two major changes: enabling startup scripts by default and refactoring file verbs to use path-based semantics. The implementation is generally solid with good test coverage, but there are several concerns that should be addressed. 🟢 Strengths1. Excellent Test Coverage
2. Good Documentation
3. System Root Discovery Enhancement
4. Buffer Size Optimization
🟡 Concerns & Issues1. Thread Safety - Path-Based File Table
|
- Fix USERTALK_INFINITY to use 64-bit value (0x7FFFFFFFFFFFFFFFLL) - Use platform-specific path normalization (case-insensitive on macOS, case-sensitive on Linux) - Move release_file_by_path() call after all cleanup logic in readfunc - Add debug logging for getcwd() failures - Update CLI_USAGE_GUIDE.md to document startup script default change for legacy Frontier parity Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: PR #382 - Startup Scripts and Path-Based File VerbsSummaryThis PR makes two significant architectural changes: (1) enabling startup scripts by default in headless mode, and (2) refactoring file verbs to use path-based semantics instead of refnum-based handles. The implementation is well-executed with strong test coverage improvements (7→71 passing file verb tests). ✅ Strengths1. Excellent Path Normalization StrategyThe path-based file API includes platform-aware path normalization (lines 407-414 in fileverbs_portable.c):
This is exactly the right approach for cross-platform compatibility. 2. Strong Thread SafetyThe refactored file table maintains proper reference counting and mutex protection:
3. Clear Backward Compatibility PathThe CLI flag --skip-startup and FRONTIER_HEADLESS_RUN_STARTUP=0 provide escape hatches for users who need the old behavior during migration. 4. Comprehensive Test CoverageThe integration tests now cover:
|
|
LOW: Startup Script Default Change Needs Clearer Migration Path 🟢The PR changes the default behavior for all existing CLI users. Scripts that previously did not run will now run automatically. Mitigations Already in Place:
Recommendation: Consider adding a deprecation notice in the next release notes or a one-time warning message when startup scripts run (suppressible via env var). LOW: Buffer Size Increase Lacks Justification 🟢Location: fileverbs_portable.c:676, 684 128KB buffer is used with the comment "reduces syscall overhead; macOS default stack is 8MB" Questions:
Recommendation: Either add a comment citing performance benchmarks, use heap allocation for large buffers, or add a compile-time stack size check. 🔍 Code Quality ObservationsPositive:
Minor Nitpicks:
|
📋 TestingWhat is Tested:
What is Missing:
Recommendation: Add a concurrency test to verify the race condition fix once implemented. 🎯 VerdictApprove with Required Changes The PR accomplishes its goals and includes excellent test coverage (7→71 passing file verb tests), but the TOCTOU race condition in open_file_by_path() is a blocking issue that must be fixed before merge. Action Items:
📚 References
Review conducted per: docs/TESTING_GUIDE.md, docs/ARCHITECTURAL_ANTIPATTERNS.md, CLAUDE.md |
- Fix TOCTOU race in open_file_by_path() by reserving slot before I/O (mark inuse=true with fp=NULL, then install fp after fopen) - Add truncation detection to normalize_path() with warning log - Lower infinity threshold to 2GB (USERTALK_INFINITY_THRESHOLD) matching the practical "read rest of file" behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review SummaryThis PR makes significant changes to file I/O semantics and startup behavior. Implementation is solid overall, but critical issues need addressing. CRITICAL ISSUES1. API Breaking Change (portable/fileverbs_portable.c)
2. Thread Safety Race (portable/fileverbs_portable.c:136-199)
3. Platform Inconsistency (portable/fileverbs_portable.c:109-126)
MAJOR CONCERNS4. Startup Scripts Default Changed
5. Infinity Magic Number (line 90)
6. 128KB Stack Buffer (lines 854, 965)
CODE QUALITY7. CWD Search Priority (main.c:450-460)
8. Missing Leak Info (line 329)
9. Performance: Linear search O(n) and repeated normalization acceptable for now POSITIVESTest Coverage: EXCELLENT
BEFORE MERGECRITICAL:
HIGH: MEDIUM: Verdict: Request changes for thread safety + docs, then approve Great work on test coverage! |
- Skip reserved-but-not-opened slots (fp=NULL) in get_file_by_path() - Skip reserved-but-not-opened slots in close_file_by_path() - Skip NULL fp in cleanup_file_handles() - Improve leak warning to show file paths This ensures concurrent threads do not see slots during the fopen window. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: PR #382 - Startup scripts and path-based file verbsSummaryThis PR makes two significant architectural changes:
The implementation is well-structured and the test improvement (7→71 passing tests) is impressive. However, there are several critical issues that need attention before merge. 🔴 Critical Issues1. Thread-Safety Race Condition in
|
Summary
This PR enables startup scripts to run by default in headless mode and refactors file verbs to use path-based semantics matching legacy Frontier behavior.
Key Changes
system.startupscripts now execute automatically in headless mode--skip-startupflag - Added CLI flag to disable startup script execution for debuggingfile.open,file.read,file.write,file.closeetc. to use path-based lookups instead of refnum-based (matching legacy Frontier semantics)File Verb Semantics Change
Legacy Frontier uses path-based file handles:
This PR implements path-based lookups in the kernel to match this behavior.
Test Results
File verb integration tests improved from 7 passed (66 failed) to 71 passed (7 failed) - a 10x improvement.
Test plan
make -C frontier-clibuilds successfully--system-root dist/Frontier.root7--skip-startupflag works correctly🤖 Generated with Claude Code