Worker factory must hand minted worker the original intent via factory_init skill #116

Closed
opened 2026-04-10 19:40:37 +00:00 by Mark · 3 comments
Owner

Architecture Violation

worker_factory provisions workers but never hands off the original intent. The comment at line 370 says "Intent will be reissued for claiming" but this never happens.

Current Flow (Broken)

mesh_node receives intent "write_article"
→ No workers for write_article
→ Falls back to worker_factory bidding
→ worker_factory wins bid
→ Provisions ephemeral_worker with CAPABILITIES=writer
→ Returns "Intent will be reissued for claiming"
→ Nothing happens - intent never reaches minted worker

Correct Flow

mesh_node receives intent "write_article"
→ No workers for write_article
→ Emits "provision_worker" intent with payload:
    - original_intent: "write_article"
    - target_capability: "writer"
→ worker_factory bids on provision_worker intent
→ worker_factory wins bid
→ worker_factory executes spawn_workers skill
→ Provisions ephemeral_worker with CAPABILITIES=writer
→ Uses factory_init skill to hand minted worker the original intent
→ Minted worker executes original intent directly
→ Minted worker emits result.committed

Required Fix

Implement factory_init skill in worker_factory:

  1. After provisioning - Call factory_init skill
  2. Direct handoff - Pass original intent to minted worker
  3. Not backplane re-emission - Direct execution, not re-bidding
  4. Minted worker executes - Worker runs, emits result

Implementation

# In worker_factory/run.py execute()

# After provisioning worker:
minted_worker_id = provisioning_result["worker_id"]

# Use factory_init skill to hand off intent
init_result = self.skills["factory_init"].execute(
    worker_id=minted_worker_id,
    original_intent=self.intent
)

# Minted worker now has intent, will execute
return {
    "ok": True,
    "provisioned_worker": minted_worker_id,
    "intent_handoff": "complete"
}

factory_init Skill Contract

skill: factory_init
input_schema:
  - worker_id: ID of minted worker
  - original_intent: Intent to hand off
output_schema:
  - handoff_status: "complete" or "failed"
  - execution_started: bool

Impact

Without this fix:

  • Worker spawning produces workers that never execute
  • Intents hang after provisioning
  • Factory pattern broken
  • Architecture violation propagates

References

  • capabilities/_muscle/worker_factory/run.py:370 - "Intent will be reissued" comment
  • docker/mesh_node.py - Fallback routing logic
  • AGENTS.md - Factory pattern section
  • docs/reference/FACTORY_PATTERN.md - Factory specification
## Architecture Violation worker_factory provisions workers but never hands off the original intent. The comment at line 370 says "Intent will be reissued for claiming" but this never happens. ## Current Flow (Broken) ``` mesh_node receives intent "write_article" → No workers for write_article → Falls back to worker_factory bidding → worker_factory wins bid → Provisions ephemeral_worker with CAPABILITIES=writer → Returns "Intent will be reissued for claiming" → Nothing happens - intent never reaches minted worker ``` ## Correct Flow ``` mesh_node receives intent "write_article" → No workers for write_article → Emits "provision_worker" intent with payload: - original_intent: "write_article" - target_capability: "writer" → worker_factory bids on provision_worker intent → worker_factory wins bid → worker_factory executes spawn_workers skill → Provisions ephemeral_worker with CAPABILITIES=writer → Uses factory_init skill to hand minted worker the original intent → Minted worker executes original intent directly → Minted worker emits result.committed ``` ## Required Fix Implement factory_init skill in worker_factory: 1. **After provisioning** - Call factory_init skill 2. **Direct handoff** - Pass original intent to minted worker 3. **Not backplane re-emission** - Direct execution, not re-bidding 4. **Minted worker executes** - Worker runs, emits result ## Implementation ```python # In worker_factory/run.py execute() # After provisioning worker: minted_worker_id = provisioning_result["worker_id"] # Use factory_init skill to hand off intent init_result = self.skills["factory_init"].execute( worker_id=minted_worker_id, original_intent=self.intent ) # Minted worker now has intent, will execute return { "ok": True, "provisioned_worker": minted_worker_id, "intent_handoff": "complete" } ``` ## factory_init Skill Contract ```yaml skill: factory_init input_schema: - worker_id: ID of minted worker - original_intent: Intent to hand off output_schema: - handoff_status: "complete" or "failed" - execution_started: bool ``` ## Impact Without this fix: - Worker spawning produces workers that never execute - Intents hang after provisioning - Factory pattern broken - Architecture violation propagates ## References - capabilities/_muscle/worker_factory/run.py:370 - "Intent will be reissued" comment - docker/mesh_node.py - Fallback routing logic - AGENTS.md - Factory pattern section - docs/reference/FACTORY_PATTERN.md - Factory specification
Author
Owner

🟡 PARTIALLY ADDRESSED — M009/S02: Capability Resolution in EphemeralWorker

Commit 705635f fixes one piece of the handoff: ephemeral_worker._execute_intent() now resolves intent-type capabilities (e.g. writing_task) to primitive IDs (e.g. writer_contract) before calling self.loader.get().

