Skip to content

fix: code quality, security hardening, and test coverage#9

Merged
simonovic86 merged 2 commits intomainfrom
claude/cool-solomon
Mar 4, 2026
Merged

fix: code quality, security hardening, and test coverage#9
simonovic86 merged 2 commits intomainfrom
claude/cool-solomon

Conversation

@simonovic86
Copy link
Copy Markdown
Owner

Summary

Comprehensive code review fixes addressing security, resource safety, and test coverage across the runtime.

Changes

Security & Resource Safety

  • WASM hash verification: Reject migrations with missing or malformed hashes upfront
  • P2P timeouts: Add 10s read deadline to ping handler and 30s per-peer bootstrap timeout
  • Manifest path derivation: Safe string handling with strings.HasSuffix/TrimSuffix (no panic)
  • Mutex protection: Lock SetNodeCapabilities write access in migration service
  • Sentinel errors: Use errors.Is() for ErrCheckpointNotFound comparison

Resource Cleanup & Correctness

  • Replay engine: Add defer replayEngine.Close() in main tick loop
  • LatestSnapshot: Return value copy to prevent pointer invalidation on eviction
  • History(): Return slice copy to prevent external mutation
  • Hostcall registry: Wrap instantiation errors with context
  • Log emit: Separate oversized message warning with clearer logging
  • Names() output: Sort capability names for deterministic iteration

Code Organization

  • Extract loadManifestData() helper in CLI entry point
  • Unify manifest loading logic between local and migration paths

Tests & CI

  • CLI tests: cmd/igord/main_test.go covering manifest loading and escalation policy
  • P2P tests: internal/p2p/node_test.go covering bootstrap, ping round-trip, error cases
  • CI: Add WASM agent build step to pipeline

Documentation

  • Update CLAUDE.md: Phase 3 (Autonomy) complete, Phase 4 (Economics) next
  • Expand IMPLEMENTATION_STATUS.md with runtime optimizations and hardening matrix
  • Update MIGRATION_PROTOCOL.md: Remove unused StartTime field from AgentStarted
  • Sync protocol message definition: Remove StartTime from pkg/protocol/messages.go

simonovic86 and others added 2 commits March 4, 2026 03:19
- Reject migration when WASM hash length != 32 instead of silently
  skipping verification (security: prevented hash bypass)
- Use errors.Is for sentinel error comparison in checkpoint loading
- Guard manifest path slicing with strings.HasSuffix to prevent panic
  on non-.wasm paths
- Close replay engine compilation cache to prevent memory leak
- Return TickSnapshot copy from LatestSnapshot to prevent pointer
  invalidation after replay window eviction
- Add 10s read deadline on p2p ping handler and 30s per-peer timeout
  on bootstrap to prevent connection stalls
- Protect nodeCapabilities with RWMutex to prevent data race between
  SetNodeCapabilities and handleIncomingMigration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Sort Names() output to match docstring contract
- Return slice copy from History() to prevent internal state mutation
- Wrap error in hostcall registry instantiation
- Warn on oversized log_emit instead of silent drop
- Remove unused AgentStarted.StartTime field (code + docs)
- Add tests for internal/p2p/ (node lifecycle, ping, bootstrap)
- Add tests for cmd/igord/ (manifest loading, escalation policy)
- Add WASM agent build step to CI workflow
- Update IMPLEMENTATION_STATUS.md with optimizations and hardening tables
- Update CLAUDE.md to reflect Phase 3 completion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonovic86 simonovic86 merged commit 771c781 into main Mar 4, 2026
1 check failed
@simonovic86 simonovic86 deleted the claude/cool-solomon branch March 4, 2026 02:38
Copy link
Copy Markdown

@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: 00e01d0959

ℹ️ 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 thread .github/workflows/ci.yml
Comment on lines +52 to +53
- name: Build WASM agent
run: make agent
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Install TinyGo before running make agent in CI

This new step will fail on runners that do not already have TinyGo installed (including typical ubuntu-latest images), because make agent exits with an error when tinygo is missing (Makefile target agent checks which tinygo and scripts/bootstrap.sh only treats TinyGo as optional). As written, the workflow now adds a hard dependency without provisioning it, so CI can fail even after all prior checks pass.

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