Skip to content

feat(clock): let a backing server follow the gateway clock through its own follower - #994

Open
canersoz-scaleai wants to merge 8 commits into
scaleapi:mainfrom
canersoz-scaleai:canersoz/fd-7156-real-open-source-app-envs-read-the-agentenv
Open

canersoz-scaleai wants to merge 8 commits into
scaleapi:mainfrom
canersoz-scaleai:canersoz/fd-7156-real-open-source-app-envs-read-the-agentenv

Conversation

@canersoz-scaleai

@canersoz-scaleai canersoz-scaleai commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Open-source apps wrapped as backing servers (Postgres, Gitea, Metabase and others) can run the computer clock follower in their image, so every process reads the env's time natively. Until now, sync_env_clock only handed backing servers the time URL. Now a server whose sync_time advertises the follower fields (watch_url, name, read_token) is declared a follower of its env's gateway, as an agent already is. It gets the watch URL as a compose sibling reaches the gateway, and teardown_sandboxes retires it. Servers without those fields, and deployments that aren't VM/compose, keep the current sync. A website that advertises them is declared site-<name>, so it never collides with an MCP server of the same name. The agent's declare-and-sync code moved into declare_and_sync_follower, which agents and servers now share. Part of FD-7156.

Docs: the clock page could say that a backing server opts in by advertising the follower fields on sync_time and running the follower.

How it was tested

  • ruff check passes.
  • pytest tst/unit/task_step tst/unit/a2a_agent packages/agentenv-protocol/tests/test_website_environment.py: 5032 passed on the first commit; after the review fixes, the clock, teardown and website tests (741 + 360) pass.
  • 6 tests failed on this Mac (5 in computer_exec_test, 1 in test_mcp_cli_builder); they fail the same way on unchanged main.
  • New tst/integration/task_step/test_server_env_clock_local.py passed on local Docker against the real gateway (110 s): sync_env_clock declared the server svc-warehouse, a write with wait_followers_s was acknowledged in 0.01 s, the same write answered 504 with stale: ["svc-warehouse"] while the server was paused, and after retire_server_followers a waiting write answered at once.
  • Not run on a real Modal VM or KubeVirt deployment.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge, with no outstanding findings.

Summary

Backing servers that advertise follower fields can now follow the gateway clock.

  • Backing servers can follow their gateway’s virtual clock.

No new actionable issues were found. The previous timing-settings finding is fixed.

Diagram

sequenceDiagram
    participant Step as Clock setup
    participant Gateway
    participant Server as Backing server
    Step->>Gateway: Arm clock
    Step->>Gateway: Declare follower with read token
    Step->>Server: Send watch URL, name, and token
    Server->>Gateway: Watch clock and acknowledge versions
    Gateway-->>Step: Waiting clock writes complete after acknowledgement
    Step->>Gateway: Retire follower before teardown
Loading

Reviews (8) · Last reviewed commit: "test(clock): name the follower test serv..." · Reviewed by Greptile

…s own follower

A backing server whose sync_time advertises the follower fields (watch_url, name,
read_token) is now declared a follower of its env's gateway, as an agent is, and
handed the in-compose watch URL, so every program in its image reads the env's
time. Teardown retires it. Servers without those fields keep today's sync, and a
website whose image runs the follower takes the same path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@canersoz-scaleai canersoz-scaleai self-assigned this Dec 2, 2026
@canersoz-scaleai
canersoz-scaleai marked this pull request as ready for review December 2, 2026 21:08
@canersoz-scaleai
canersoz-scaleai requested a review from a team as a code owner December 2, 2026 21:08
canersoz-scaleai and others added 4 commits December 2, 2026 13:23
…e website follower path

An MCP server and a website may share a name, so a website is declared site-<name>
and each server follower is recorded under its follower name, not its service.
The website's sync_time no longer takes follower fields: its card never
advertised them, so sync_env_clock never sent them, and the path imported the
agent package, which plain website installs don't have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_time

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l Docker

A server whose sync_time takes the follower's config is declared svc-<name> by
sync_env_clock, reaches the gateway's watch from inside the compose network, is
waited for by a write that waits for followers (504 naming it while paused), and
is no longer waited for once retired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
canersoz-scaleai and others added 2 commits December 2, 2026 15:55
…ay that takes no followers

A gateway from before declare_follower can still arm the clock and serve
env_get_time_url, so a server that could follow is synced the old way there
instead of being left unsynced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread tst/data/clock_follower_mcp/server.py Outdated
Comment on lines +39 to +42
for _ in range(100):
if self.shown is not None:
return {"synced": True, "version": self.shown.get("version")}
await asyncio.sleep(0.1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Timing settings lack names

The new test server hardcodes its request timeout, retry delay, and startup wait across _follow and sync_time. The repository requires magic numbers to be stored as named class or instance variables. Give these settings descriptive names so maintainers can change the wait budget without tracking separate literals. This requirement must be satisfied before merging.

Rule Used: Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. (source)

Learned From
scaleapi/scaleapi#126388

Prompt To Fix With AI
This is a comment left during a code review.
Path: tst/data/clock_follower_mcp/server.py
Line: 39-42

Comment:
**Timing settings lack names**

The new test server hardcodes its request timeout, retry delay, and startup wait across `_follow` and `sync_time`. The repository requires magic numbers to be stored as named class or instance variables. Give these settings descriptive names so maintainers can change the wait budget without tracking separate literals. This requirement must be satisfied before merging.

**Rule Used:** Store magic numbers as class or instance variables with descriptive names rather than using them inline in the code. ([source](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%3Fmemory%3D002e0051-41ad-46c1-9098-47433c580150))

**Learned From**
[scaleapi/scaleapi#126388](https://github.com/scaleapi/scaleapi/pull/126388)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Cursor Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8453dc0: the watch timeout, retry delay and first-answer wait are now named class attributes on ClockAppEnv (WATCH_TIMEOUT_S, WATCH_RETRY_S, FIRST_ANSWER_WAIT_S, FIRST_ANSWER_POLL_S), and the 100-iteration loop became an explicit deadline. Reran test_server_env_clock_local.py locally: passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale

Copy link
Copy Markdown
Collaborator

🤖 Automated Claude routine — Env Pod PR Context Review. This is a bot, not Edgar Arakelyan; not a human review.

Some context from a sibling PR: open #892 ("clock followers declare the times they hold") changes the same declare_follower call that this PR moves into the shared declare_and_sync_follower.

Git will flag the conflict in clock.py for whichever PR lands second. The part that's easy to lose is that the range key and the outside_range handling need to move into declare_and_sync_follower. If they stay at the old site, server followers declared through the new path (and agents, after the merge) won't declare the range they hold.


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants