feat(missions): Continuous Research harvests at launch, and cards launch by clicking
deploy / test (push) Successful in 4m21s
deploy / build (push) Successful in 5m14s

The card shipped in e20b321 could not actually be used. Three things were
missing, each of which failed at a different distance from its cause.

**1. `default_team_template` was parsed and never read.** Every recipe declares
one; `WorkflowRecipe` carries the field; nothing consumed it. A mission created
from a card with no explicitly chosen team was rejected at LAUNCH with "no
team_id, no team_template_id, no config.phase_teams" — one step removed from the
real cause, which is that creation ignored the recipe. Create now resolves it
via `team_templates::get_by_key`, only when the caller named no team of any
kind, so an explicit choice still wins. A test asserts every shipped recipe
names a template that has a `templates/teams/<key>.toml`, because a mismatch
there produces an unlaunchable card.

**2. The harvest ran nowhere.** `harvest_for_mission` existed and nothing called
it. `on_launch` now runs it for `continuous_research` missions, before the
phases start, and threads the blob store through from `main` (the route already
had it on `AppState`; the scheduler needed it). Deliberately non-fatal: a
harvest that fails still starts the phases, because the phase is what reports
whether today was quiet or broken and those must stay distinguishable — but
never silent, so both outcomes log their counts.

**3. Nothing wrote the manifest.** `templates/teams/continuous_research.toml`
has pointed its reader role at `ContinuousResearch/<date>/harvest.jsonl` since it
was authored, and the file did not exist — agents aimed at a path nothing
produced. `run_to_vault` now writes it beside the notes and stages it, but only
for a mission-attributed run. `Harvest` carries the shelved `Paper`s to build
it; re-parsing the notes we had just written would have been a parse of our own
output and one more place for the two to drift.

Also: the blob root. `storage.data_dir` defaults to "./data" and the container's
cwd is `/`, so the server tried to create `/data` as uid 65532 and EVERY shelve
failed with "storage io: Permission denied". The image now creates
/var/lib/clawmates-blobs owned by 65532 so a mounted volume inherits it rather
than arriving root:root. Kept off /var/lib/clawmates-missions on purpose: that
tree is swept, and a paper shelved there would be deleted out from under its own
catalogue note.

Proven end to end on a real mission: 15 candidates, 2 already held, 13 shelved,
0 failed; branch auto-merged as additive-only; manifest on vault `main` with
every documented key. The "already held" counts are the seen-set deduping across
topics within a single run, which is the behaviour the whole design exists for.

The project brief now comes from the mission description — `phase_task_text`
already places it under BRIEF verbatim, so no new field was needed.

346 tests pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
Omar Sobh
2026-08-17 15:05:37 -07:00
co-authored by Claude Opus 5
parent a2d7e3ea92
commit a02e0cba69
10 changed files with 222 additions and 13 deletions
+44
View File
@@ -44,6 +44,7 @@ pub async fn on_launch(
user_id: cm_domain::UserId,
mission_id: Uuid,
node_hub: Option<std::sync::Arc<crate::fleet::NodeHub>>,
blobs: Option<std::sync::Arc<dyn cm_files::BlobStore>>,
) -> Result<Option<Uuid>, String> {
eprintln!("mission_orchestrator::on_launch fired mission_id={mission_id}");
let Some(mission) = cm_db::repo::missions::get(pool, mission_id, workspace_id.as_uuid())
@@ -71,6 +72,49 @@ pub async fn on_launch(
),
}
// A Continuous Research mission harvests BEFORE its agents start.
//
// Finding papers is not agent work: `library::run_to_vault` searches arXiv,
// checks the `corpus_items` seen-set, fetches and verifies each PDF, shelves
// it and writes the catalogue note — deterministically, in seconds. The
// seen-set is the entire reason a recurring mission knows what it already
// covered, and an agent re-searching arXiv would leave it wrong.
//
// Deliberately NON-FATAL. A harvest that fails still lets the phases run,
// because the phase is what reports whether today was quiet or broken, and
// those must stay distinguishable. What is never acceptable is silence, so
// both outcomes are logged with their counts.
if mission.template_kind == crate::continuous_research::TEMPLATE_KIND {
match blobs.as_ref() {
Some(b) => {
let topics = crate::continuous_research::topics_for(&mission.config);
match crate::continuous_research::harvest_for_mission(
pool,
b,
workspace_id.as_uuid(),
mission_id,
&topics,
5,
)
.await
{
Ok(n) => eprintln!(
"mission_orchestrator: continuous research harvest shelved {n} paper(s) for mission {mission_id}"
),
Err(e) => eprintln!(
"mission_orchestrator: continuous research harvest FAILED for {mission_id} (phases still start, and will report an empty day): {e}"
),
}
}
// Not a warning to bury: without blob storage there is nowhere to
// shelve a PDF, so the mission will find an empty manifest and
// correctly report that nothing arrived.
None => eprintln!(
"mission_orchestrator: mission {mission_id} is continuous_research but blob storage is not configured — no harvest, so today's manifest will be empty"
),
}
}
// Provision the per-mission ZeroClaw runtime container (C3).
// Idempotent: returns the endpoint if the container is already
// running. Falls back silently when docker is unreachable so