Skip to content

InMemoryJobInventory has no eviction; terminal jobs accumulate forever #60

@nficano

Description

@nficano

InMemoryJobInventory stores every job ever submitted in an unbounded ConcurrentHashMap<JobId, JobRecord> at lib/src/main/kotlin/dev/arcp/runtime/JobInventory.kt:38. The runtime calls updateStatus(jobId, status) on terminal transitions in ARCPRuntime.terminalCleanup at lib/src/main/kotlin/dev/arcp/runtime/ARCPRuntime.kt:375, but nothing ever removes the record afterward. A long-running runtime that accepts many short jobs accumulates them indefinitely, both consuming heap and growing the per-call sort cost in list at lib/src/main/kotlin/dev/arcp/runtime/JobInventory.kt:54. The JobInventory interface at lib/src/main/kotlin/dev/arcp/runtime/JobInventory.kt:13 also has no evict or prune hook, so callers cannot opt into a retention policy without writing their own implementation.

Fix prompt: Add an evict(jobId) or pruneCompletedOlderThan(duration) method to JobInventory and call it from ARCPRuntime.terminalCleanup once events have drained, or implement a configurable retention window (default a few hours) inside InMemoryJobInventory using an LRU or time-based eviction structure. Document the retention contract in the interface KDoc. Add a test that records 1000 terminal jobs and asserts the inventory size stays bounded by the configured limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:mediumMedium severity issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions