livery.workshop._sweep¶
livery.workshop._sweep ¶
What the workshop leaves in the runner's directories, and the sweep that bounds it.
The runner's data directory holds the workshop's durable state: the
issue worktrees under worktrees/<repo>/ and the loop's workspace.
footman's collector never touches it, by design. This module is the
workshop's sweeper, registered under footman's footman.sweepers
entry point and run by fm janitor, by the daily collector child,
and, for the worktrees alone, by every fm start.
It also runs the state store's own janitor over every series the
workshop keeps (livery.workshop._series), in the scope the run
has: the checkout's local series on a machine, the remote series too
inside CI.
The rules, each saying what went or why it stayed:
- A worktree whose linked git directory is gone (its checkout was deleted) goes. This rule is quick and offline: no forge is asked.
- A worktree whose issue is closed, or whose branch's pull request
merged, goes when the branch holds nothing that exists nowhere else,
decided by the one keep-or-drop rule
fm issue.closeuses (livery.workshop._submit.only_local_work): a tree whose tip the merge took holds nothing only there, whatever a squash did to the ancestry. A tree with uncommitted changes or commits past the merge stays and is named, and so is a tree whose issue is open or whose forge cannot be asked. A closed issue's tree also stays while its branch heads an open pull request, asfm issue.closeleaves it, since that pull request still needs the branch. A tree whose name carries no issue number is judged by its branch's pull request alone. This rule asks the forge, since asking is what proves the removal safe. - A local branch of the checkout whose pull request merged and took
its tip goes by the same rule; the branch a linked worktree holds
belongs to the worktree rule, and the branch the checkout stands on
is named for
fm syncto step off. On demand only, like the rule above. - Every declared series of the state store is bounded, windows, ages, and orphans, as livery.git.sweep says.
- The config directory is reported, never touched: anything beside the user's config, tasks file, and shared env file is named. The loop's workspace is reported by size and kept.
Functions:
| Name | Description |
|---|---|
sweep |
The workshop's sweep, footman's sweeper contract; the lines to print. |
finish_worktree |
Remove linked worktree tree and its local branch when its work landed. |
sweep_worktrees |
Sweep every |
sweep_branches |
Drop the checkout's local branches whose pull request merged and took their tip. |
finish_branch |
Drop branch when its pull request merged and took its tip; whether it went. |
finish_flow |
Clean up finished work: one branch/worktree, or every landed one with all_. |
sweep_store |
Bound every declared series of the state store in the run's scope; the lines. |
report_config |
Name what sits in the config directory beside the user's own files. |
report_loop |
The loop's workspace by size, kept: |
Attributes:
| Name | Type | Description |
|---|---|---|
WORKTREES |
|
|
LOOP |
|
|
CONFIG_OWN |
|
|
sweep_branch |
|
sweep ¶
The workshop's sweep, footman's sweeper contract; the lines to print.
The state store's series are the checkout's: the one above the
working directory, or the root among facts when one is
given, None for no checkout at all.
Source code in packages/workshop/src/livery/workshop/_sweep.py
finish_worktree ¶
finish_worktree(tree: Path, *, name: str = '', dry_run: bool = False, allow_chdir: bool = False) -> tuple[bool, str]
Remove linked worktree tree and its local branch when its work landed.
The one keep-or-drop rule shared by fm finish, fm janitor,
and fm start: queries the owning checkout's forge contract
(_forge_root), verifies the issue closed or PR merged with no
open PR remaining, and confirms only_local_work is empty before
touching anything. When allow_chdir is set and the process stands
inside tree, moves to the owning checkout first and prints the
cd hint.
Source code in packages/workshop/src/livery/workshop/_sweep.py
sweep_worktrees ¶
Sweep every <repo>/<number>-<slug> worktree under home; the lines.
Source code in packages/workshop/src/livery/workshop/_sweep.py
sweep_branches ¶
Drop the checkout's local branches whose pull request merged and took their tip.
A branch a linked worktree holds is the worktree rule's; the base branch is never touched; the branch the checkout stands on is named when allow_switch is False, since a sweep never moves a person's HEAD. Asks the forge, since asking is what proves the removal safe. The lines say what went and why the rest stayed.
Source code in packages/workshop/src/livery/workshop/_sweep.py
finish_branch ¶
finish_branch(root: Path, branch: str, *, current: str, dry_run: bool, allow_switch: bool = False, repo: Any = None) -> tuple[bool, str]
Drop branch when its pull request merged and took its tip; whether it went.
The one branch cleanup rule shared by fm finish, fm janitor,
fm sync, and fm start. When branch is checked out
(current), allow_switch steps onto an up-to-date main and
deletes it through teardown_branch; without allow_switch, the
branch stays and is named for fm sync to step off. repo is the
forge's repository, asked for when absent. The line says what went,
or why it stayed.
Source code in packages/workshop/src/livery/workshop/_sweep.py
finish_flow ¶
Clean up finished work: one branch/worktree, or every landed one with all_.
Source code in packages/workshop/src/livery/workshop/_sweep.py
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 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
sweep_store ¶
Bound every declared series of the state store in the run's scope; the lines.
Source code in packages/workshop/src/livery/workshop/_sweep.py
report_config ¶
Name what sits in the config directory beside the user's own files.
Source code in packages/workshop/src/livery/workshop/_sweep.py
report_loop ¶
The loop's workspace by size, kept: fm ci.e2e reuses it.