Skip to content

Route the two time.Now() child-session sites through port.Clock for full clock-injectability of the engine #116

Closed

Description

@JAORMX

Sibling of #113. Small, mechanical, makes the engine fully deterministic for an embedding host.

Context

The main turn loop already reads wall-clock only through the injected port.Clock (verified: loop.go reads are e.deps.Clock.Now(); the only time.Now token in loop.go is a comment). But there are two direct time.Now() calls in the engine core, both minting ephemeral child-session ids + timestamps outside the main turn path:

// engine/agent/guardrailcheck.go:39
sess := session.New(
    session.SessionID(fmt.Sprintf("guardrail-checker-%d", time.Now().UnixNano())),
    session.ModeDefault, "/", guardrailCheckLimits,
    time.Now(),
)

and the identical pattern in engine/agent/forkjudge.go (engineJudge.Judge: fmt.Sprintf("%s-%d", j.idPrefix, time.Now().UnixNano()) + time.Now() createdAt).

Why it matters

An embedding host (Atrium) bans direct time.Now() in loop code so time-sensitive behaviour is deterministic in tests — all wall-clock must come from the injected clock. These two sites are reachable only when the guardrail-checker or the Parallel "judge" strategy is wired, so they don't bite a minimal embedding — but they're the one spot that breaks a strict "engine is fully clock-injectable" guarantee.

Ask

Thread the engine's port.Clock into guardrailcheck.go and forkjudge.go so the child-session CreatedAt and the id-suffix derive from the injected clock (the id can use Clock.Now().UnixNano(), or a port-supplied id source if you'd rather not derive ids from time). Then the core has zero direct time.Now() calls and layering_test.go could optionally grow a guard for it.

Activity

  1. added
    enhancement
    good first issue
    atrium-convergence
    on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    atrium-convergenceenhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions