Repository navigation
fix: keep guild spec order and refresh the manager row on relaunch (0.8.1) - #77
Merged
milliondreams merged 5 commits intoNov 28, 2026
Merged
Conversation
TestRaftElector_Failover shut the leader down once the leader's own configuration listed all three voters. A configuration change commits once a majority has it, so one follower could still hold the older configuration without the third node. Raft rejects votes from candidates outside a node's own configuration, so neither remaining node could win an election and the test timed out. It failed about 1 in 30 runs, before and after the raft 1.8.0 upgrade. Wait until every node's configuration lists all voters instead.
Bootstrap built the stored guild by hand instead of through the store's mapper, so the position and spec_data columns added for rusticai-core 1.5 were never set on this path. Every guild launched from a client was stored with all agents and routes at position 0, read back in ID order rather than spec order, and kept no spec_data on the guild row. - Build the rows with store.FromGuildSpec, as the manager API's ensure path already does. - Finish the spec before building them: settle the guild ID, rewrite default agent IDs and derive the state manager config first, so the stored spec_data matches what is launched. - Apply FORGE_STATIC_GUILD_ID to the spec itself. It only set the stored guild's ID, so the spawned manager and agent IDs still used the authored ID. Guilds already stored keep their rows; ones with every position at 0 read back in ID order, as rusticai-core does after its migration.
Every relaunch of a guild logged "manager api POST .../agents/ensure failed (409): agent id already exists with a different specification". The guild manager registers its own row with ensure_agent, and its spec always differs from the stored one on a relaunch: its properties carry the manager API address, which changes whenever Forge gets a new port (Rustic Studio picks one on each launch), and the guild spec it was spawned with, which a relaunch rebuilds from the stored rows. The 409 aborted launch_guild_agents before it marked the guild starting and sent its first health report. - When the guild's own manager agent ensures an existing row, update the row to the new spec, keeping its position and status. Every other agent still gets 409 for a changed spec, including one that reuses the manager's ID with another class. - Never store manager_api_token in the manager's row. The guild API returns stored agent specs, and each spawn passes the token from Forge's environment, so nothing needs the stored copy. Rows that already hold it are rewritten without it on the next relaunch.
A relaunch spawns the guild manager with a guild spec rebuilt from the stored rows, and those include the manager's own row. So the manager's guild_spec property held the previous manager spec, which held its own guild_spec. With the manager's row now refreshed on each relaunch, the spec would gain a level of nesting every time. Build the manager's spawn request from the guild spec without the manager agent. Rows that already nest an older spec are rewritten without it on the next relaunch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two bugs found while testing Rustic Studio on Forge 0.8.0, and bumps the version to 0.8.1.
Guilds launched from a client lost their spec order
Bootstrapbuilt the stored guild by hand instead of through the store's mapper. So thepositionandspec_datacolumns added in 0.8.0 for rusticai-core 1.5 were never set on this path. Every guild launched from Studio or the API was stored with all agents and routes at position 0, and read back in ID order instead of spec order. The guild row also had nospec_data.buildModelsnow usesstore.FromGuildSpec, as the manager API's ensure path already does.Bootstrapfinishes the spec before building the rows: it settles the guild ID, rewrites default agent IDs and derives the state manager config first, so the storedspec_datamatches what is launched.FORGE_STATIC_GUILD_IDnow applies to the spec itself. It only set the stored guild's ID, so the spawned manager and the agent IDs still used the authored ID. This matches what the docs already said.Guilds already stored keep their rows. Ones with every position at 0 read back in ID order, which is also what rusticai-core does after its migration.
Relaunching a guild logged a 409 from the guild manager
Every relaunch logged:
This predates 0.8.0; it is also in logs from 0.7.5.
Cause: the guild manager registers its own row with
ensure_agent, and its spec always differs on a relaunch. Its properties hold the manager API address, which changes whenever Forge gets a new port (Studio picks one on each launch). They also hold the guild spec it was spawned with, which a relaunch rebuilds from the stored rows.Effect: the 409 aborted
launch_guild_agentsbefore it marked the guild STARTING and before it sent the first health report.Changes:
manager_api_token. The guild API returns stored agent specs, so the token was readable by anyone who could read the guild. Each spawn passes the token from Forge's environment, so nothing needs the stored copy.Rows written by earlier versions are rewritten correctly on their next relaunch.
Also included
TestRaftElector_Failoverfix. The 0.8.0 release run failed on this test, which fails about 1 in 30 runs, before and after the raft 1.8.0 upgrade.version.go,pyproject.toml,uv.lockand the TypeScript client.Testing
mark_forwardedandspec_data(with IDs that sort opposite to the spec, so ID order can't pass).FORGE_STATIC_GUILD_IDreaches the spawned manager and the agent IDs.go test ./...passes, and golangci-lint 2.15.0 reports 0 issues.pytest tests/contract) pass.runningand replied.