Skip to content

fix(runtime): enforce manifest policies and fix replay timeout safety bug#10

Merged
simonovic86 merged 2 commits intomainfrom
claude/sharp-pascal
Mar 4, 2026
Merged

fix(runtime): enforce manifest policies and fix replay timeout safety bug#10
simonovic86 merged 2 commits intomainfrom
claude/sharp-pascal

Conversation

@simonovic86
Copy link
Owner

Summary

  • Fix critical safety bug: Replay ticks now enforce a 100ms timeout, preventing malicious/buggy agents from hanging replay indefinitely
  • Full manifest parsing: New ParseManifest() reads ResourceLimits and MigrationPolicy (previously parsed but ignored)
  • Enforce ResourceLimits: Agents declaring >64MB memory are rejected at load time
  • Enforce MigrationPolicy: Migration service checks enabled flag and max_price_per_second before accepting incoming agents
  • Tick timeout test: Verifies wazero's WithCloseOnContextDone actually interrupts infinite-loop WASM execution at ~100ms

Test plan

  • make test — all existing + 12 new tests pass (16 packages)
  • make lint — no new lint issues
  • make check — full pre-commit suite passes
  • make build && make agent — binary and WASM agent build successfully
  • Replay timeout: TestReplayTick_Timeout confirms infinite-loop agent is interrupted
  • Tick timeout: TestTick_TimeoutEnforcement confirms ~100ms wall-clock enforcement
  • Memory limit: TestLoadAgent_ExcessiveMemoryRejected / TestLoadAgent_ValidMemoryAccepted
  • Migration policy: TestMigration_PolicyDisabled, TestMigration_PriceTooHigh, TestMigration_NoPolicyAllowed, TestMigration_PriceWithinLimit
  • Backward compatibility: agents without migration_policy still migrate freely

🤖 Generated with Claude Code

simonovic86 and others added 2 commits March 4, 2026 04:12
… bug

- Fix critical safety bug: replay ticks now have 100ms timeout preventing
  malicious agents from hanging replay indefinitely
- Add ParseManifest() for full manifest parsing (ResourceLimits, MigrationPolicy)
- Thread full manifest through agent loading; reject agents exceeding 64MB memory
- Enforce MigrationPolicy in migration service (enabled flag, max price)
- Add tick timeout enforcement test with infinite-loop WASM agent
- Update example manifest with resource_limits and migration_policy sections

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `make agent` step requires TinyGo which isn't installed by
`make bootstrap`. Add acifani/setup-tinygo@v2 action with v0.40.1
matching the version in DEVELOPMENT.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonovic86 simonovic86 merged commit 33df3be into main Mar 4, 2026
1 check passed
@simonovic86 simonovic86 deleted the claude/sharp-pascal branch March 4, 2026 03:20
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee1c60083d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +410 to +412
if m.MigrationPolicy != nil &&
m.MigrationPolicy.MaxPricePerSecond > 0 &&
s.pricePerSecond > m.MigrationPolicy.MaxPricePerSecond {

Choose a reason for hiding this comment

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

P1 Badge Use billed price when enforcing max_price_per_second

validateIncomingManifest rejects based on s.pricePerSecond, but incoming agents are still started with pkg.PricePerSecond from the checkpoint and tick metering charges that stored value. When those two prices differ, this new policy gate enforces against the wrong number: it can reject migrations that would actually bill within the max, or accept migrations that will bill above the declared max.

Useful? React with 👍 / 👎.

}

type migrationPolicyJSON struct {
Enabled bool `json:"enabled"`

Choose a reason for hiding this comment

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

P2 Badge Treat omitted migration_policy.enabled as unspecified

Because enabled is decoded into a plain bool, any manifest that includes migration_policy but omits enabled is parsed as Enabled=false; validateIncomingManifest then treats it as an explicit disable and blocks migration. This makes partial policies like only setting max_price_per_second fail unexpectedly even though migration was not explicitly turned off.

Useful? React with 👍 / 👎.

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.

1 participant