adapter
adapter
¶
BatonAdapter — wires the baton into the conductor.
Step 28: Replace monolithic execution with the baton's event-driven model.
The adapter is the bridge between the conductor (JobManager) and the baton (BatonCore). It handles:
-
Job submission → baton registration (Surface 1) JobConfig → Sheet[] → SheetExecutionState[] → BatonCore.register_job()
-
Dispatch callback → backend acquisition (Surface 2) BatonCore dispatches → adapter acquires backend → spawns musician task
-
Prompt assembly (Surface 3) Creates SheetContext, calls PromptBuilder.build_sheet_prompt()
-
State synchronization (Surface 4) BatonSheetStatus ↔ CheckpointState.SheetStatus mapping
-
EventBus integration (Surface 5) Baton events → ObserverEvent format → EventBus.publish()
-
Rate limit callback bridge (Surface 6) Musician extracts wait time → SheetAttemptResult → baton handles
-
Lifecycle (Surface 8) The adapter is always initialized by the conductor at startup
Design decisions: - Checkpoint is source of truth. Baton rebuilds from checkpoint on restart. - Save checkpoint FIRST, then update baton state (prevents re-execution). - The adapter does NOT own the baton's main loop — the manager runs it. - Concert support: sequential score submission (option 1 from wiring analysis).
Wiring analysis: step-28-wiring-analysis.md from the v1-beta-v3
movement-2 workspace (preserved in the project's private history archive).
Attributes¶
Classes¶
ProcessGroupCleanupResult
dataclass
¶
ProcessGroupCleanupResult(cleanup_generation='unbound', tracked_process_groups=0, sigterm_attempted=0, sigterm_succeeded=0, sigterm_failed=0, sigterm_skipped=0, escalation_state='not_needed', sigkill_attempted=0, sigkill_succeeded=0, sigkill_failed=0, residual_check_state='unverified', residual_process_groups=None)
Observable process-group effects of one Baton deregistration.
BatonAdapter
¶
BatonAdapter(*, event_bus=None, max_concurrent_sheets=10, state_sync_callback=None, persist_callback=None, learning_store=None, rate_limit_reporter=None, diagnostic_snapshot_fn=None, flow_pause_callback=None, flow_concert_callback=None)
Bridges the conductor (JobManager) and the baton (BatonCore).
The adapter owns: - A BatonCore instance (event loop, sheet registry, state machine) - A mapping of job_id → Sheet[] (for prompt rendering at dispatch time) - Active musician tasks (asyncio.Task per dispatched sheet)
The adapter does NOT own: - The BackendPool (injected by the manager) - The EventBus (injected by the manager) - The CheckpointState (managed by the manager's state backend)
Usage::
adapter = BatonAdapter(event_bus=bus)
adapter.set_backend_pool(pool)
# Register a job
adapter.register_job("j1", sheets, deps)
# Run the baton (blocks until shutdown)
await adapter.run()
Initialize the BatonAdapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_bus
|
EventBus | None
|
Optional EventBus for publishing events to subscribers. |
None
|
max_concurrent_sheets
|
int
|
Global concurrency ceiling for dispatch. |
10
|
state_sync_callback
|
StateSyncCallback | None
|
Deprecated — kept for backward compat. Phase 2 uses persist_callback instead. |
None
|
persist_callback
|
PersistCallback | None
|
Called with job_id after significant state transitions (terminal, dispatch) to persist CheckpointState to the registry. Replaces the sync layer. |
None
|
learning_store
|
GlobalLearningStore | None
|
Optional GlobalLearningStore handle for injecting learned patterns into prompts (#200). None (and store-less paths) cleanly skip the layer. |
None
|
rate_limit_reporter
|
RateLimitReporter | None
|
Optional async write-through to the daemon's RateLimitCoordinator (#206). Every RateLimitHit the run loop processes is mirrored here so daemon-level consumers (backpressure, submit-time warnings, the scheduler) see the same limits the baton is already enforcing at dispatch. None (tests, standalone use) skips the mirror. |
None
|
diagnostic_snapshot_fn
|
DiagnosticSnapshotFn | None
|
Optional sync runtime-diagnostics provider (#133): observer file/process events + resource state attached to the retry failure-evidence context so the agent sees what its previous attempt actually did. Fail-open; None skips enrichment (plain #201 evidence). |
None
|
Source code in src/marianne/daemon/baton/adapter.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | |
Attributes¶
Methods:¶
set_backend_pool
¶
Inject the BackendPool for backend acquisition.
Must be called before dispatching any sheets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pool
|
BackendPool
|
The backend pool from the manager. |
required |
Source code in src/marianne/daemon/baton/adapter.py
set_cron_handler
¶
schedule_cron_tick
¶
Schedule a recurring-score tick on the shared timer wheel.
cancel_cron_tick
¶
set_mcp_pool
¶
set_memory_gate
¶
Inject the memory dispatch gate; jobs already registered are handed to it.
Source code in src/marianne/daemon/baton/adapter.py
configure_retry
¶
configure_retry(*, base_delay=None, exponential_base=None, max_delay=None, jitter=None, startup_failure_floor=None, startup_failure_window=None)
Thread the score's RetryConfig backoff settings to the baton (#196).
Pass-through to BatonCore.configure_retry. Called once per job at
registration (and recovery) so score-level retry: timing reaches the
scheduler instead of the hardcoded defaults.
Source code in src/marianne/daemon/baton/adapter.py
register_job
¶
register_job(job_id, sheets, dependencies, *, max_cost_usd=None, max_sheet_cost_usd=None, max_retries=3, max_completion=5, completion_threshold_percent=0.0, escalation_enabled=False, self_healing_enabled=False, prompt_config=None, learning_config=None, parallel_enabled=None, parallel_max_concurrent=None, parallel_fail_fast=False, cross_sheet=None, pacing_seconds=0.0, live_sheets=None, techniques=None, memory=None, memory_movement_names=None, stale_detection=None, spec_config=None, spec_tags=None, stagger_delay_ms=0, skip_when=None, code_execution=None, agent_card=None, cleanup_generation=None, schedule_id=None, scheduled_due_at=None, loops=None, triggers=None, flow_state=None, flow_variables=None, declared_products=None, ledger_scope=None)
Register a job with the baton for event-driven execution.
Converts Sheet entities to SheetExecutionState and registers them with the baton's sheet registry.
Phase 2: when live_sheets is provided, uses those SheetState
objects directly instead of creating new ones. This ensures the
baton writes to the same objects that live in _live_states,
eliminating the need for a sync layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
Unique job identifier (conductor job_id). |
required |
sheets
|
list[Sheet]
|
Sheet entities from build_sheets(). |
required |
dependencies
|
dict[int, list[int]]
|
Dependency graph {sheet_num: [dep_nums]}. |
required |
max_cost_usd
|
float | None
|
Optional per-job cost limit. |
None
|
max_retries
|
int
|
Max normal retry attempts per sheet. |
3
|
max_completion
|
int
|
Max completion mode attempts per sheet. |
5
|
escalation_enabled
|
bool
|
Enter fermata on exhaustion. |
False
|
self_healing_enabled
|
bool
|
Try self-healing on exhaustion. |
False
|
prompt_config
|
PromptConfig | None
|
Optional PromptConfig for full prompt rendering. When provided, creates a PromptRenderer for this job that handles the complete 9-layer prompt assembly pipeline. |
None
|
parallel_enabled
|
bool | None
|
Whether parallel execution is enabled. Explicit False enforces the score-facing serial contract; None retains legacy direct-caller scheduling behavior. |
None
|
parallel_max_concurrent
|
int | None
|
Score-owned dispatch ceiling when parallel execution is enabled. None preserves legacy/global behavior. |
None
|
parallel_fail_fast
|
bool
|
Stop starting new sheets in this job after a failure when parallel execution is enabled. |
False
|
cross_sheet
|
CrossSheetConfig | None
|
Optional CrossSheetConfig for cross-sheet context (F-210). When provided, the adapter collects previous sheet outputs and workspace files at dispatch time. |
None
|
cleanup_generation
|
str | None
|
Optional manager-issued execution generation. Direct adapter registrations allocate their own local value. |
None
|
Source code in src/marianne/daemon/baton/adapter.py
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | |
get_router
¶
Return the per-job TechniqueRouter, or None if not activated.
The router is created by :meth:register_job when the job declares
one or more techniques. Jobs without techniques (the default for
legacy scores) have no router and classification is skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job to look up. |
required |
Returns:
| Type | Description |
|---|---|
TechniqueRouter | None
|
The job's TechniqueRouter if one was activated, else None. |
Source code in src/marianne/daemon/baton/adapter.py
get_a2a_inbox
¶
Return the per-job A2A inbox, or None when no card is registered.
get_process_group_cleanup_result
¶
Return the live cleanup evidence for a deregistered job.
The returned result is intentionally live while the SIGTERM grace
callback is pending. Callers can therefore observe the later
SIGKILL and residual-process check instead of retaining the initial
pending snapshot forever.
Source code in src/marianne/daemon/baton/adapter.py
begin_cleanup_generation
¶
Begin or bind one local execution generation for cleanup evidence.
Source code in src/marianne/daemon/baton/adapter.py
deregister_job
¶
Remove a job from the adapter and baton.
Cleans up all per-job state including active tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job to remove. |
required |
Source code in src/marianne/daemon/baton/adapter.py
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 | |
recover_job
¶
recover_job(job_id, sheets, dependencies, checkpoint, *, max_cost_usd=None, max_sheet_cost_usd=None, max_retries=3, max_completion=5, completion_threshold_percent=0.0, escalation_enabled=False, self_healing_enabled=False, prompt_config=None, learning_config=None, parallel_enabled=None, parallel_max_concurrent=None, parallel_fail_fast=False, cross_sheet=None, pacing_seconds=0.0, live_sheets=None, techniques=None, memory=None, memory_movement_names=None, stale_detection=None, spec_config=None, spec_tags=None, stagger_delay_ms=0, skip_when=None, code_execution=None, agent_card=None, loops=None, triggers=None, flow_variables=None, declared_products=None, ledger_scope=None)
Recover a job from a checkpoint after conductor restart.
Rebuilds baton state from the persisted CheckpointState. Terminal sheets (completed, failed, skipped) keep their status. In-progress sheets are reset to PENDING because their musicians died when the conductor restarted. Attempt counts are preserved to avoid infinite retries.
Design invariant: Checkpoint is the source of truth. The baton rebuilds from checkpoint, not the reverse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
Unique job identifier. |
required |
sheets
|
list[Sheet]
|
Sheet entities from build_sheets() — same config that produced the original job. |
required |
dependencies
|
dict[int, list[int]]
|
Dependency graph {sheet_num: [dep_nums]}. |
required |
checkpoint
|
CheckpointState
|
Persisted CheckpointState loaded from workspace. |
required |
max_cost_usd
|
float | None
|
Optional per-job cost limit. |
None
|
max_retries
|
int
|
Max normal retry attempts per sheet. |
3
|
max_completion
|
int
|
Max completion mode attempts per sheet. |
5
|
escalation_enabled
|
bool
|
Enter fermata on exhaustion. |
False
|
self_healing_enabled
|
bool
|
Try self-healing on exhaustion. |
False
|
prompt_config
|
PromptConfig | None
|
Optional PromptConfig for prompt rendering. |
None
|
parallel_enabled
|
bool | None
|
Whether parallel execution is enabled. Explicit False restores the score-facing serial contract; None retains legacy direct-caller scheduling behavior. |
None
|
parallel_max_concurrent
|
int | None
|
Restored score-owned dispatch ceiling. |
None
|
parallel_fail_fast
|
bool
|
Restored score-owned fail-fast policy. |
False
|
cross_sheet
|
CrossSheetConfig | None
|
Optional CrossSheetConfig for cross-sheet context (F-210). |
None
|
Source code in src/marianne/daemon/baton/adapter.py
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 | |
get_sheet
¶
Get a Sheet entity for a registered job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job identifier. |
required |
sheet_num
|
int
|
The sheet number. |
required |
Returns:
| Type | Description |
|---|---|
Sheet | None
|
The Sheet entity, or None if not found. |
Source code in src/marianne/daemon/baton/adapter.py
wait_for_completion
async
¶
Wait until a job reaches terminal state.
Blocks until all sheets in the job are completed, failed, skipped, or cancelled. Used by the manager's _run_job_task to await baton execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job to wait for. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if all sheets completed successfully, False if any failed. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the job is not registered. |
Source code in src/marianne/daemon/baton/adapter.py
has_job
¶
Whether the baton is currently tracking this job.
Delegates to the baton's presence predicate. Used by the manager to cancel auto-recovered baton jobs that have no wrapper task (#162).
Source code in src/marianne/daemon/baton/adapter.py
has_completed_sheets
¶
Check if any sheet in the job reached COMPLETED status.
F-145: Used by the manager to set completed_new_work after baton execution. The zero-work guard for concert chaining needs to know whether any sheet completed new work — not just whether all sheets succeeded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if at least one sheet completed, False otherwise. |
Source code in src/marianne/daemon/baton/adapter.py
clear_instrument_rate_limit
¶
Clear instrument rate limit state in the baton core.
Delegates to BatonCore.clear_instrument_rate_limit(). Also
moves WAITING sheets back to PENDING so they can be re-dispatched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instrument
|
str | None
|
Instrument name to clear, or |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of instruments whose rate limit was cleared. |
Source code in src/marianne/daemon/baton/adapter.py
publish_sheet_skipped
async
¶
Publish a sheet skip event to the EventBus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
SheetSkipped
|
The sheet skip event. |
required |
Source code in src/marianne/daemon/baton/adapter.py
publish_job_event
async
¶
Publish a job-level event to the EventBus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
The job identifier. |
required |
event_name
|
str
|
Event name (e.g., "job.started", "job.completed"). |
required |
data
|
dict[str, Any] | None
|
Optional event data. |
None
|
Source code in src/marianne/daemon/baton/adapter.py
active_musicians
¶
Every musician still in flight: job, sheet, instrument, model, elapsed.
The rows a graceful drain is waiting on (GH #476). Task authority is what counts — a sheet relabelled WAITING on the baton side is still in flight while its task runs.
Source code in src/marianne/daemon/baton/adapter.py
set_max_concurrent_sheets
¶
Live-resize the global sheet-dispatch ceiling (#408, #231 pattern).
The run loop rebuilds DispatchConfig from this attribute every
cycle, so an in-place update takes effect on the next dispatch pass —
no object replacement, no baton restart. Lowering never cancels
in-flight sheets: running executions drain, new dispatch waits until
the global running count drops below the new limit. Raising enqueues a
coalesced DispatchRetry so waiting sheets dispatch immediately
instead of idling until an unrelated event.
Source code in src/marianne/daemon/baton/adapter.py
sync_model_concurrency
¶
Replace the live per-model cap map from fresh profiles (#408).
Delegates to BatonCore.sync_model_concurrency (atomic swap with
removal) and wakes the dispatch loop so a raised cap releases
waiting sheets without waiting for an unrelated event.
Source code in src/marianne/daemon/baton/adapter.py
model_concurrency_snapshot
¶
resolve_fermata
¶
Resolve a FERMATA sheet on the composer's behalf (#361).
Backs mzt resolve via the job.resolve_escalation IPC method.
Writes the SAME decision marker a composer would create by hand,
then enqueues an immediate FermataCheck so the existing poll
handler consumes it — one consumption path, restart-safe (the
marker survives a crash between write and consumption), and the
consumed/ audit trail is preserved.
Returns:
| Type | Description |
|---|---|
bool
|
|
str
|
the decision is invalid or the sheet is not in FERMATA. |
Source code in src/marianne/daemon/baton/adapter.py
run
async
¶
Run the baton's event loop with dispatch integration.
Processes events from the inbox, updates state, dispatches ready sheets, and publishes events to the EventBus.
Runs until the baton receives a ShutdownRequested event.
Source code in src/marianne/daemon/baton/adapter.py
5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 | |
shutdown
async
¶
Gracefully shut down the adapter.
Cancels all active musician tasks and closes the backend pool.
Source code in src/marianne/daemon/baton/adapter.py
Functions:¶
baton_to_checkpoint_status
¶
Identity mapping — Phase 2 unified the enums.
Kept for backward compatibility with tests that import this function. Since BatonSheetStatus IS SheetStatus, this is just status.value.
Source code in src/marianne/daemon/baton/adapter.py
checkpoint_to_baton_status
¶
Reconstruct SheetStatus from string — Phase 2 unified the enums.
Kept for backward compatibility with tests that import this function.
Source code in src/marianne/daemon/baton/adapter.py
attempt_result_to_observer_event
¶
Convert a SheetAttemptResult to the ObserverEvent format.
Maps baton musician results to the event names the EventBus subscribers expect (dashboard, learning hub, notifications).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SheetAttemptResult
|
The musician's execution report. |
required |
Returns:
| Type | Description |
|---|---|
ObserverEvent
|
Dict matching the ObserverEvent TypedDict shape. |
Source code in src/marianne/daemon/baton/adapter.py
skipped_to_observer_event
¶
Convert a SheetSkipped event to ObserverEvent format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
SheetSkipped
|
The sheet skip event. |
required |
Returns:
| Type | Description |
|---|---|
ObserverEvent
|
Dict matching the ObserverEvent TypedDict shape. |
Source code in src/marianne/daemon/baton/adapter.py
sheets_to_execution_states
¶
Convert Sheet entities to SheetExecutionState dict for baton registration.
Each Sheet becomes a SheetExecutionState with the baton's extended tracking fields. The sheet_num is the dict key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sheets
|
list[Sheet]
|
List of Sheet entities from build_sheets(). |
required |
max_retries
|
int
|
Maximum normal retry attempts per sheet. |
3
|
max_completion
|
int
|
Maximum completion mode attempts per sheet. |
5
|
Returns:
| Type | Description |
|---|---|
dict[int, SheetExecutionState]
|
Dict of sheet_num → SheetExecutionState. |
Source code in src/marianne/daemon/baton/adapter.py
extract_dependencies
¶
Extract baton-compatible dependency graph from a JobConfig.
The baton expects: {sheet_num: [dep_sheet_num, ...]}
When config.sheet.dependencies is set (non-empty), it is used
as the authoritative DAG. Stage-level dependencies are expanded to
sheet-level: if stage S has a fan-out of 3 (sheets 4,5,6) and
depends on stage T (sheets 1,2,3), each of 4/5/6 depends on all of
1/2/3. Stages not listed in the dependencies map are treated as
having no dependencies (independent).
When config.sheet.dependencies is empty or absent, falls back to
the legacy linear chain: all sheets in stage N+1 depend on all sheets
in stage N.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Any
|
Parsed JobConfig with sheet.get_fan_out_metadata(). |
required |
Returns:
| Type | Description |
|---|---|
dict[int, list[int]]
|
Dict of sheet_num → list of dependency sheet_nums. |
Source code in src/marianne/daemon/baton/adapter.py
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 509 510 511 512 | |