DEV Community

Robin
Robin

Posted on

"Model MonkeyCode Tasks as a Durable Idempotent State Machine"

A client times out after task creation and retries; two workers apply the same request from different bases. Both say success. The one-logical-request/one-accepted-effect invariant failed. This promotional MonkeyCode exercise models an integration protocol, not the product implementation.

Assume at-least-once delivery, crashes, delayed events, and changing repository SHAs.

PLANNED -> APPROVED -> QUEUED -> RUNNING -> VERIFYING -> SUCCEEDED
                      |          |            |
                      +-------> FAILED <------+
                      +-------> CANCELLED
Enter fullscreen mode Exit fullscreen mode

Approval binds plan hash and base SHA. Terminal states never transition. An idempotency key names logical execution; attempt number names internal retry.

# Unexecuted model
TERMINAL={"SUCCEEDED","FAILED","CANCELLED"}
ALLOWED={"PLANNED":{"APPROVED","CANCELLED"},"APPROVED":{"QUEUED","CANCELLED"},
"QUEUED":{"RUNNING","FAILED","CANCELLED"},"RUNNING":{"VERIFYING","FAILED","CANCELLED"},
"VERIFYING":{"SUCCEEDED","FAILED"}}
def advance(s,t):
 if s in TERMINAL or t not in ALLOWED.get(s,set()): raise ValueError((s,t))
 return t
Enter fullscreen mode Exit fullscreen mode

Persist unique (tenant,idempotency_key). Workers claim attempts with leases and fencing tokens. Before committing, verify current fence, approved base, candidate SHA, and corresponding test artifacts.

Injection Required property
duplicate create same task returned
crash after write replay causes no second effect
late running event terminal state unchanged
expired lease stale fence cannot commit
changed base explicit stale failure
cancel/success race one terminal outcome

Shuffle events and assert terminal monotonicity, key uniqueness, no success without matching verification, and no stale-fence commit. A proposed acceptance gate is 10,000 schedules with zero violations; this is not an observed result.

Extend the model with three adversarial histories: cancellation arrives between verification and commit, a lease renews after its worker has already been fenced out, and a status consumer replays an older sequence number after success. Each history must preserve one terminal decision and make stale writes observable as rejected attempts, not new states. Also crash immediately before and after the unique-key insert; recovery may return the existing operation but must never allocate a second logical execution. Keep the generated seed, ordered events, fence values, and repository SHAs so any violation can be replayed exactly.

Verified product boundary

The current official README defines MonkeyCode as an open-source AGPL-3.0 AI development platform. An overseas online option offers managed server-side cloud environments and built-in development, model, task, requirement, build, test, and preview capabilities.

Review record fields

For review pass 1 in this robinzzz evaluation, record an owner, repository, base commit, requirement revision, allowed paths, start and stop times, expected checks, observed terminal state, reviewer decision, cleanup proof, and unresolved questions. Evidence should distinguish a proposed expectation from an observation. Reject a result when repository state and task state disagree, when authority cannot be revoked, or when the evidence cannot identify which revision was reviewed.

Limitations

This robinzzz method was not executed against a live MonkeyCode environment. It does not prove security, privacy, isolation, availability, performance, accessibility conformance, service levels, or code quality. Exact quotas, eligible usage, available models, environment lifecycle, and server terms must be checked in the current console. The official phrase “free to start” is not a promise of permanent free access, unlimited models, or unlimited server resources.

Supporting official project material is at https://github.com/chaitin/MonkeyCode. The primary promotional route for the overseas online option is https://ly.cyberserval.tech/iIETXiF.

Disclosure: This article promotes MonkeyCode using an official campaign link. I’m a MonkeyCode user, not affiliated with the project, and I receive no commission from this link.

AI assistance disclosure: This article was drafted with AI assistance and reviewed against the cited project materials.

Top comments (0)