Files
hakmem/core/box/smallobject_policy_v7_box.h
Moe Charm (CI) 8143e8b797 Phase v7-4: Policy Box 導入 (L3 層の明確化とフロント芯の作り直し)
- SmallPolicyV7 Box: L3 Policy layer に配置、route 決定を一元化
- Route kind enum: SMALL_ROUTE_ULTRA / V7 / MID_V3 / LEGACY
- ENV priority (fixed): ULTRA > v7 > MID_v3 > LEGACY
- Frontend integration: v7 routing を Policy Box 経由に変更 (段階移行)
- Legacy compatibility: 既存の tiny_route_env_box.h は併用維持

Box Theory layer structure:
- L0: ULTRA (C4-C7, FROZEN)
- L1: SmallObject v7 (research box)
- L1': MID_v3 / LEGACY (fallback)
- L2: Segment / RegionId
- L3: Policy / Stats / Learner ← Policy Box added here

Frontend now follows clean "size→class→route_kind→switch" pattern.
ENV variables read once at Policy init, not scattered across frontend.

Future: ULTRA/MID_v3/LEGACY consolidation, Learner integration, flexible priority.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 03:50:58 +09:00

50 lines
1.9 KiB
C

// smallobject_policy_v7_box.h - SmallObject Policy v7 (Phase v7-4)
//
// Purpose:
// - Centralized routing policy for ULTRA / v7 / MID_v3 / LEGACY
// - Single source of truth for class → route_kind mapping
// - ENV configuration managed in one place (L3 Policy layer)
#ifndef HAKMEM_SMALLOBJECT_POLICY_V7_BOX_H
#define HAKMEM_SMALLOBJECT_POLICY_V7_BOX_H
#include <stdint.h>
#include <stdbool.h>
// ============================================================================
// Route Kind Enum (L0/L1/L1' layer selection)
// ============================================================================
typedef enum {
SMALL_ROUTE_ULTRA, // L0: C4-C7 ULTRA (FROZEN)
SMALL_ROUTE_V7, // L1: SmallObject v7 (research box)
SMALL_ROUTE_MID_V3, // L1': MID v3 (257-768B mid/small)
SMALL_ROUTE_LEGACY, // L1': TinyHeap v1 / Pool v1 (fallback)
} SmallRouteKind;
// ============================================================================
// Policy Snapshot Structure
// ============================================================================
typedef struct SmallPolicyV7 {
SmallRouteKind route_kind[8]; // C0-C7 routing decision
} SmallPolicyV7;
// ============================================================================
// Policy API
// ============================================================================
/// Get policy snapshot (read-only, TLS cached)
/// Frontend calls this to determine route_kind[class_idx]
const SmallPolicyV7* small_policy_v7_snapshot(void);
/// Initialize policy from ENV variables (called once at startup)
/// Priority: ULTRA > v7 > MID_v3 > LEGACY
/// @param policy: Policy structure to initialize
void small_policy_v7_init_from_env(SmallPolicyV7* policy);
/// Get route kind name for debugging
const char* small_route_kind_name(SmallRouteKind kind);
#endif // HAKMEM_SMALLOBJECT_POLICY_V7_BOX_H