Skip to content

Latest commit

 

History

History
513 lines (499 loc) · 78.4 KB

code-map.md

File metadata and controls

513 lines (499 loc) · 78.4 KB

Code map

Documentation index. For contributors and coding agents: which module owns what, where new code goes, and the checks that keep it that way. How the parts work together: Architecture.

The app is a modular monolith in the making. assistant.py (the service, python3 assistant.py serve) and the dashboard (dashboard.html, served as one page, with most of its script in parts in dashboard/) still hold most of the code. Domains move out of them one at a time, each in its own pull request, with the code moved as is. Until a domain has moved, its code stays where this map says.

Modules and the tables they own

Every module is flat at the repository root, apart from one package: machine/, where the code moving out of assistant.py goes (machine/store/, machine/sources/, machine/web/, ...). Don't add other packages, and don't name a root folder after a standard library module (http/ would hide http.server). assistant.py stays the entry file (python3 assistant.py serve) and keeps the names it hands out for the code and tests that use them. A table belongs to the module that creates it, in that module's ensure(db) (or, for assistant.py, in Store.__init__). Only the owner writes it; other modules call the owner's functions.

domain modules tables (owner)
service core assistant.py (the entry, main()), machine/main.py (Store, App and its mixins), machine/store/todo_moves.py (transition(): a to-do's move from one status to another, checked against todo_states.MOVES and kept in its history), machine/store/send_later.py (a message scheduled with Send later, until it goes to the outbox or is taken back; machine/app/send_later.py its step and fresh read), machine/stamps.py (change counters per table, so a request's answer is kept until one of its tables changes), machine/store/ahead_hold.py (the drafts ahead that wait while reviews are far behind; machine/app/ahead_hold.py its step), machine/store/event_versions.py (what a signal said before its source changed it; deleted or cleared with it), source_quotes (a message deleted at its source: the lines learnings quoted from it go, no table), machine/store/coverage_spans.py (which periods of each account were read, and what was set aside or left out by what), machine/store/schema_version.py (the database's schema version, PRAGMA user_version, and the steps that brought it there), machine/store/list_refs.py (the ids in six JSON lists of message and account ids as rows, one side table each, kept by trigger, for "what points at X") schema_migrations, ref_* (list_refs), ahead_holds, events (sealed, the only writer), event_versions (sealed), coverage_spans, coverage_span_counts, suggestions (to-dos), todo_moves, decisions, deliveries, preparations, action_jobs, analyses, profile_runs, facts, promises, voices, checkpoints, faults and the rest of its 54, data_stamps
message sealing message_seal, message_keyring, network_crypto, machine/store/plain_keys.py (once: the routing keys that became plain, in the messages kept before) event_search, plain_key_pass
graph and CRM graph, forgotten_people (people deleted permanently, kept as keyed hashes: forgotten_people, forgotten_salt), chat_forgotten (the same, in the Telegram and Signal stores' own state), graph_joins (which identities a name may join, no table), graph_show (an edit on its record's page at once, before the next build, no table), graph_fold (a merge makes one record at once, before the rebuild, no table), graph_board_reviews (a review's board checks: sorting, fits, a new board's look through the history, Add or Leave out with Undo; writes graph's board tables), crm, crm_fields, crm_import, crm_fixes, enrichment, ms_photos (photos of colleagues and Outlook contacts through Microsoft Graph), leaddelta_people (the owner's LeadDelta connections, kept as listed and matched to people already in the Graph), own_addresses, bounces, verified_sender (whether the mail service verified a mail's sender address; no table), places, signatures, person_summary, person_birthday (a person's one birthday, kept as a fact, no table), project_about (a project's description), project_split (Split up: one project into two to four, with undo; a catch-all into one per counterpart that answered), project_spread (catch-all projects: a review's label that shares nobody with one is kept off, and its page offers Split up or Keep as one), project_success (a project's done-when, its proof and blocker), project_stall (once a week, a next step for a few projects that went quiet with nothing on them), opportunities (once a week, off by default: work that only shows across separate threads), todo_org (the organization a to-do is about, no table), project_org_checks (a review keeps or drops the organization the Machine gave a project from its people), knowledge (what every surface asks about a record, no table), record_log (a record's Recent changes, no table), change_log (what a write on a role, organization, name, relation, merge, fact or the owner's details replaced, kept first), graph_updates (what The Machine updated today, for the Graph lists, no table), machine/store/graph_history.py (older mail and meetings, counted toward closeness and who knows whom), machine/store/graph_identifiers.py (which person has an identifier, an index), machine/store/entities.py (a permanent id per person and organization with entity_ids, off by default; graph_publish writes graph_nodes.entity_id for it, the Store owns the id columns next to names, ENTITY_REFS and PROJECT_REFS), mail_senders (which senders are a system, never a person; who a message went to, whatever way its source keeps to) graph_*, projects, boards, board_*, person_*, org_* (graph); entities, entity_identifiers, entity_assertions, entity_returns (machine/store/entities.py); record_*, org_aliases (crm); changes (change_log); crm_fields, crm_tags, crm_values; person_facts, enrich_prefs, photo and logo tries (enrichment); own_*; email_bounce*; person_summar* (person_summary); project_success; project_stall_* (project_stall); opportunity_* (opportunities); project_org_checks; project_splits (project_split); project_spread_kept (project_spread); leaddelta_people (leaddelta_people); ms_photo_* (ms_photos), mail_hidden, mail_shown
follow-ups follow_ups, task_invites, task_pages follow_up_*, task_pages
task apps task_sync (which task in Todoist, Microsoft To Do or Google Tasks is which to-do; machine/app/task_sync.py brings the owner's tasks in, Store.follow_tasks follows them, connectors/todoist.write, connectors/ms_todo.write and connectors/google_tasks.write copy and close to-dos there, task_sync.outgoing picks what goes, task_sync.on_page answers The Machine: Tasks extension, extension/tasks/) task_links
trips and events note_pages (trips and events kept as pages of lines, sync with what an owner changed before on top; also makes the tables of the Notes feature that is gone, whose rows stay untouched), note_pages_app (NotesApp: the Calendar's bands and a trip's or an event's page), trip_notes and bookings (trips from booking mail), machine/app/trips.py (TripsApp: booking mail without structured data read by a small model call), event_notes (events from ticket mail) note_pages, note_page_lines, note_page_links, trip_bookings, trip_pending, trip_state; kept from Notes, unread: section_topics, section_state, topic_routes, topic_state, topic_aliases, note_writeups, folder_overviews, memory_seed_pages, memory_seed_state
recurring to-dos recurring, recurring_app, public_holidays recurring_series, recurring_cards, recurring_offers
grant history grant_history (what was allowed and when, appended by every writer of a permission; a record nothing reads to decide: intelligence.md) grant_history, action_grants, grant_lists_key
routines routines, routines_app, routine_recipe (the reading part the Machine writes for itself, checked as read-only every run, no table), routine_imports (old OpenClaw jobs as suggestions, read-only, no table), openclaw_records (OpenClaw's own skills and the jobs routine_imports does not take, kept read-only as records once a day; the skill rows go through skills.keep_record), routine_patterns (suggestions from the owner's own activity, plain code, no table), routine_changes (a lasting change to a routine learned from a note on one of its to-dos, saved on the owner's confirm), routine_templates (ready-made routines added with one tap, no table), machine/todo_kinds (the to-do kinds that behave unlike an ordinary to-do, such as a cleanup or the digest: delivery, the card, decisions and the view ask it instead of naming each kind's module; no table), routine_offers (offers a mail cleanup template above the to-dos when a lot of that mail comes in), mail_cleanup, mail_cleanup_app (their newsletter and spam to-dos), unsubscribe_page (a list's unsubscribe page, done in the Machine's own browser after the owner's confirm, no table), birthdays, birthdays_app (the Birthdays template: close contacts' birthdays today, no table), birthdays_facebook, birthdays_facebook_app (its Import birthdays from Facebook to-do: read once on the owner's tap, saved on their OK), reading_digest, reading_digest_app (the Daily digest template: newsletter picks for the owner's interests, one capped model call a day), subscriptions, subscriptions_app (the Subscriptions and trials template: recurring charges and trial, renewal and price notices in plain code, one model call only over candidates, Keep or Cancel per row), stay_in_touch, stay_in_touch_app (the Stay in touch template: people the owner picked, a nudge only with a long gap and something concrete to say, at most two a week; plain code shortlists, one small model call over the shortlisted only), secondhand, secondhand_app (the Second-hand finds template: a second-hand search read in the Machine's own browser, cheap filters in plain code, one capped model call per new listing), reorder, reorder_app (the Reorders template: Shopify order mail read once by one small model call, a quiet to-do per item bought at a steady pace when it is nearly due again; it opens the store, never buys) routines, routine_runs, routine_changes, mail_cleanup_items, mail_cleanup_senders, routine_offers, facebook_birthdays, digest_items, digest_interests, digest_spend, subs_items, subs_kept, subs_state, touch_people, secondhand_searches, secondhand_seen, secondhand_spend, secondhand_todos, reorder_mail, purchases, reorder_todos, openclaw_jobs, openclaw_import_state
do it and preparation next_actions, machine/new_post (the one step that posts a new post, told wherever a run goes another way, no table), machine/draft_marks (what a draft's marks say, in any language: a placeholder left in, a sentence's end, a closing's name, no table), machine/step_labels (what a step's button label may hold, no table), machine/hand_back (a step a refused or held save had, given back when the run's next save lost it, no table), preparation_state, machine/run_status.py (a running review's or preparation's status checks through one long-lived helper, preparation-status-service.mjs, falling back to preparation-run.mjs; no table), gap_note (what isn't known about a to-do's people, no table), agent_jobs, agent_remote, agents_app, codex_signin (Codex's device sign-in, no table), calendar_writes, calendar_app, doc_writes, meeting_writer, meeting_notes, browser_login, browser_viewer, meeting_prep (a briefing to-do before a meeting with people from outside, or a team meeting that continues earlier notes), calendar_clashes (a work meeting that overlaps a personal one, or the other way around), machine/store/proposals.py (the proposal log: every version of a to-do as it was put forward, and which one was shown), machine/store/action_outcomes.py (outcomes with proof: what came of a send, a close or a promise, with the rows it rests on, and every state an outbox job passed through), machine/store/action_effects.py (what a sent action did in the world: its receipt and effect key, so a second draft for the same effect is recognized) preparation_runs, preparation_calls, agent_*, meeting_writes, meeting_moves, meeting_preps, meeting_prep_web, calendar_clashes, proposal_revisions, proposal_evidence, outcomes, outcome_links, outcome_reply_scan, action_states, action_effects
reviews and learning learning_loop, missed_work, missed_work_app, bring_in, bring_in_app, history_notes (how the owner works, from their own older email, once per mailbox; facts with source history:email), history_notes_app, memory_import (another assistant's answer read, secrets out, compared with what is learned; no table), memory_import_app, corrections, corrections_app, learnings, team_learnings, fleet_learnings, embeddings, gbrain, gbrain_app, memory_use (the shape of a piece of memory in a prompt, and the log of what prompts read), fact_links (which record a fact names, read from its words, read-only, no table), fact_ties (the one-time pass that ties loose facts to who they are about, one small turn per batch), notes_people (facts kept from the owner's notes go on who they are about, in the owner's words, with a birthday for the Birthdays routine; one small turn per batch kept, with Undo), contact_facts (a phone or email the owner states for one person goes on their Graph record, merging a same-name double, with Undo; no table), machine/store/review_saves.py (a review's to-do saves, and the ones that failed), machine/store/review_whys.py (why a review made no to-do of a message, sealed in analyses.whys, apart from its items that SQL reads), machine/store/first_pass.py (automated signals sorted by a small model before a review; what clearly needs nothing is set aside; machine/app/first_pass.py makes the call), machine/app/same_item.py (whether a fact or promise read again from a note or message is one the owner removed from it, in other words: one small-model call with machine/prompts/same_item.py, set on the Store as same_item; no table), machine/app/batch_review.py (a review run as batched calls instead of an agent turn, for every run with nothing to look up; its prompt is machine/prompts/batch_review.py; no table) learning_changes, learning_claims, learning_change_signals, learning_outdated, fact_overturns, missed_audit*, bring_in_*, team_learning*, fleet_learn*, event_vector*, gbrain_*, memory_use, review_save_failures, first_pass
chat, talk, voice chat_model, chat_files, file_text, talk_live, readback (whether Talk read a draft out, no table), voice_input, voice_worker, help_chat, help_search (finds the help passages for a question, no table; people's words in other languages in help_words.json), search_ask (Ask from search, no table) chat_models, chat_fast_sessions, chat_files, talk_lines, draft_seen (talk_live), voice_prefs
WhatsApp photos and voice notes whatsapp_images (Read photos and voice notes: which chats, keeping a photo, what it says joined to its message), whatsapp_voice (a voice note written down through OpenClaw's speech-to-text, only the text kept, joined to its message), whatsapp_images_app whatsapp_photos, whatsapp_photo_prefs, whatsapp_voice_notes, whatsapp_media_left_out
fleet and network fleet, fleet_log (the Fleet log, and the owner's decisions on requests kept past their notices), fleet_brief (the brief by plain code from cleaned facts: assemble_brief, who is on separate threads with the same people, and its ranked lines; no table), fleet_rounds (a background round's reads once, and its slow parts logged; no table), fleet_promises (the open promises a meeting-context answer may count: its accounts, the Team Graph gate, a Work Fleet's side; no table), fleet_requests, fleet_reviews, fleet_trust, shared_graph, shared_graph_private (who is on a thread: its conversation, automated mail, someone kept private; no table), shared_graph_takeback (take-backs while sharing is off or paused, no table), shared_graph_since (a publish reads again only what could have changed; no table), shared_graph_boards (Shared Boards: a teammate's board laid out as on its owner's, no table), shared_graph_logos (organization logos: LinkedIn addresses, and logos from their own site as small pictures; no table), logo_image (those pictures: decoded and drawn again, pixels only), shared_graph_photos (person photos from work sources as small pictures, the same way; no table), jpeg_image (a small baseline and progressive JPEG decoder for them), shared_graph_app, shared_connectors, network, friends, family, family_done, family_questions (a family member's question to this Machine: its path, limits and Activity lines), family_question_check (the turn that judges the question alone; no table), family_question_sources (what an answer may come from, its drafting turn and the checks on it; no table), family_question_always (what lets one go by itself, with its second turn; no table), family_question_links (which messages may be on the same matter, and which mail can be believed; no table), family_question_facts (the turn that says how the matter stands, and whether the answer is that; no table), family_question_hold (the hold before it goes; no table), contact_share, discovery, meet, meet_app, security_levels, meet_link (a link to pick a time, for someone without a Machine), family_invites, handoff_mail (a Work to-do handed off by email) fleet_*, network_request_nodes (fleet); fleet_reviews (fleet_reviews); fleet_questions (family_questions); share_*, team_* (shared_graph); network_* (network, discovery); meet_* (meet); contact_*; security_prefs, family_invite_*, handoff_mail*
skills, support skills, skills_app, learned_skills and learned_skills_app (skills learned from Do it tasks; their drafts wait in learned_drafts), support, support_app, bug_queue, error_feed, error_words (the words, error types and services an error report's message may have; the control plane runs a byte-for-byte copy, no table), help_topics skills, skill_hints, error_feed*, help_topics
connected AIs (MCP) ai_access, ai_app, meeting_titles (a meeting's title for a connected AI: without codes or dial-ins, none for a meeting kept private; no table), ai_learnings (get_learnings and the brief, no table), ai_experience (get_todo's history and why_not, no table), pairing (one-click pairing, no table), ai_reach (the address's certificate and dial-back, no table), ai_events (MCP Events: subscriptions, signed webhook delivery) ai_clients, ai_connections, ai_codes, ai_tokens, ai_activity, ai_writes, ai_ledger (content-free, kept for good); ai_events: ai_event_subs, ai_event_seen, ai_event_outbox, ai_event_verified
browser history machine/sources/browser_history (the browser extension's pairing codes, tokens, upload, rules and sync), machine/app/browser_history (its dashboard actions, no table), machine/store/browsing_refs (the one place that keeps browsing out of evidence and links: readers drop it by the event's kind, writers are refused, triggers on the tables and lists that hold one; no table) browser_devices, browser_inbox
obsidian machine/sources/obsidian (an Obsidian vault the desktop app sends: paths checked, notes as events, deletes), machine/sources/obsidian_local (a vault folder the Machine reads itself: a folder on its computer, or Obsidian Sync through Obsidian Headless; its setup), machine/app/obsidian (its owner actions, search_notes and get_note for connected AIs, and a to-do's notes: its preparation's notes block, note-find and note) obsidian_notes
notify, Telegram notify, machine/delivery/desk.py (the desktop robot in place of its computer's browser: notify_desks), telegram_mirror, telegram_store, pacing, signal_store (what the Signal mirror writes and the app reads) notify_*, pacing_*, signal_*; telegram_store keeps its own database (chats, messages, outbox, ...)
setup and upkeep onboarding, whatsapp_setup (WhatsApp's sync service, paused while it links again), google_pair, microsoft_grants (a Docs or Teams sign-in delivered to a paired self-hosted Machine), installer, cli, service, portable, moving, work_removal, deletion_reach (every row the registry in machine/export/inventory.py ties to what a deletion removes, after each path's own code; no table), kept_lessons (with keep_own_lessons, on: the owner's own lessons that wait after leaving a Work Fleet; kept_lessons_decide in FleetApp; no table), retention, experience (run detail kept for good with keep_experience, and how the owner's deletes reach it; no table), journal_scrub (secrets, one-time codes and link signatures taken out of that run detail as it is stored; no table), run_record (The Machine's own record of a piece of AI work: the run, each model try, what its prompt was given and the visible conversation, written as a run starts and replies, its text through journal_scrub, own_transcript), run_import (once: the runs from before that record get their start, replies and models from OpenClaw's own store, read-only, in paced batches), run_stamp (which run and try wrote an AI row: the call's run as the plugin bound it, the fixed prompt text each run was given once by hash in prompt_parts, a signal review's models per try from its session, why a try failed), note_history (each version seen of USER.md and MEMORY.md, and which USER.md a run was given), result_files (each version of the result files a Do it run links in the workspace, kept as it saves and ends, once for the files from before, and opened when the workspace lost one), rollout_health, machine/app/reconnect_asks (one quiet to-do to sign an account in again for more, done once it has it), machine/app/setup_nudge (the setup to-do's one suggestion with its reason in the first two weeks; no table); pinned downloads checked by hash: openclaw_pin, telegram_release, wacli_release, machine/store/history.py (older messages and meetings kept to search and read, never as signals) retention_runs, sync_daily, reconnect_asks, history_backfill, moved_in, runs, run_attempts, run_inputs, run_turns, run_imports, note_versions, result_files
shared helpers machine/dashboard_link (the dashboard's own https address: every link to it in a message, push or page is built there from dashboard_host and dashboard_path; a leaf), machine/todo_states (every to-do status and the named groups code and SQL ask about, such as OPEN and CLOSED, and the moves between statuses a to-do may make, MOVES, plus the few outside them that one writer makes today, each allowed only for its named reason, ALSO; a leaf, no table), machine/owner_error (OwnerError: a ValueError whose message is for the owner, which the dashboard shows; any other ValueError that reaches it is logged and counted for the error reports; a leaf), timeutil (the owner's time zone and hours, and the clock: clock(), today(), now() and stamp() (to the second) are the only reads of the current time, which a test fixes with tests/pinned.py), models (which model OpenClaw runs, whether it can), sources (SourceError, credentials, gog_read, mail and calendar accounts), i18n, locale_prefs, activity, load_speed (how fast the dashboard opens: a daily summary per device kind), activity_log (Settings, Activity: reads the other tables, writes only its own), authorship, model_budget, model_fallback, google_api, ms_graph, slack_api, mail_grants, mail_attachments activity_seen; load_speed (load_speed); activity_accounts (activity_log)
dashboard source dashboard_parts (assembles dashboard.html with its parts in dashboard/) none
connectors connectors/*.py, integrations/*.py none: they hand events to the service, never SQL
evals evals/regeneration/run.py (the R0 regeneration eval: its own run.sqlite beside a read-only copy, never the live store), evals/regeneration/rebuild.py (R2: another model rebuilds person summaries on a copy, in a sandbox without network; its own run.sqlite), evals/regeneration/kinds.py (R2b: relationships, preferences, knowledge and commitments rebuilt by several models, graded blind, replayed through the writers on a copy; its own run.sqlite) r0_*, r2_*, r2b_*

The full list, computed from the code: python3 tests/test_architecture.py --owners.

Where new code goes

  • A new action (a dashboard button, a CLI or agent call): in a domain that has an App mixin (<domain>_app.py, listed in APP_MIXINS in machine/main.py), a line in its ACTIONS ('name': 'method') and the method there, called as method(name, args, owner_dashboard); App.action looks there first. Otherwise its branch in App.action, with the code it calls in its domain's module when there is one. Either way, add the name to the right *_ACTIONS set in machine/actions.py, one name per line, sorted. Those sets are the security boundary and stay together there; a handler still checks owner_dashboard itself where its branch did.
  • A routine template (Routines, Templates): its catalog entry in routine_templates.TEMPLATES, and its code as a routine_templates.Template listed in ROUTINE_TEMPLATES in machine/main.py, not an App mixin. It declares the keys it runs, its to-do kind (machine/todo_kinds.py), its ACTIONS, an optional worker step and an optional start at service start; App.template(key) loads it. What it sets on itself stays its own: only the template reads it back. Today:
    • mail_cleanup_app.py (CleanupTemplate): Newsletter cleanup and Spam cleanup, their one to-do with a choice per mail, only what the owner confirms there, and the offers above the to-dos.
    • reading_digest_app.py (DigestTemplate): the Daily digest, one model call under a daily token cap, the owner's More or Less like this.
    • birthdays_app.py (Birthdays, with birthdays_facebook_app.py composed into BirthdaysTemplate in machine/main.py): today's birthdays among close contacts (birthdays.py), each a to-do prepared ahead on the channel the owner usually uses with them.
    • birthdays_facebook_app.py (BirthdaysFacebook): the Birthdays template's one Import birthdays from Facebook to-do: reads Facebook's birthdays page once in the shared browser on the owner's tap (birthdays_facebook.py), shows who matched and keeps their birthdays only on Save, through person_birthday.offer (the owner's own stays). Save also fills in the profile picture of a matched person who shows no photo, from the link in the same read, as a small copy (birthdays_facebook.save_photos, enrichment.keep_photo), one at a time in a thread of its own. Add as personal contacts adds the friends nobody in the Graph has as Personal people with their birthday, in one transaction and one build, with Undo (birthdays_facebook.add, remove). An older to-do with no friends kept gets them at start, from the same read (birthdays_facebook_fill_old); a read that comes back short is read again later, a few times at most, with its report kept on the to-do.
    • subscriptions_app.py (SubscriptionsTemplate): Subscriptions and trials, its monthly run and its daily 7-day check: plain code over receipts and notices (subscriptions.py), one model call only when there are candidates, one quiet to-do with Keep or Cancel per row; Cancel only hands the owner a draft or a cancel page.
    • secondhand_app.py (SecondhandTemplate): Second-hand finds, the one template added many times (many), each routine with its own search page and filters from the template card's setup. Every 3 hours it reads the search in the shared browser (secondhand.py, generic: JSON-LD and listing cards, no code per site), filters new listings in plain code, and only then has one small model call per listing judge its photo and seller, under a daily cap. One to-do per run with what passed; a login, robot check or block is a to-do with Open, never solved here.
    • reorder_app.py (ReorderTemplate): Reorders, every morning: plain code lists Shopify stores' order mail not read yet (reorder.py), one small model call only when there is any, then a quiet to-do per item nearly due again. Its link opens the store (reorder.way, where a later Shop checkout plugs in); Do it is refused.
  • App methods of a domain (workers, reads, what its actions call): in its mixin when it has one. A mixin imports what it needs like any module, never assistant, and only machine/main.py imports it (assistant.py re-exports it). The mixins today:
    • support_app.py (SupportApp): Help and Report a bug.
    • calendar_app.py (CalendarApp): the Calendar's actions.
    • skills_app.py (SkillsApp): the skill actions and the skills kept here.
    • learned_skills_app.py (LearnedSkillsApp): a Do it run's procedure, its check by meaning, the learned skills it writes, updates and retires (learned_skills.py; written through skills.Skills), and which skills a run opened.
    • agents_app.py (AgentsApp): Hand to Claude Code / Codex (the hand-off actions and where agents run).
    • gbrain_app.py (GBrainApp): GBrain on and off, its view and its sync thread.
    • shared_graph_app.py (SharedGraphApp): the Shared Graph's controls (GRAPH_SHARE_ACTIONS).
    • recurring_app.py (RecurringApp): recurring to-dos (Repeat, Skip this one, the one-time offer) and their worker.
    • corrections_app.py (CorrectionsApp): fix it where it came from (a chat turn finds where a wrong thing came from and fixes it there).
    • ai_app.py (AiApp): connected AIs: /mcp, the OAuth endpoints, the consent page and its tools (AI_ACTIONS).
    • missed_work_app.py (MissedWorkApp): the weekly missed-work audit's background turn and the owner's label on a miss (missed_work_label).
    • bring_in_app.py (BringInApp): Bring these in: the daily background turn over OpenClaw's notes and the owner's ticks (bring_in_decide).
    • history_notes_app.py (HistoryNotesApp): Notes from your older email: the once-per-mailbox background pass over the owner's own history mail (history_notes.py).
    • memory_import_app.py (MemoryImportApp): Import from another AI: the prompt, the review of a pasted answer and the owner's picks (memory_import_prompt, memory_import_review, memory_import_save).
    • meet_app.py (MeetApp): scheduling between Machines: the review's meeting request, the other side's to-do, Book it as a calendar write with the invite, and the setting (MEET_ACTIONS).
    • whatsapp_images_app.py (WhatsAppImagesApp): Read photos and voice notes on a WhatsApp connection and the worker that downloads and reads each photo and writes each voice note down.
    • routines_app.py (RoutinesApp): routines, work The Machine does on its own on a rhythm: the Routines page's actions (ROUTINE_ACTIONS), a run's own report (routine_result) and the worker that starts each run. It also sorts old OpenClaw jobs (routine_imports.py), then patterns in the owner's activity (routine_patterns.py, at most one a day), into suggestions, and turns an old job off on the owner's tap (openclaw-cron-off.mjs). It adds a template's routine (routine_template), hands each template run to the template's own code, and runs each template's step in its worker and its start at service start (routine_templates_start).
    • machine/export/ (with moving.py): inventory.py, the one list of what an install keeps by part, and walk(), one iterator over it; home.py, OpenClaw's conversations and what else an export takes from outside the data folder; hold.py, what an import holds so nothing goes out by itself (moving.md); experience_inspector.py, a read-only reader of the experience behind a to-do with every missing piece named (no table; intelligence.md).
    • machine/app/export.py (ExportApp): Settings, Export: an export in the background, its download, an upload to import and its Import now (EXPORT_ACTIONS; machine/export/staged.py marks a staged import confirmed). Another way out is one entry of EXPORT_OPTIONS in dashboard/settings-export.js.
    • machine/app/backup_settings.py (BackupApp): Settings, Export, Backup: the built-in backup of a self-hosted Machine turned on, its recovery key shown once, a new key, a snapshot now (BACKUP_ACTIONS, backup.py). The Backup row is dashboard/settings-backup.js, a part of its own (backup). After a restore, backup_review.py lists what it kept or restricted, each kept or put back (backup_review), drawn by dashboard/settings-backup-review.js (restored), loaded only when there is something to confirm.
    • machine/store/decision_rows.py: the one writer of decisions (write()): who decided (actor), where (surface), which version of the to-do was on screen (on_revision, the status's rev sent back with the tap) and until when a snooze runs (until). Record only, never a check (intelligence.md, tests/test_decision_rows.py).
    • machine/action_basis.py: what allowed each outward step (a tap, Do it, the owner's words, a setting), recorded with the step in action_jobs.basis and preparation_runs.basis and said in Settings, Activity. Record only, never a check (tests/test_action_basis.py).
    • machine/app/page_watch.py (PageWatchApp): Watch a page from the owner's own main chat (page_watch, the bridge's assistant_page_watch): list, add and remove Web page connections (connectors/web_page.py) with Settings' own connect steps.
    • machine/app/message_reads.py (MessageReadsApp): the read-only read_around (the messages just before and after one in its conversation) and filter_messages (messages by person, sender, days, channel, kinds, conversation and words; fixed parameters, no SQL from a model) for the bridge's assistant_signals and Talk. Every row passes connected AIs' gates (message kinds only, the chosen accounts and area, message_check, knowledge.held); bounded in rows and characters.
    • machine/store/done_checks.py with machine/app/done_checks.py (DoneChecksApp): a waiting to-do whose done when a public page will show (suggestions.done_check, sealed) has that page read when its time to chase comes, before it comes back: shown, it is checked (below); not there or unread, it comes back as before. Read only.
    • machine/app/done_elsewhere.py (DoneElsewhereApp) with marked_done, done_accounts and done_elsewhere (machine/store/action_outcomes.py): for a day after Mark done, what the owner did elsewhere (their own message to the to-do's people on the connected accounts of its area, a meeting that was held) is linked to the to-do as its outcome, by one small background turn per to-do. Outcomes only, never a draft lesson. Undo, Reopen or deleting the message drops it. What each turn judged is kept in done_elsewhere_judged, and the turns it spent in done_elsewhere_turns, until the window and its grace are past.
    • machine/store/result_checks.py with machine/app/result_checks.py (ResultChecksApp) and machine/prompts/result_check.py: what came for a waiting to-do (its page, a message, outcomes.result_seen) read against what was agreed in its thread in one small background turn (suggestions.result_check, sealed). Closes only on a match with nothing owed in return; a difference, a skipped OK, the owner's half of an exchange or can't tell comes back with its line. The thread says who wrote each message and when (review.own_message); a match quotes the page and the thread, and code checks both quotes are there (machine.text.quoted_in). Eval: evals/result-checks.
    • note_pages_app.py (NotesApp): trips and events for Calendar: their bands (calendar_notes) and a trip's or an event's page on api/graph?node=note:<id>, opened from its band (dashboard: dashboard/graph-notes.js). Nothing on it is edited. note_pages.sync keeps them under Trips and Events, with what an owner changed before on top. The Notes feature is gone: its rows stay in the database untouched (other kinds in note_pages, and the tables note_pages.KEPT_SCHEMA still makes), no code reads or writes them, and the full export still has them. Trips: the mail source reads a confirmation's schema.org reservations, JSON-LD or microdata (bookings.py), into the message's sealed metadata; trip_notes.py keeps them (trip_bookings). A booking-like mail without them (bookings.looks_booked, plain code) waits in trip_pending for machine/app/trips.py (TripsApp.trip_extract_step): one small background call reads a few at a time into the same rows (bookings.extract_prompt, parse), at most EXTRACT_CALLS_DAY a day. trip_notes.py groups one journey into one trip by dates and connecting places, adds what is missing (gaps), and trip_notes_step (every ten minutes, plain code) syncs them under Trips. Events: ticket mail's EventReservation rows, kept with them, become one dated note per event under Events (event_notes.py, the same step; a to-do from the ticket mail opens from its line).
    • machine/names.py: what the owner calls a service, app or agent; every key from data shown on screen goes through it, so a tool underneath (gog, wacli, msgraph-cli) is never a name (tests/test_owner_names.py).
    • machine/owner_name.py: the owner's own name for what greets them, signs their drafts or names them on a page to pick a time: config, else USER.md, else (a greeting only) their work mailbox's. Whose message is whose keeps to owner_name (own_addresses.py, graph.py).
    • machine/services.py: every service a connection reads (gmail, slack, web_page), one row each: its name, its + Add label, group and sign-in, and the transports that mean it. A leaf; names, sources/groups, fleet, onboarding and the mail and calendar lists read it, and the page carries its dashboard fields as JSON (SERVICE_ROWS in dashboard/shell-core.js; tests/test_services.py).
    • machine/omarchy.py: the current Omarchy theme's colors (GET /api/omarchy-theme), for Settings, General, This device, Omarchy theme (dashboard/settings-omarchy.js, painted by paintOmarchy in dashboard.html).
    • machine/app/history.py (HistoryApp): the history backfill's worker, when it may run and one step per source; after a mailbox's walk, history_bookings reads its held mail once more per trip_notes.WALK_VERSION for bookings, Personal mailboxes first, and queues booking-like mail without structured data for the model (trip_notes.queue); machine/store/history.py owns history_backfill and the line between history and signal (events.history). machine/store/graph_history.py lets history into the Graph's people and organizations in bounded passes, newest first.
    • machine/graph/: the passes of a Graph build, one function each, in the order graph._build_in runs them: identities, joins, strength, projects, decisions, sides, people, organizations, same person, organization and project nodes, relations, rows. graph.py keeps the transactions and the publish. tests/test_graph_golden.py holds every graph_* row a sandbox build writes, so a change to a pass shows each row it changes. machine/graph/card_lead.py is no pass: it orders a to-do's people (graph.card_people), who asked first. machine/graph/setup.py is the setup before the passes (writes only what changed) and a build's mark, by which the graph worker skips a timed build while nothing it reads changed.
    • machine/app/search_ask.py (SearchAskApp): Ask from search: the messages a question in Search finds in the area in view and the one-shot turn that answers it (search_ask.py has the prompt and the answer).
    • machine/app/ask_connections.py: a question about the owner's own mailbox or chat account: the list the first turn picks from, the check of what it picks, and what the Machine knows of it (how it is doing in Connections' own words, up to when it was read, or not connected).
    • machine/app/ask_memory.py: what Ask reads besides messages, as four blocks on the ask recall: promises, facts, the asked-about record's summary and meeting notes that match the question, cited as what they are.
    • machine/app/recall.py (recall(app, purpose, about, budget)): the one way a prompt reads memory. The review, preparation and Ask builders ask it for each block's text; the pickers behind it are unchanged and say what they put in (memory_use.note), and the builder logs that once its run is admitted (memory_use.record). A new reader of memory is a block there, not another call in a builder. machine/app/senders.py is the review's sender block: one line per sender of the claimed batch the Graph knows something specific about.
    • machine/app/start_message.py: a run's start message, put together within the runner's limit: what always goes is set aside first, the rest by rank. A new block of a preparation's start is an add there, never appended to the message. Also the codes of a start that can never go out (REFUSED).
    • machine/app/review_facts.py (ReviewFacts): which facts a review gets once they no longer all fit its cap: the standing ones first, then the closest to the waiting signals (stored vectors), and a turn for the one a review saw longest ago.
    • machine/app/retained_facts.py: the retained block of the review, preparation and chat recalls: ended or replaced facts as history, that bear on the to-do or the waiting signals, in a small slice.
    • machine/app/prep_reads.py: a to-do's run reads less. review_brief is the preparation's "What the review found" block (the to-do as saved and a header line per message it came from, no text); inline_block adds what events returns for the messages it came from (newer ones are read as before) when they come whole within INLINE_CHARS: one read through the run's own read gates, its own accounts in its own area only, Slack members by name as a run gets them, marked untrusted. Added last and dropped first when the start runs out of room; the start that is sent marks them read (preparation_gateway). RunReads keeps which messages each run got whole from events or related, so a repeat read gets already_read and a note. history_once does the same for preparation_history pages, and slack_read uses it to list only new messages.
    • machine/app/review_status.py: a signal review's status, light and read once. light lists every open to-do by its title and body_start and every done one as a line, kept under the review page size by fit; read_once gives a second status in the same review only the to-dos new or changed since (on RunReads); here puts the open to-dos on the claim's own threads, chats and senders whole in its reply (open_todos_here).
    • machine/app/claim_reply.py: what a claim (begin_analysis) carries next to its signals: the boards with only the claim's own projects (boards), one whole board on request (lookup, graph board), and fit, which keeps the whole reply under the review page size and says in left_out what it dropped.
    • calendar_busy.py: what takes the owner's time (one rule for free/busy and clashes), and which times aren't known; no table.
    • calendar_clashes.py with machine/app/calendar_clashes.py (CalendarClashesApp): a work meeting overlapping a personal event, found by plain code (pairs), one to-do per event (grouped) that names only its own side, raised once; later overlaps join it (plan). A block that only frames the day never clashes (mark_frames). The owner's dashboard reads the other side at view time (annotate), so no Fleet sees it.
    • bookings.py and trip_notes.py with machine/app/trips.py (TripsApp): booking mail without structured data read by one small background call for a few mails at a time, so it lands on its trip too.
    • meeting_prep.py with machine/app/meeting_prep.py (MeetingPrepApp): before a meeting with people from outside (a recurring one only when something is new since the one before it: repeated, news), one briefing to-do from what the Machine already has (the Graph, looked-up profiles, where the conversation started and its latest messages (a day of one chat as one: _folded), open promises, and the notes of earlier meetings with the same people: earlier_notes.py, which meetings, which record of each, how much, and what happened since; no table; its eval is evals/meeting-briefings/; messages and notes may come from history, graph_history.BOTH) and, for a first meeting, the organization's own home page (enrichment.site_text) and, where OpenClaw has a search provider, a short web search on their name and organization (openclaw infer web search; else, unless meeting_prep_signin_search is false, one search on the owner's ChatGPT or Claude sign-in: machine/signin_search, claude_print.search, openclaw-plugin/web-search.ts, which puts the hosted search in that one request and no other; on ChatGPT the addresses are those the answer names), both cached (meeting_prep_web), written in one background turn, or none when there is nothing useful; once per meeting, by its iCalUID (and the planned time in a series). Each briefing carries its format (meeting_prep.FORMAT); once after an upgrade that raises it, open, unedited briefings for meetings still ahead are written again (stale, meeting_prep_rebuild; done per format in learning_state). A note in a briefing's chat runs as any to-do's chat, told meeting_prep.chat_rule; Store.prepare saves only an answer or the briefing with the note in it, never a step or a send, and puts it back to read (_briefing_saved).
    • machine/model_reply.py: the JSON in a small background turn's reply (read, rows), the one more ask when it can't be read (ask), and the rest and cap after that (waiting, in memory, no table). Used where an unreadable reply would otherwise stand as an answer: briefings, the checks that close to-dos and promises, person summaries; the first pass only reads with it. A new small turn that keeps a verdict uses it too. Native structured output was measured in its place and not used (evals/structured-output): OpenClaw's one-shot turn takes no schema, and on Claude Code it doubled the input with no unreadable reply to save.
    • machine/upkeep/agent_workspaces.py: the nightly cleanup of Claude Code and Codex job folders nothing needs any more (retention.py runs it; it only reads agent_jobs, suggestions and agent_relayed).
    • machine/upkeep/memory_rebuild.py: an OpenClaw memory index rebuild that never ends by itself (the installer stops waiting for it) and the quiet night that lets it finish (the retention worker runs it, background_pause holds).
    • machine/app/knowledge_export.py (KnowledgeExportApp): Knowledge for another AI (Settings, General, Export) and its one-time download; the format is machine/export/knowledge.py, with the experience records in machine/export/experience_records.py (knowledge-export.md).
  • A question about a person, organization or project (who they are, their latest messages, what is open with them, when the owner last talked to them), from any surface: through knowledge.py with the caller's Caller (knowledge.owner(), or knowledge.connection(config, area) for a connected AI), never a query of its own. Add a case to tests/knowledge_eval.py for every surface that answers it.
  • A new route: in machine/web/handler.py (make_handler(app), which App.serve runs). A GET path is a line in GET_ROUTES ('/api/x': 'get_api_x') and its Handler method, called as method(path) after do_GET's owner check; only patterns stay branches of do_GET (tests/test_get_routes.py). A POST goes in do_POST. JSON reads go through App methods; owner-only and CSP headers stay as the neighboring routes have them (tests/test_owner_boundary.py).
  • A new table: in its domain module's ensure(db), called from Store.__init__, with the functions that write it in that same module.
  • A new domain: a new flat module at the root that the others import. It never imports assistant.
  • Code moved out of assistant.py: in its area of machine/, in that area's layer (below). Nothing in machine/ imports assistant or a module of a higher layer. Moved so far, besides the mixins above: machine/config.py (ROOT, WORKSPACE, DEFAULT_CONFIG, LOG, the brand assets and rule files), machine/timing.py (a request's timing, SLOW_REQUEST_SECONDS, aside: a write a request leaves for after its answer), machine/mail_quotes.py (which lines of a mail its sender wrote and which they quote, in plain text and HTML), machine/text.py (message text: quoted history, bodies, attachments, clamp, encoded, seal_copy, body_after_title: a to-do's body without its title again, as the dashboard's bodyAfterTitle), machine/prompts/ (review.py: the review prompt, source notes, how facts are worded; profile.py: the profile, voices, skills, roles, organizations, history and import prompts; bias.py: model bias corrections, such as plain drafts, per model family), machine/cards.py (how a to-do reads: snooze times, titles, source lines, handoffs, ask and blocker text, controls, to-do states), machine/browser.py (browser leases, sign-in handoffs, tab peeks, safe links, preparation steps), machine/chat.py (a to-do's chat: its items, replies, drafts, handoffs and redaction), machine/faults.py (the Machine's own errors: where they happened, their scrubbed message, the code version and release, the fault log), machine/system_logs.py (the computer's own logs: journald and crash dumps read only, the real problems in them and their to-dos), machine/sources/exclusions.py, salesflare.py and telegram.py (the exclusion rules and the Salesflare and Telegram sources), machine/sources/gmail.py and calendar.py (the Gmail and Calendar sources with their sync, rooms, guests, owners and write helpers), machine/model_usage.py (the model's usage and resets, the Codex app server, Node and Telegram environment helpers), machine/work_report.py (how the background jobs went in the last 24 hours, counts only, for the hosted health report), machine/ai_training.py (whether the owner's AI plan trains on chats by default, the provider's setting to turn it off, and Done), machine/sources/android.py and gateway.py (the Android notification feed and the Gateway journal source), machine/sources/phone_app.py, phone_words.py and machine/app/phone_notifications.py (Android notifications from The Machine app: device tokens, the upload, its sync, its own setup words), machine/sources/obsidian.py and machine/app/obsidian.py (Obsidian notes the desktop app reads from a vault), machine/sources/obsidian_local.py (Obsidian from a folder on the Machine, or Obsidian Sync), machine/sources/browser_history.py and machine/app/browser_history.py (Browser history from The Machine's browser extension: pairing codes, browser tokens, the upload, its rules, its sync), machine/sources/connectors.py (connector plugins and helpers, hosted sign-ins, silent failures, read windows, the connector prompt lines) and whatsapp.py (the WhatsApp source), machine/delivery/ (push.py: phone pushes, app notices, reminders and setup hints; telegram.py: Telegram sends; deliver.py: the delivery loop, Fleet pushes and uncertain sends), machine/actions.py (the *_ACTIONS sets: who may call which action), machine/store/core.py (StoreCore: opening the database, its schema, message protection, exclusion purges, connect; Store in assistant.py subclasses it), machine/store/events.py (EventsStore: committing and reading events, the Android feed, tombstones, sync checkpoints), machine/store/event_versions.py (what a signal said before its source changed it, and when it was first seen), machine/store/coverage_spans.py (which periods of each account were read: dated spans from the checkpoint before it is overwritten), machine/store/row_sides.py (Work or Personal on a message, a fact and a proposal, stamped when written, and the nightly backfill of older rows, labeled inferred), machine/store/review.py (ReviewStore: claiming signals for a review, the context it reads, keeping its result; how a signal is weighed and shown; review_catch_up.py: what it claims while far behind; ahead_hold.py: the drafts ahead that wait meanwhile), machine/store/cards.py (CardsStore: making and changing to-dos: suggest, update, rename, move, merge, the owner's own, their sources), machine/store/decisions.py (the DecisionsStore mixin: decisions, handoffs, feedback, preparing a to-do, sends and merges with their undo), machine/store/voices.py, machine/store/facts.py and machine/store/promises.py (the VoicesStore, FactsStore and PromisesStore mixins), machine/store/views.py, machine/store/profile.py and machine/store/first_look.py (the ViewsStore, ProfileStore and FirstLookStore mixins), machine/store/message_view.py (how each event kind reads in the message viewer: its view, email, chat, notification or card, and the rules every source keeps there; connectors declare VIEWS and APP), machine/store/judged_words.py (what the checks that close to-dos and promises by themselves read of a message: its own words, and its files where the source keeps them; made-up cases for a model run: evals/closing-checks/), machine/store/evidence_moments.py (from when on something is news on a to-do: per conversation its evidence is in, and since its newest message elsewhere), machine/store/whats_new.py (the WhatsNewStore mixin and ENTRIES: the pool of What's new candidates, the morning's pick of up to five (pick_step, run by retention_worker; an entry for a Work Fleet or for one main model only goes where that fits) and what a person saw; its dialog is dashboard/shell-whats-new.js), machine/store/done_milestones.py (the DoneMilestonesStore mixin and LEVELS: the milestone on done to-dos due on To-dos, shown once; its card and share image are dashboard/todos-milestone.js), machine/store/machine_cards.py (the MachineCardsStore mixin: The Machine's own to-dos, through Store.machine_card), machine/web/serving.py (the dashboard page, hosts, CSRF, compression, ETags, status) and machine/web/waiting.py (KeyWaitingPage, message_key_keeper), machine/web/handler.py (make_handler(app): the dashboard's HTTP Handler, out of App.serve), machine/web/loopback.py (Server: both web servers on 127.0.0.1, bound without a reverse DNS lookup), machine/app/talk.py (TalkApp: Talk's view, actions, tools, drafts and sends), machine/app/siri.py (SiriApp: what the iPhone app's Siri shortcuts and the Android app's assistant functions ask, through the connected AIs' tools and Talk's send), machine/app/fleet.py (FleetApp: attaching the Fleet, its pings, notices, votes, shared learnings and connectors), follow-up and promise steps into FollowUpsApp and PromiseChecksApp (machine/app/follow_ups.py, promise_checks.py; a refund promise's check, money-back match, chase text and draft are plain code in refunds.py), the graph worker and timeline methods into GraphActionsApp (machine/app/graph_actions.py), machine/app/card_chat.py (CardChatApp: a to-do's chat turn, its models, stop and hand-offs), machine/app/recap.py (RecapApp: the weekly recap, its steps, view and choices), machine/store/conversation.py and machine/app/conversation.py (ConversationStore, ConversationApp: what was said around a message), machine/app/first_look.py (FirstLookApp: the quick first review, the dig after it and its ending, with their timing constants), App.meeting_notes (the meeting_notes tool) into MeetingWritesApp (machine/app/meeting_writes.py), machine/app/preparation.py (PreparationApp: starting and checking a to-do's preparation run, its progress, peek and worker, with the preparation prompt and its helpers), machine/app/review.py (ReviewApp: the review step, its queue, tick and worker, the live view and the preview on a new install, with their timing constants and step names), machine/store/faults.py (FaultsStore: recording The Machine's own errors, reporting them and settling the ones that stopped), the tool approval reads and the one-time ahead-blockers fix into StoreCore, the graph actions of App.action (graph, its people, organizations, roles, pictures, merges and facts) into GraphActionsApp.ACTIONS handlers, the follow-up and promise actions of App.action into FollowUpsApp.ACTIONS and PromiseChecksApp.ACTIONS handlers, the review, preparation, recap, signature, to-do chat, voice and Talk actions of App.action into their mixins' ACTIONS handlers, machine/app/settings_actions.py (SettingsActionsApp) and machine/app/notifications.py (NotificationsApp): the Settings and Notifications actions of App.action, machine/app/browser.py (BrowserApp): the browser and site sign-in actions of App.action, machine/app/profile.py (ProfileApp) and machine/app/feedback.py (FeedbackApp), with the projects, boards and CRM actions into GraphActionsApp, learning_undo into FleetApp and the review run's own actions into ReviewApp, machine/app/card_actions.py (CardActionsApp: a to-do's own actions of App.action: prepare, decide, revise_draft, confirm_action, refresh_card, chat files and task_import, with the helpers only they use), machine/app/docs.py (DocsApp: doc_text, doc_find, doc_write_draft; a linked Google Sheet or Slides file is read by google_files.py, and google_links.py finds the links) and machine/app/status.py (StatusApp: the status action with needs_you, compact_status, sign_in_help and agent_work_status), App methods for feedback prompts, profile steps, digest and notify, gbrain, skills and support: into FeedbackApp, ProfileApp, NotificationsApp, GBrainApp, SkillsApp and SupportApp, Browser and sign-in App methods into BrowserApp; first-profile, share-history and orgs backfill steps into ProfileApp; skills sign-in, notify views and prompt receipts into SkillsApp, NotificationsApp and FeedbackApp, Settings views (hours, locale, setup hints, agents, account, security, learnings, activity) into SettingsActionsApp; voice warm-up into VoiceApp; model usage workers into ModelPacingApp; retention, embedding, enrichment, Help topics and error report workers and Google contact photos into new WorkersApp (machine/app/workers.py), Approved-action workers, merge effects, Undo and stale-run stops into new ActionRunsApp (machine/app/action_runs.py); style, expire, thread snooze and config-follow steps into WorkersApp; doc runs into DocsApp; gbrain_save into GBrainApp; task import, handoff email and import checks into CardActionsApp; bug_offer into SupportApp, Each account's collector, its lock and waits, connector sync and action-only ability checks into new SyncApp (machine/app/sync.py); sync_source, sync_slack and Slack title naming stay in assistant.py (they write the sealed events table), Slack title naming (name_slack_titles) into EventsStore as a Store method, so the code that calls it can leave assistant.py without another writer of the sealed events table, sync_source, sync_slack, remember_slack_names, sync_retrying and sync_soon into SyncApp (after name_slack_titles became a Store method), The owner's email (Gmail message and source email, attachments, mailbox lookups, own addresses, handoffs by email and task pages) into new MailApp (machine/app/mail.py); WhatsApp source and photo event into SyncApp; calendar_write into MeetingWritesApp, New to-dos (new_card, agent_card with its message, background and chat helpers, is_work) into new NewCardsApp (machine/app/new_cards.py); review evidence paging and the first-cards report into machine/app/review.py; split_notes_text into ReviewApp; short_window into ModelPacingApp; activity_report, active_work and weekly_recap next to their features, ai_card's events insert into EventsStore as a Store method (add_ai_request), so ai_card can leave assistant.py without another writer of the sealed events table, ai_card into NewCardsApp (after its events insert became EventsStore.add_ai_request), stop_all and message protection into WorkersApp; serve and packed_page into the new ServeApp (machine/app/serve.py), dictation_openai into VoiceApp, its script path from machine.config.ROOT, the mail attachment methods (mail_attachment, gmail_attachments, outlook_attachments, share_files) into MailApp, still_needed_step into RecapApp, calling FirstLookStore.still_needed_ask, adding a source from the dashboard (connect_action, connect_run, connect_view, team_domains, connect_form, same_signin and the sign-in pages) into the new ConnectApp (machine/app/connect.py), the dispatcher's card, source and learning branches into ACTIONS handlers (card_owner_action in CardActionsApp, connect_owner_action in ConnectApp, learnings_action in SettingsActionsApp), and the rest of them: events_action (events, related, begin_analysis) in ReviewApp, mail_attachment_action and task_page_action in MailApp, client_error_action in ServeApp, bug_offer_action in SupportApp; only the Fleet and Family prefix route stays in App.action. Then Store, APP_MIXINS and App themselves into machine/main.py; assistant.py keeps main() and re-exports them.
  • Dashboard code: in its area's part in dashboard/ (<area>-<what>.js: shell, todos, settings, graph, calendar, routines, connections, help, events, new, fleet), next to the functions it works with, never at the end of the script. The page's core is in the shell-* parts too: locale and error reports (shell-core.js), network and outbox, render() and refresh(), toast() and the start (shell-start.js), the i18n script's body (shell-i18n.js). Which to-dos stand in For you and in which order is todos-for-you.js: plain rules on the status, no page, so another program can run the same file. dashboard.html itself holds the head (with its small theme script, which runs before paint), the page's elements that wrap the parts, and the include lines in order: what the page is made of, at a glance. A new top-level statement goes in a part only whole (each part parses on its own). Parts run in the page's order, as they were in the one file, so a part may use what an earlier one declares. New UI strings go in i18n/en.json; the daily translator writes the other catalogs.
  • Dashboard styles and markup: the same way, in parts: a stylesheet part dashboard/<area>-<what>.css fills a line /*@include dashboard/<name>.css*/ inside the page's <style>, a markup part dashboard/<area>-<what>.html a line <!--@include dashboard/<name>.html--> in the markup (base is the area of the shared design layer). A stylesheet part is whole rules and the parts follow each other in the page's order, so the cascade is the one of the whole sheet: a rule that overrides another comes after it, in the same part or a later one. A markup part is whole elements. tests/test_dashboard_parts.py checks both, and that each include line is in its place. The markup is in parts by area (shell-sidebar.html, shell-main.html, settings-panels.html, the dialogs); a new element goes in its area's part. The stylesheet is in parts already, in the page's order (base-tokens.css with the shared design tokens first); some runs still mix areas, as the sheet grew: a new rule goes in its area's part, after any rule it overrides.
  • One to-do on its own: ?compact=1#card=<id> shows only that to-do, for a small window another app frames (300 px and up; GET api/session answers "compact": 1 where it's there). It is the dashboard's own card, chat and dialogs with the page around them left out: dashboard/todos-compact.js and .css, a lazy part no other page fetches. Never in a frame. What leads out of the to-do is a new window with the whole dashboard's address, Escape is the app's when nothing is open, and the page's title is <state>: <title>, never translated: open, done, snoozed, gone, offline or signed-out.
  • Reading the dashboard's source (a test, a script): through dashboard_parts.assemble() in Python or dashboardPage() from tests/dashboard-page.mjs in Node, never dashboard.html itself. The page is served as one document, but its source can be split into parts (dashboard/<name>.js, .css and .html, each filling its include line in dashboard.html), and only the assembled page has them all. scripts/split_dashboard.py readers rewrites a test that still reads the file. The service serves the assembled page (dashboard_page()), so the browser, the service worker's offline copy, the ETag and the CSP see one page as before; dashboard/ itself is never served. The script's parts are edited by hand; scripts/split_dashboard.py split-css and split-html cut the stylesheet and the markup into parts at named anchors, and verify origin/main proves the assembled page is byte for byte main's.
  • A big page or script is split before it nears 450 KiB: Aikido skips big files (some just over 500 KiB already go unscanned), so a bigger one ships unchecked (see the size rule below).
  • Markup in the dashboard: build elements with make(), or write markup with html`...` and put it in the page with setHTML(el, h). In html every `${}` is escaped unless it is itself anhtml result (or raw() of a vetted constant), so no esc() call can be forgotten; setHTML takes nothing else. An html result that is joined, added to a string or passed to `t()` is text again, and its tags show on screen: put the array inhtml (${parts.map((x,i)=>html`${i?' · ':''}${x}`)}), and use htmlT() for a sentence with markup in it. Older renderers that build strings with esc() move to html `` one at a time.

The rules and their checks

Run them with python3 scripts/test.py test_architecture.py test_message_seal.py test_dashboard_parts.py test_app_mixins.py (they run in CI with every suite).

rule check
Each module defines or imports every global name it uses. A function moved without its import fails here, not with a NameError at runtime. Covers every *.py, subfolders and tests included. tests/test_architecture.py
No module loads assistant.py. The service runs it as __main__, so an import elsewhere makes a second copy with its own Store and globals. The entry points that do so today are listed in LOADS_ASSISTANT; tests may. Only machine/main.py composes the *_app.py modules (assistant.py re-exports them). tests/test_architecture.py
assistant.py is frozen: main() and the names it hands out to code and tests that still read them through it. No new def, class or assignment goes in (ASSISTANT_OWN), and the count of names it binds (ASSISTANT_NAMES) may only come down: import a name from its own module instead, and lower the count when one goes. tests/test_architecture.py
Each table is created by one module, its owner (today's few shared ones are in SHARED_SCHEMA). tests/test_architecture.py
Only the owner writes a table. Today's other writers are listed in OTHER_WRITERS. That list may only shrink: a new writer fails with the owner's name, and an entry that no longer writes fails until it's removed. tests/test_architecture.py
Every text column of the database is sealed (message_seal.DERIVED) or in tests/plain_columns.py: a code, or words that stay plain with the reason. Words written to a code column fail the suites scripts/test.py runs guarded (PLAIN_CHECKED). tests/test_message_seal.py
Only the Store and App (machine/main.py, machine/store/*) write events, the sealed table (and the sandbox's fixture loader, through the sealed connection). Covers subfolders. tests/test_message_seal.py
Nothing reads dashboard.html itself; every part in dashboard/ is included once, its include line is in its place (a script, the stylesheet, the markup), and it is whole (statements that parse on their own, whole rules, whole elements); the service serves the assembled page; Python and Node assemble the same page. tests/test_dashboard_parts.py
No html `` result of the dashboard is used as plain text (joined, added to a string, in an attribute, through t()), where its tags would show on screen, and no escaped text is escaped twice. tests/test_html_flow.mjs
A script of the dashboard uses only names that are there when it runs: its own, the main script's, and those of a part loaded later that the code makes sure is in (lazyRun, lazyPart, lazyIn) or dashboard_parts.LAZY_WITH says always is. tests/test_lazy_names.mjs
Every CSS custom property the dashboard or the app's own screens use is defined there: in a stylesheet, an inline style or a script. A name nothing defines takes its fixed fallback color, which follows no theme. tests/test_css_tokens.py
No action is mapped by two mixins, no member is defined in two of them or in both App and a mixin, every handler is a method, every name in OWNER_ACTIONS or DASHBOARD_ACTIONS reaches a mixin's handler or a branch of App.action, no branch of App.action names an action a mixin maps (it would never run), and every action the dashboard sends is in DASHBOARD_ACTIONS and has a handler. Each routine template runs keys no other one runs, names a to-do kind the registry has, maps its actions to its own methods and hides no App member. tests/test_app_mixins.py
Code in machine/ imports only from its own layer or the ones below it, and any root module, never with import *; machine/__init__.py imports nothing. Each area declares its layer, LAYER = <n> at the top of its module or its package's __init__.py, from 0 (leaves such as owner_error and todo_states) up to 4 (app, main); a new area declares it in the pull request that adds it. python3 tests/test_architecture.py --layers prints them. tests/test_architecture.py
Python files (tests aside) stay under 2,500 lines and 450 KiB. A bigger module is hard to review, and Aikido's scan skips it. PY_OVER_BUDGET lists today's bigger files with ceilings that only come down: a file that grows past its ceiling fails, one that shrinks well under it fails until the ceiling is lowered, and one back within the budget fails until its entry is removed. tests/test_architecture.py
To-do statuses come from machine/todo_states.py: two or more of them spelled out elsewhere, as a tuple, list or set or as an SQL IN list, fail; so does a list of them in the dashboard's scripts, which read the groups the page carries (TODO.CLOSED, from dashboard_parts.kinds_json). Name a group from it, or add one there with its reason when a module means something else. tests/test_architecture.py
A to-do's status changes only through machine/store/todo_moves.transition(), which checks the move against todo_states.MOVES and keeps it in the to-do's history: a raw UPDATE suggestions SET status= anywhere else in the app fails. The writer sets its other columns in its own UPDATE, then moves it. tests/test_todo_moves.py
Services (gmail, slack, web_page) come from machine/services.py (a leaf: each service's names, group, sign-in, transports and video links), whose dashboard fields the page carries as JSON (SERVICE_ROWS). A new hand-written list or map of four or more of them, in Python or the dashboard's scripts, fails; SERVICE_LISTS counts today's per file, and those counts only come down. tests/test_services.py
Kinds of event (slack.message) and of message a to-do sends (email, slack) come from machine/kinds.py (a leaf: each kind's service, name, view, family, timeline group and mark), which the page also carries as JSON (<script id="source-kinds">). A new hand-written list of them (two or more event kinds, or three or more send kinds with email or doc_reply, in a tuple, list, set, dict's keys, SQL IN list, or a dashboard array or object) fails; KIND_LISTS counts today's per file, and those counts only come down. tests/test_kinds.py
Every dashboard area in scripts/i18n_extract.py resolves. tests/test_architecture.py, python3 scripts/i18n_extract.py --area <name>
Shipped .html, .css, .js and .mjs files stay under 450 KiB. Aikido's code scan skips big files (some just over 500 KiB already go unscanned), so a bigger one ships unchecked, and splitting it later turns up its findings all at once. The dashboard's source has smaller budgets: dashboard.html 24 KB, each part in dashboard/ 160 KB (.js), 64 KB (.css) or 32 KB (.html); a part over its budget is split into another <area>-<what> part next to it. OVER_BUDGET lists today's bigger files with a ceiling that may only come down. The page's first load (the page and its main script, without the parts that load when first needed, dashboard_parts.LAZY) and each of those groups stay under their budgets in dashboard/budgets.json, raised only on purpose. Sizes count gzip of the text without its whole-line // and /* */ comments, so comments cost nothing; the budgets sit about 3% over the size when they were set. A new page, panel or dialog goes in a part that loads when first needed, not in the first load. tests/test_architecture.py

The table checks read the SQL in each module's strings. A statement whose table name is computed (f'DELETE FROM {table}') isn't seen, so keep table names literal in new code.

Moving code out of assistant.py

  • Move code as is, one domain per pull request, with no other change in it.
  • Keep names that other code or tests use from assistant available there until those callers move.
  • When the move takes a table's writes along, update OTHER_WRITERS in the same pull request.
  • Move with scripts/move_code.py, so a rebase is a rerun of the script on the newer assistant.py, not a merge by hand. move_code.py --export assistant.py machine/text.py message_body QUOTED_MARK moves top-level functions, classes and constants, text unchanged, to the end of the target, and imports them back in assistant.py (one name per line, sorted). move_code.py assistant.py <domain>_app.py:<Class> App.<member> ... moves App methods and class attributes to the end of a mixin's class. Each item goes with the comment lines above it; the script checks the text is the same. Then add the imports tests/test_architecture.py says the moved code lacks. Code that uses a helper defined in assistant.py stays until that helper has a module of its own.
  • assistant.py is within the general Python budget and out of PY_OVER_BUDGET; keep it there.
  • When the moved code is named by file elsewhere (scripts/help_check.py FEATURES, scripts/i18n_extract.py SERVER_TEXT, a test that reads source text), point that at the new file in the same pull request.
  • Tests patch names on assistant with seams.patch_everywhere (tests/seams.py), never plain patch.object: it also patches every module of the app that binds the same object, so code moved out of assistant.py sees the patch too. tests/test_seams.py fails on a plain patch or assignment; methods go through the class (patch.object(a.App, ...)).
  • Tests import names from their own modules (machine.main.Store, sources.SourceError), not through assistant.py, and patch them where the code looks them up. The shared test helpers (test_assistant, test_connectors, test_graph, test_intercom_replies, test_ux) do so too, so importing one doesn't run assistant.py; they still hand it out as a (test_assistant: assistant), loaded on first use (tests/assistant_on_use.py), to the tests not yet converted.
  • Only the entry points in LOADS_ASSISTANT load assistant.py. onboarding.assistant() hands setup what it reads from the rest of the app (onboarding._Reads), each name looked up in its own module at every use, so a test's patch_everywhere on that module reaches setup too; a test may still patch onboarding.assistant (as test_connectors.FOR_ONBOARDING).
  • Prefer plain modules to mixins. A mixin still reaches into App (self.store, self.config, other mixins), so it moves code without separating it. New domain code goes to a flat module of plain functions that take db, config and the values they need as arguments (notify.py, follow_ups.py); App keeps a thin method that passes them in. The mixins above stay until their code moves that way. Store mixins go the same way: a method that needs nothing of the Store becomes a function of db in its module (card_channels(db, suggestion_id) in machine/store/voices.py), and the Store keeps a thin method that passes db in, so callers and tests that patch Store are unchanged. A @staticmethod already is one: it moves out as is and the class keeps name = staticmethod(name) (fact_state in machine/store/facts.py).
  • Shared helpers go to plain modules of plain functions that take what they need as arguments (timeutil.py, models.py, sources.py), never a mixin. assistant.py imports their names, so its own code and the tests that patch them on assistant keep working; state such as the zone or the hours lives in the helper module, so a test patches it there (patch.object(timeutil, 'LOCAL_TZ', ...), patch.dict(timeutil.WORK_HOURS, ...)). When one helper calls another in the same module (models.has_model calls model_ready), a test that wants the patch seen there patches the helper module too.
  • A table's writes go to its owner module as functions that take db (notify.digest_claim, follow_ups.add_card); the caller keeps its transaction. Then remove the caller from OTHER_WRITERS.