Files
hakorune/tools/hako_check/rules/rule_missing_entrypoint.hako
nyash-codex 50ac8af2b8 Phase 21.4 Complete: FileBox SSOT + Analyzer Stabilization (7 Tasks)
 Task 1: Fallback Guarantee (create_box failure → ring1/core-ro auto fallback)
- Three-tier fallback system: plugin → builtin → core-ro
- Mode control: auto/plugin-only/core-ro
- New: src/box_factory/builtin_impls/file_box.rs
- New: tools/test_filebox_fallback_smoke.sh

 Task 2: Provider Registration SSOT (static/dynamic/core-ro unified)
- ProviderFactory trait with priority-based selection
- Global registry PROVIDER_FACTORIES implementation
- Priority: dynamic(100) > builtin(10) > core-ro(0)
- New: src/boxes/file/builtin_factory.rs
- New: tools/smoke_provider_modes.sh

 Task 3: FileBox Publication Unification
- Verified: basic/file_box.rs already minimized (11 lines)
- Perfect re-export pattern maintained

 Task 4: ENV Unification (FILEBOX_MODE/DISABLE_PLUGINS priority)
- Removed auto-setting of NYASH_USE_PLUGIN_BUILTINS
- Removed auto-setting of NYASH_PLUGIN_OVERRIDE_TYPES
- Added deprecation warnings with migration guide
- ENV hierarchy: DISABLE_PLUGINS > BOX_FACTORY_POLICY > FILEBOX_MODE

 Task 5: Error Log Visibility (Analyzer rule execution errors to stderr)
- Added [rule/exec] logging before IR-based rule execution
- Format: [rule/exec] HC012 (dead_static_box) <filepath>
- VM errors now traceable via stderr output

 Task 6: Unnecessary Using Removal (14 rules Str alias cleanup)
- Removed unused `using ... as Str` from 14 rule files
- All rules use local _itoa() helper instead
- 14 lines of dead code eliminated

 Task 7: HC017 Skip & TODO Documentation (UTF-8 support required)
- Enhanced run_tests.sh with clear skip message
- Added "Known Limitations" section to README.md
- Technical requirements documented (3 implementation options)
- Re-enable timeline: Phase 22 (Unicode Support Phase)

📊 Test Results:
- Analyzer: 10 tests PASS, 1 skipped (HC017)
- FileBox fallback: All 3 modes PASS
- Provider modes: All 4 modes PASS
- Build: Success (0 errors, 0 warnings)

🎯 Key Achievements:
- 28 files modified/created
- Three-Tier Fallback System (stability)
- SSOT Provider Registry (extensibility)
- ENV unification (operational clarity)
- Error visibility (debugging efficiency)
- Code cleanup (maintainability)
- Comprehensive documentation (Phase 22 ready)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 17:04:21 +09:00

63 lines
1.8 KiB
Plaintext

// tools/hako_check/rules/rule_missing_entrypoint.hako — HC014: Missing Entrypoint
// Detect when no entrypoint (Main.main or main) exists in the analyzed code.
static box RuleMissingEntrypointBox {
method apply_ir(ir, path, out) {
local entrypoints = ir.get("entrypoints")
if entrypoints == null { return 0 }
local methods = ir.get("methods")
if methods == null || methods.size() == 0 {
// No methods at all - definitely missing entrypoint
out.push("[HC014] missing entrypoint (Main.main or main)")
return out.size()
}
// Check if any entrypoint exists
local found = 0
local ei = 0
while ei < entrypoints.size() {
local ep = entrypoints.get(ei)
if me._has_entrypoint_method(methods, ep) == 1 {
found = 1
break
}
ei = ei + 1
}
// If no entrypoint found, report error
if found == 0 {
out.push("[HC014] missing entrypoint (Main.main or main)")
}
return out.size()
}
_has_entrypoint_method(methods, ep_name) {
// Check if method starting with ep_name exists
// e.g., "Main.main" matches "Main.main/0", "Main.main/1", etc.
// "main" matches "main/0", etc.
local mi = 0
while mi < methods.size() {
local m = methods.get(mi)
if m == null { mi = mi + 1; continue }
// Check exact match with arity suffix
// ep_name can be "Main.main" or "main"
local len = ep_name.length()
if m.length() >= len + 2 {
local prefix = m.substring(0, len)
if prefix == ep_name {
// Check if followed by "/" (arity separator)
local next_char = m.substring(len, len+1)
if next_char == "/" { return 1 }
}
}
mi = mi + 1
}
return 0
}
}
static box RuleMissingEntrypointMain { method main(args) { return 0 } }