What was fixed

  • _execute_intent() calls resolve_primitive_for_intent(capability) before loading the contract
  • Prevents "Contract not loaded" errors when the factory hands off an intent-type instead of a primitive ID

What remains

  • The full factory_init skill contract (as described in this issue) is not yet implemented
  • After S02, the minted worker can load the right contract, but the original intent isn't directly handed off via factory_init
  • Comment at worker_factory/run.py line 370 ("Intent will be reissued for claiming") still reflects the current broken behavior

Next

  • S03: Writer execution produces actual LLM output (needs vLLM integration)
  • S04: Full E2E test with real Redis/ledger/vLLM
## 🟡 PARTIALLY ADDRESSED — M009/S02: Capability Resolution in EphemeralWorker Commit 705635f fixes one piece of the handoff: `ephemeral_worker._execute_intent()` now resolves intent-type capabilities (e.g. `writing_task`) to primitive IDs (e.g. `writer_contract`) before calling `self.loader.get()`. ### What was fixed - `_execute_intent()` calls `resolve_primitive_for_intent(capability)` before loading the contract - Prevents "Contract not loaded" errors when the factory hands off an intent-type instead of a primitive ID ### What remains - The full `factory_init` skill contract (as described in this issue) is not yet implemented - After S02, the minted worker can *load* the right contract, but the original intent isn't directly handed off via `factory_init` - Comment at worker_factory/run.py line 370 (`"Intent will be reissued for claiming"`) still reflects the current broken behavior ### Next - **S03**: Writer execution produces actual LLM output (needs vLLM integration) - **S04**: Full E2E test with real Redis/ledger/vLLM
Author
Owner

⏸ Needs Decision

What needs to be decided?

  • Is this issue still relevant? If yes, remove the blocked:needs-decision label to route back to triage.

Blocking factors:

  • Didn't meet auto-approve criteria — scope=small, risk=low, spec=partial

Scope: small Risk: low Spec: partial Type: bug
Summary: Worker factory provisions workers via provision_worker but the original intent (e.g. 'write_article') never reaches the minted worker — it's returned in the factory response but nobody acts on it.
Suggestion: Add a factory_init internal function/skill in worker_factory that, after registering a new worker, directly spawns execution of the original_intent on the minted worker's capability channel — reuses existing WorkerSpawner or ephemeral worker path instead of re-emitting via backplane. The original_intent already flows through BidManager claim payloads and worker_factory responses; the handoff action is what's missing.
Rationale: Scope=small: only worker_factory/run.py needs the new skill logic and the provision_worker_v1 orchestration needs to invoke it after factory returns. Risk=low: data already flows (original_intent field in claim payloads, line 407 of worker_factory/run.py), the fix is additive and doesn't alter existing provisioning. Spec=partial: AGENTS.md mandates workers execute intents and factories define workers only, which this upholds, but factory_init as a named skill isn't documented. Type=bug: the current flow dead-ends after provisioning — the comment 'Handoff intent to spawned worker' at line 408/409 of run.py confirms this was intended but never implemented.

To unblock: Remove the blocked:needs-decision label. The triage will apply the appropriate outcome based on your choice above.

## ⏸ Needs Decision **What needs to be decided?** - **Is this issue still relevant?** If yes, remove the `blocked:needs-decision` label to route back to triage. **Blocking factors:** - **Didn't meet auto-approve criteria** — scope=small, risk=low, spec=partial --- **Scope:** small **Risk:** low **Spec:** partial **Type:** bug **Summary:** Worker factory provisions workers via provision_worker but the original intent (e.g. 'write_article') never reaches the minted worker — it's returned in the factory response but nobody acts on it. **Suggestion:** Add a factory_init internal function/skill in worker_factory that, after registering a new worker, directly spawns execution of the original_intent on the minted worker's capability channel — reuses existing WorkerSpawner or ephemeral worker path instead of re-emitting via backplane. The original_intent already flows through BidManager claim payloads and worker_factory responses; the handoff action is what's missing. **Rationale:** Scope=small: only worker_factory/run.py needs the new skill logic and the provision_worker_v1 orchestration needs to invoke it after factory returns. Risk=low: data already flows (original_intent field in claim payloads, line 407 of worker_factory/run.py), the fix is additive and doesn't alter existing provisioning. Spec=partial: AGENTS.md mandates workers execute intents and factories define workers only, which this upholds, but factory_init as a named skill isn't documented. Type=bug: the current flow dead-ends after provisioning — the comment 'Handoff intent to spawned worker' at line 408/409 of run.py confirms this was intended but never implemented. **To unblock:** Remove the `blocked:needs-decision` label. The triage will apply the appropriate outcome based on your choice above.
Author
Owner

Partially addressed by 705635f — removing blocked:needs-decision. Open if more work needed, close if the partial fix is enough.

Partially addressed by 705635f — removing blocked:needs-decision. Open if more work needed, close if the partial fix is enough.
Mark closed this issue 2026-08-12 12:33:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/mesh-seed#116
No description provided.