Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(self-build): give every self-built artefact the shared id join key (#769)

Ruben Lütke21c0c5356362
diff --git a/docs/self-build.md b/docs/self-build.md
index 81c6a2f8e5..267107f257 100644
--- a/docs/self-build.md
+++ b/docs/self-build.md
@@ -125,6 +125,8 @@ ledger; build calls `self_build:<id>`.
| routine | a lead-owned Automations task on a subscription or local seat, no plugin grants, no announcement | schedule before 2/3 of the requests, grounded prompt, nothing outbound, a shadow run | paused |
| agent | `Roster.create` on a subscription or local seat | free name, clean instructions, focus from used tools, shadow answers | paused |
+Every artefact carries the shared join key `id` next to its own fields: the skill name, the routine's task id, the agent id, or the memory notebook's path in the vault (with `entry_id`).
+
**Measure.** A skill run counts as a use, a correction within two minutes as
corrected. A routine run counts, a manual request within a day after a run as
corrected, a failed run as ignored. A turn in a self-built agent's chat
diff --git a/dodaios/self_build/builders.py b/dodaios/self_build/builders.py
index aede3a7922..b0042eb2c1 100644
--- a/dodaios/self_build/builders.py
+++ b/dodaios/self_build/builders.py
@@ -318,7 +318,13 @@ class Builders:
await self._fail(record, "the notebook already says this")
return
entry_id = await asyncio.to_thread(_entry_id, notebook, target, text)
- payload = {"type": "memory", "target": target, "entry_id": entry_id, "text": text}
+ payload = {
+ "type": "memory",
+ "id": await asyncio.to_thread(_memory_path, notebook, target),
+ "target": target,
+ "entry_id": entry_id,
+ "text": text,
+ }
await self._live(record, payload, payload, f"memory:{target}:{entry_id}")
# ------------------------------------------------------------ skill
@@ -378,6 +384,7 @@ class Builders:
raise
payload = {
"type": "skill",
+ "id": promoted.name,
"name": promoted.name,
"slug": slug,
"path": str(promoted.path.parent),
@@ -479,7 +486,12 @@ class Builders:
)
task = task.model_copy(update={"tags": (*task.tags, PROVENANCE)})
task_id = await create_routine(store, scheduler, task)
- payload = {"type": "routine", "task_id": task_id, "agent_id": lead.agent_id}
+ payload = {
+ "type": "routine",
+ "id": task_id,
+ "task_id": task_id,
+ "agent_id": lead.agent_id,
+ }
await self._live(record, payload, payload, f"task:{task_id}")
# ------------------------------------------------------------ agent
@@ -515,7 +527,12 @@ class Builders:
if not created:
await self._fail(record, f"the name {agent.name!r} belongs to an existing agent")
return
- payload = {"type": "agent", "agent_id": agent.agent_id, "name": agent.name}
+ payload = {
+ "type": "agent",
+ "id": agent.agent_id,
+ "agent_id": agent.agent_id,
+ "name": agent.name,
+ }
await self._live(record, payload, payload, f"agent:{agent.agent_id}")
# ------------------------------------------------------------ undo, dormant, restore
@@ -661,6 +678,16 @@ class Builders:
# ------------------------------------------------------------------ helpers
+def _memory_path(notebook: Any, target: str) -> str:
+ """The notebook file an entry lives in, relative to the vault (the badge's join key)."""
+ path = Path(notebook.paths()[target])
+ vault = Path(getattr(notebook, "_vault", path.parent))
+ try:
+ return path.relative_to(vault).as_posix()
+ except ValueError: # a notebook outside the vault: its full path is the key
+ return path.as_posix()
+
+
def _entry_id(notebook: Any, target: str, text: str) -> str:
for entry in notebook.entries().get(target, []):
if entry.text == text:
diff --git a/tests/unit/self_build/test_self_build_loop.py b/tests/unit/self_build/test_self_build_loop.py
index c154444149..550f953749 100644
--- a/tests/unit/self_build/test_self_build_loop.py
+++ b/tests/unit/self_build/test_self_build_loop.py
@@ -335,6 +335,7 @@ async def test_weekly_request_becomes_one_proven_routine_on_trial(world: Any) ->
# with no plugin grants and no spoken announcement.
assert len(world.scheduler.specs) == 1
spec = world.scheduler.specs[record.artefact["task_id"]]
+ assert record.artefact["id"] == record.artefact["task_id"]
assert "self-built" in spec.tags and "agent:jarvis" in spec.tags
assert spec.action.provider == "sub-seat"
assert spec.action.plugin_grants == ()
@@ -436,6 +437,7 @@ async def test_repeated_request_becomes_one_proven_live_skill(world: Any) -> Non
assert record.state == State.TRIAL, record.note
assert "replay caught 3 of 3" in record.proof["detail"]
skill = world.registry.get(record.artefact["name"])
+ assert record.artefact["id"] == skill.name
# ADR-0043: proven by the replay, so live (active) instead of a draft.
assert skill.state.value == "active"
assert "self-built" in skill.frontmatter.tags
@@ -534,6 +536,7 @@ async def test_repeated_correction_becomes_a_memory_entry(world: Any) -> None:
(opened,) = await world.loop.run_queue()
record = await _settle(world, opened.id)
assert record.kind == Kind.MEMORY and record.state == State.TRIAL, record.note
+ assert record.artefact["id"] == "society/jarvis/MEMORY.md"
texts = [e.text for e in world.notebook.entries()["memory"]]
assert "The user's office is the Berlin office, not Munich." in texts
await world.service.undo_build(record.id)
@@ -582,6 +585,7 @@ async def test_a_domain_of_needs_proposes_an_agent_and_builds_it_on_accept(world
record = await _settle(world, accepted.id)
assert record.state == State.TRIAL, record.note
octo = await world.roster.get(record.artefact["agent_id"])
+ assert record.artefact["id"] == octo.agent_id
assert octo.name == "Octo" and octo.provider == "sub-seat"
assert octo.focus == ["mcp:github/list_runs", "mcp:github/list_issues"]
# Talking to it counts.