Skip to content

Reuse portfolio-queue's real attempt-history in loop-cli.js's own convergence gate instead of an in-memory Map #5677

Description

@JSONbored

Context

loop-cli.js maintains its own separate, in-memory convergenceHistory Map for the autonomous loop daemon's run-loop-boundary gate -- distinct from, and now redundant with, the real, SQLite-persisted attempt-history portfolio-queue.js's getAttemptHistory already provides (#5654). loop-cli.js's own header still documents this as a known gap: "convergence/cap-usage history is IN-MEMORY, scoped to this loop process's own lifetime... a durable version needs attempt-log.js to grow a repo+issue index." That durable version now exists -- just via a different store (portfolio-queue.js, already real and persisted) than the header anticipated (attempt-log.js).

Left as-is, a loop-daemon restart (crash, deploy, systemd bounce) silently resets convergence/consecutive-failure counters for every in-flight item, weakening the stuck-loop detector exactly at the point -- a real restart -- it matters most.

Dependencies

None -- builds directly on #5654's already-shipped getAttemptHistory.

Requirements

  1. Replace loop-cli.js's in-memory convergenceHistory Map with real reads from portfolio-queue.js's getAttemptHistory -- the same function attempt-cli.js's own buildAttemptGovernorContext already consumes, so the loop daemon and a one-shot attempt invocation share one real source of truth instead of two independent counters (one persisted, one not).
  2. Remove the stale "DOCUMENTED GAP" header comment once the in-memory Map is gone.
  3. Out of scope: changing the run-loop-boundary gate's own decision thresholds (DEFAULT_AMS_POLICY_SPEC.convergenceThresholds) -- only its data source changes.

Deliverables / Acceptance Criteria

  • loop-cli.js's run-loop-boundary gate reads real, persisted convergence history via getAttemptHistory
  • A convergence-history counter survives a simulated loop-daemon restart (regression test)
  • The in-memory convergenceHistory Map and its stale header comment are removed

Test Coverage Requirements

This PR must ship with full test coverage for every changed line and branch -- the repo's Codecov patch gate requires 99%+ coverage and the house standard is to aim for 100%, including both sides of every conditional/nullish-coalescing branch introduced.

Expected Outcome

The non-convergence detector's cross-cycle memory survives a real process restart, closing a real durability gap in the autonomous loop daemon specifically (a one-shot attempt invocation is unaffected -- it already reads the real store via #5654).

Links & Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

    Projects

    Status
    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions