Projects, workspaces and invocation resources¶
octomate.managers.project ¶
Database-backed project lookup and native working-directory resolution.
ProjectManager ¶
Bases: Manager
Read persisted projects without retaining a process-local catalog.
Source code in octomate/managers/project.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
get
async
¶
get(
owner_id: UUID7,
*,
project_id: UUID7 | None = None,
name: str | None = None,
thread: Thread | None = None,
) -> Project | None
The owner's project matching all supplied filters; at least one is required.
ID and name lookups include disabled projects. A thread lookup uses its stored project ID, refuses missing or foreign bindings, and returns None for unbound threads or disabled projects.
Source code in octomate/managers/project.py
list
async
¶
list(
owner_id: UUID7,
*,
cursor: str | None = None,
limit: int = 20,
enabled: bool | None = None,
query: str = "",
) -> Page[Project]
An owner-scoped page in stable ID order, optionally filtered by enabled state.
Source code in octomate/managers/project.py
resolve
async
¶
The owner's enabled project whose root most closely contains cwd.
Resolve paths before comparing so symlinks and alternate spellings of the same directory match. Roots are read anew on each call.
Source code in octomate/managers/project.py
octomate.managers.workspaces.base ¶
Compose thread workspaces from logical volumes and their host storage.
WorkspaceManager ¶
Bases: Manager
Every run's workspace. A registered user's run gets a tree volume in that
user's root, volumes_dir/<owner>/tree/<volume>, recorded by a row and
checked out on the thread's own branch; an unregistered sender's run gets an
empty temporary directory.
A fork is a complete, independent repository — its own .git, its own object
store — containing only project history and this tree's saved snapshot.
The mirror's private refs, unreachable objects and host metadata stay on
the host; no hardlinks or object alternates connect the two repositories.
A project's tree is a cache rather than the only copy: each turn's tree is snapshotted and pushed to the mirror under the tree's own ref, so releasing one is a disk decision and resuming lays that ref back over a fresh fork. Releasing deletes the folder and keeps the row. What the agent did with git in there is the agent's — nothing here commits.
A registered user's thread in no project gets a tree too, forked from the blank mirror and thrown away when the run that made it ends. Same mechanism, opposite ending: there is no project to keep it for.
A turn enters open to prepare its workspace and scope its lifetime.
Project exit checkpoints its exact volume; chat exit releases its temporary
directory. resolve records a volume and settles its path without preparing it.
Explicit save and dismiss resolve an owner's existing tree for
graph finalization and handoffs. The registry identifies the project and the
mirrors hold its checkpoints.
Source code in octomate/managers/workspaces/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
identity
property
¶
Who the machine is when it writes a snapshot — the mirrors: block's,
read rather than copied, so a turn's work and a folder sync into a mirror
carry one name and cannot drift into two.
root ¶
The owner's storage directory; volumes select individual host directories.
Resolving it creates neither files nor database rows.
resolve
async
¶
resolve(
thread_id: UUID7,
project: Project | None,
owner_id: UUID7 | None,
ref: str | None = None,
) -> Workspace
Record the owner's volumes and settle their paths without making files.
A registered owner's tree comes with their package cache and their agent
configuration. Unregistered
senders receive a temporary chat path alone and cannot resolve project
workspaces. This writes or stamps registered volume rows; use
volumes.find for read-only inspection.
Source code in octomate/managers/workspaces/base.py
open
async
¶
open(
thread_id: UUID7,
project: Project | None,
owner_id: UUID7 | None,
ref: str | None = None,
) -> AsyncGenerator[Workspace]
Prepare a workspace and own its checkpoint or release when the run ends.
Source code in octomate/managers/workspaces/base.py
enter
async
¶
Prepare the working tree's source, then enter the volume composition.
Source code in octomate/managers/workspaces/base.py
prepare
async
¶
Prepare a persistent project tree for a handoff outside an invocation.
Source code in octomate/managers/workspaces/base.py
save
async
¶
Leave this owner's finished turn where losing their tree cannot cost it: a validated snapshot imported into the project's mirror as the tree's own ref.
A fork owns its objects outright — nothing in a tree survives its removal — so without the import the tree is the only copy of what the turn did, and releasing it would be losing work rather than evicting a cache. That is what makes a tree disposable, and why the sweep is a disk decision.
A thread with no tree for this owner — in no project, or one whose turn never forked one — has nothing to leave.
The ref records what the tree holds rather than a history to protect. Imports update only that ref in the mirror and never reach the upstream.
A failure is logged rather than raised. The turn has already happened and already answered; failing it now would report a delivered answer as an error, and the next turn saves the same work again.
Source code in octomate/managers/workspaces/base.py
saved
async
¶
Whether this volume matches its canonical snapshot in the host mirror.
Workspace markers are writable by the harness and cannot authorize reclamation. Invalid or unreadable captures leave the tree unsaved.
Source code in octomate/managers/workspaces/base.py
reclaim
async
¶
Delete a tree's folder only while nothing uses it and the mirror has its work, and answer whether it went.
The storage lock is held from the first check to the deletion. A turn that arrives meanwhile waits and forks afresh, instead of starting in a folder that is about to go or leaving work there after it was verified.
Source code in octomate/managers/workspaces/base.py
prune
async
¶
Release every project tree nothing has used for idle seconds, and
answer with the volumes that lost their folder.
Eviction, not a decision about whether a thread is over: abandonment is
unobservable, so rather than guessing, being wrong here costs the next turn
a fork instead of costing anyone their work. Which is only true of a tree
the mirror already has, so one holding anything unsaved is kept and said
out loud. Idleness is read from the row's last_used_at, which every
open stamps.
A folder in a user's root that no row owns is reported and never deleted: the row is written before the folder, so such a folder is something this manager did not make.
Source code in octomate/managers/workspaces/base.py
report_unowned
async
¶
Warn about every tree folder no row owns, and answer how many there are. Hidden folders are forks in progress, and are skipped.
Source code in octomate/managers/workspaces/base.py
sweep
async
¶
Prune on the interval, for as long as the host runs.
A sweep that fails is logged and the next one still happens: reclaiming disk is maintenance, and a host that stops serving because it could not tidy up has the priority backwards.
Source code in octomate/managers/workspaces/base.py
carry
async
¶
Give thread, landed in source's project, a tree holding this owner's
work as source left it — what a conversation moving to another thread
takes of its work — and fork it.
Saved first: the source's last turn may not have been, and what it left
uncommitted has to travel as uncommitted. The snapshot is filed under the
new tree's ref too, so its first fork resumes into it the way a released
tree does; on a branch of its own when the source was on its own, since
two trees pushing one branch would overwrite each other. A source with no
snapshot leaves thread to fork the project fresh.
Ignored files are copied across, an .env among them, since a snapshot
never holds them. Ignored directories are not: they are dependencies and
build output, which whatever runs in the landed tree makes again.
Source code in octomate/managers/workspaces/base.py
dismiss
async
¶
Release this owner's tree on their agent's word that the work in it is done — the one release that is asked for rather than swept up — and answer whether it went.
Saved first, and released only when the save took: the sweep's rule, that a tree holding work the mirror has not seen is never thrown away, does not bend for being asked. So what this costs is what a prune costs, a fork on the thread's next turn with the ref laid back over it.
Source code in octomate/managers/workspaces/base.py
octomate.managers.workspaces.mirrors ¶
Project mirrors: the pristine checkouts workspaces fork from, and the git plumbing that syncs them.
BATCH_GIT_ENV
module-attribute
¶
MirrorManager ¶
Every project's mirror: a pristine git checkout at mirrors_dir/<project>,
made from the project's upstream and kept current by syncing from it.
A remote upstream is cloned and freshened by fetching; a directory upstream is
git init'd and freshened by staging the folder's state and committing when
anything changed — the same job with a directory in place of a URL, so the
default branch becomes a history of the folder. The folder stays authoritative:
carrying reviewed work back out to it is a deliberate step, not part of syncing.
A mirror stays on its default branch and no run ever writes to it; workspaces fork from it and are disposable.
Source code in octomate/managers/workspaces/mirrors.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
path ¶
The initial storage location for a project's mirror or the blank mirror.
Existing mirror records retain their stored location through resolve.
Absolute, because directory sync points GIT_DIR here while running in the
upstream folder, where a relative path would resolve against the wrong tree.
Source code in octomate/managers/workspaces/mirrors.py
resolve
async
¶
The service-owned mirror volume, without synchronizing its files.
Source code in octomate/managers/workspaces/mirrors.py
name ¶
What this mirror is filed under, which is also what its lock and its freshness stamp are keyed by. The blank mirror is dot-prefixed, to keep it out of the way of the mirrors it sits among — those are named after projects, and so after directories people actually have.
Source code in octomate/managers/workspaces/mirrors.py
sync
async
¶
The mirror, current enough to fork from: created from the upstream when missing, freshened from it when the freshness window has lapsed.
Serialized per mirror, so a burst of materializations costs one sync: the
making of it waits inside create, and the freshening of it waits here, on
the same lock. Which is why create is called before this takes it —
asyncio.Lock is not reentrant, and both halves are the same mirror's turn.
A freshen that fails degrades to the stale mirror with a warning rather than failing the caller — work continues on what the machine already has, and the stale stamp is not renewed, so the next sync tries again. A mirror that cannot be created is a hard failure: there is nothing to fall back to.
Source code in octomate/managers/workspaces/mirrors.py
create
async
¶
The mirror, made where there is none, and where it is.
A GitHub project is cloned onto its default branch. A local project is
git init'd with its folder's contents committed. With no project at all it is the blank mirror,
which is a git init and one empty commit — that commit being what makes it
forkable rather than special, since a repository with no commit clones onto
an unborn branch, where git refuses the ordinary things a run does with one.
Its service-owned volume has no project association.
Serialized per mirror and idempotent, which is what the blank one needs —
two threads in no project starting at once both ask for it, and a mirror
half-made is a mirror something would fork. sync holds the same lock for
the freshening half, and takes it after this rather than around it.
A partial mirror is worse than none — it would read as existing and turn every later sync into a stale-mirror warning — so a creation that fails or is cancelled removes what it left before the error travels on.
Source code in octomate/managers/workspaces/mirrors.py
freshen
async
¶
Bring an existing mirror up to its upstream: fetch and move the default branch for a remote, stage-and-commit the folder for a directory.
--prune follows upstream branch deletions; thread refs live outside the
fetched refspec, so pruning never touches them. The hard reset is what a
mirror allows that a working checkout would not: nothing else writes
here, so the default branch simply follows upstream, force-pushes included.
Source code in octomate/managers/workspaces/mirrors.py
commit_folder
async
¶
One sync of a directory upstream: stage exactly the folder's state into
the mirror at path, and commit only when anything changed.
Git's own index does the comparison. With GIT_WORK_TREE pointing at the
folder, add -A stages additions, edits, and deletions in one pass while
honoring the folder's own .gitignore — which is what keeps a served
checkout's .octomate/ out of its mirror — and no .git is ever created
in the folder itself. The final reset materializes the commit into the
mirror's tree; it never git cleans, so untracked state the mirror keeps
survives every sync.
Source code in octomate/managers/workspaces/mirrors.py
octomate.managers.habitat ¶
Invocation resources and each registered user's persistent habitat.
RunInterrupted ¶
Interruption
dataclass
¶
A run-owned stop request, retained until its harness is ready to handle it.
Source code in octomate/managers/habitat.py
Invocation
dataclass
¶
Core-authorized resources, valid only inside the core's owning contexts.
Core prepares the storage and acquires any habitat before yielding this value. Adapters borrow them for the call; core owns their lifetime and the cleanup required on completion, failure, or cancellation.
Source code in octomate/managers/habitat.py
interruption
class-attribute
instance-attribute
¶
environment
property
¶
Settings that point the harness at the owner's own volumes, as the habitat shows them.
Package managers keep their stores beneath the cache. Codex keeps its memory-bearing home in the config volume in every runtime; the other native CLIs retain their host configuration and login.
cwd
property
¶
The harness's working directory; workspace.path remains host-side.
Residence
dataclass
¶
Source code in octomate/managers/habitat.py
HabitatManager
dataclass
¶
Source code in octomate/managers/habitat.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
residences
class-attribute
instance-attribute
¶
invoke
async
¶
invoke(
*,
thread: Thread,
conversation: Conversation,
owner_id: UUID7 | None,
interruption: Interruption | None = None,
) -> AsyncGenerator[Invocation]
Own one call's resources for the full consumption of its events.
A sandbox runs for a registered user; an unregistered sender is refused before anything is prepared.
Source code in octomate/managers/habitat.py
residenced ¶
Whether an invocation of the conversation is inside the user's sandbox now.
Source code in octomate/managers/habitat.py
residence ¶
Internal lookup; callers must supply a core-authorized owner.
Source code in octomate/managers/habitat.py
status ¶
report ¶
report(
residence: Residence,
phase: Literal[
"unknown",
"preparing",
"starting",
"ready",
"stopping",
"stopped",
"failed",
],
*,
scope: InvocationScope | None = None,
invocation_id: UUID7 | None = None,
error: HabitatError | None = None,
) -> None