Shift-handoff scheduled task + license gating
This guide covers how build_mes_runtime in engine/node_main.py wires ShiftHandoffTask (engine/shift_handoff.py) against a real, running MES Node instance's own license file.
Checking a license is a pure local operation: read the file, verify its signature, compare expires_at to today. It is re-derived fresh on every LicenseManager.state access, with no periodic sync task.
A handoff describes the Node it runs on. Each of its Activity Log reads (the resume point, the restart gap and the window's entries) is filtered by this Node's own node type and instance, so a peer's activity in the window is not in it. A site's activity across Nodes is the job of the order trail and the genealogy (see order-trail-assembly.md and traceability.md).
Contents
- How the MES runtime builds it
- Two Configuration Schema fragments
- Bounded inputs
- The license-gating wiring itself
- Testing without a real day boundary
- Pitfalls
- Coverage gaps in a window
How the MES runtime builds it
build_mes_runtime has a fully optional shift_handoff branch.
- It is nested inside the existing
inferencebranch.shift_handoffrequiresinferencethroughdependentRequired, soinference_clientandsignoff_storeare already real objects by the time this branch runs. - It is placed after the
deviation_flaggingandcosting_varianceblocks, deliberately. Those two blocks' ownConfigValidationErrorpaths (a collidingdata_source, an ERP-lesspeerslist) must still raise before the license-file read. A config author fixing an unrelated collision then doesn't also need a valid license file on disk just to see that unrelated error.
The helper _build_shift_handoff_runtime bundles the whole branch. It:
- reads and verifies this appliance's own offline license file (
verify_license_fileinengine/license_server.py); - builds a
LicenseManagerover it; - optionally builds a
CasePrecedentRetriever, whenembeddingis configured; - builds the
ShiftHandoffTaskitself; - returns one
ScheduledTask,"shift-handoff"(which wrapsShiftHandoffTask.run_scheduled), plus the one collaborator (embedding_client) thatmain()'sfinallyblock needs to close.
License file paths are site-wide Settings, not per-Node-Type config.
engine/config.pyhaslicense_file_pathandlicense_public_key_path, defaulting tolicense.jsonandlicense_public_key.pem. These matchengine/license_issuer.py's default output paths. There is one license file per appliance, regardless of how many Node instances it runs.build_mes_runtimetakes a matchingsettings: Settings | None = Noneparameter (defaulting toget_settings()). This is the same caller-supplied-or-build-your-own convention thatactivity_log,queue,storeandsignoff_storeuse. A test points aLicenseManagerat its own throwaway signed license file instead of this process's real one, withSettings(...).model_copy(update={...}).
Two Configuration Schema fragments
"config": {
"shift_handoff": {
"interval_seconds": 28800,
"shift_schedule": { "$shared": "shift-schedule" }
},
"embedding": {
"endpoint": "http://ollama.example.local:11434",
"model": "nomic-embed-text",
"dimensions": 768
}
}
shift_handoff
shift_handoff has the two fields described here, interval_seconds and shift_schedule, plus two optional limits (max_window_shifts and max_prompt_entries, under Bounded inputs below).
interval_secondsdrives bothShiftHandoffTask'sshift_duration(its no-shift_schedulefallback window, below) and the"shift-handoff"ScheduledTask's cadence. For a real deployment these are the same number by construction: run once per shift, summarizing the shift that just ended.- It requires
inferencealongside it (dependentRequiredinnode_type.config_schema,node-types/mes/node_type.json). The reasoning is the same asdeviation_flagging's own requirement ("no CaseTriage handler registered"), applied here toShiftHandoffTask'sInferenceClientandSignoffStore.
shift_schedule
shift_schedule is optional. It is a real, wall-clock-anchored shift calendar:
{"anchor": "<ISO 8601 datetime, timezone-aware>", "duration_seconds": <number>}
It is meant to be referenced through the existing "$shared" config-fragment mechanism (engine/config_loader.py). Every Node Type at a site then shares one fragment and agrees on the same shift boundaries, rather than each hand-configuring its own.
_build_shift_handoff_runtime builds it into engine.shift_schedule.ShiftSchedule and passes it to ShiftHandoffTask. The task uses it for exactly one thing: the one-time _last_run_end seed that its first scheduled run's window start comes from.
- With a schedule: the seed is
ShiftSchedule.most_recent_boundary, the most recently elapsed real shift boundary. - Without one: the seed is
clock() - shift_duration. After every restart, that would land on an arbitrary, off-calendar window.
Every call after the first continues from whichever window the previous call produced. It is deliberately not re-anchored to shift_schedule on every call. Re-anchoring would silently drop an entire elapsed shift's worth of activity if two calls were ever more than one shift's duration apart (a delayed tick, or interval_seconds not matching duration_seconds). Chaining from the previous end keeps every window gapless up to the reach described under Bounded inputs below. Only time older than that is skipped, and that is recorded.
A live Production Scheduling peer outranks shift_schedule
A real external scheduler stays the source of truth for "the current shift" where one is reachable.
ShiftHandoffTask takes an optional peer_client: PeerClient | None (engine/communication_interface.py) alongside shift_schedule. When it is given, the one-time construction-time seed tries a live current_shift query against a reachable Production Scheduling peer first. The peer relays whatever its own System Connector last read from the real external scheduler, never a Kindred-computed boundary (see engine/production_scheduling_answering.py for the answering side).
Order of preference for the seed:
- A live Production Scheduling peer's
current_shift. shift_schedule.most_recent_boundary.clock() - shift_duration.
It falls through to 2 and 3 when no peer answers usably. That covers every PeerClient.query failure mode (NoReachablePeerError, UnresponsiveServiceFailure, EnvelopeVersionError), and a reachable peer answering with no usable shift_start. production_scheduling_answering.py takes the fail-safe stance of answering empty event_fields on a failed poll against the real scheduler, never a raised exception. None of these cases is treated as a failure. $shared and clock() - shift_duration are legitimate secondary mechanisms here, not error states.
Why this catches more than other peer queries do. This is deliberately broader than every other PeerClient.query caller in this codebase (build_variance_data_point in costing_variance.py, report_event_to_erp in erp_reporting_wiring.py). Those let UnresponsiveServiceFailure and EnvelopeVersionError propagate as genuine errors, because they run from a poll tick or Trigger dispatch step already wrapped by Try/Catch's retry-and-dead-letter mechanism.
This query instead runs once, synchronously, during ShiftHandoffTask's construction, at MES node startup, with no such wrapper. Letting any PeerClient.query failure propagate uncaught would crash the entire node instance's startup over an optional secondary data source. Every attempt still gets its own logged ActivityLogEntry through PeerClient.query's log_try_catch_task wiring, whatever the outcome. A real reachability or version problem therefore stays visible in the Activity Log even though it never blocks startup.
The wiring.
_build_shift_handoff_runtimetakes a matchingpeer_client: PeerClient | None = Noneparameter, threaded straight through from_build_optional_mes_collaborators' ownpeer_client.- That is the same
PeerRegistryandPeerClientpair thecosting_varianceblock builds againstcommunication_interface.peers. It is built once whenevercommunication_interfaceis configured at all, and shared by both consumers. It was moved out of thecosting_varianceblock specifically so a site can wire this peer query without also configuringcosting_variance. shift_handoffhas nodependentRequiredoncommunication_interface. A site with no Production Scheduling peer worth connecting to for this one fact configures neither, andShiftHandoffTasknever attempts a peer query.$sharedstays a permanent fallback, not something every site is expected to migrate off of.identity.relevant_peer_node_typesinnode-types/mes/node_type.jsonlists"Production Scheduling"alongside"ERP", reflecting this live-query relationship.
Resolving $shared
build_mes_runtime resolves "$shared" references against its own shared_config_dir parameter (engine/node_main.py), plumbed from main's --shared-config-dir CLI flag. It is a plain optional path, the same convention --config and --node-type-dir use, not a Settings field. See build_mes_runtime's docstring for why: load_node_config runs before this function resolves any Settings, and Settings' required ollama_base_url has no default.
A config referencing "$shared" with no --shared-config-dir given fails closed with ConfigValidationError, as calling load_node_config directly with no shared_dir does.
embedding
embedding (EMBEDDING_CONFIG_SCHEMA in engine/embedding_config.py) is hand-duplicated into node_type.json, the same two-representations shape inference established. It is independently optional, with no dependentRequired of its own.
- When present alongside
shift_handoff,build_mes_runtimebuilds aCasePrecedentRetrieverover the Node Type's own Playbook table (the one document ingestion writes), limited to the document types the catalogue markscase_record, and passes it toShiftHandoffTask. - When absent,
ShiftHandoffTask's default (precedent_retriever=None) applies, and theLICENSEDdrafting path simply skips precedent retrieval rather than failing.
Bounded inputs: the precedent query, the window and the chat prompt
The precedent query is bounded because the reference backend (Ollama, nomic-embed-text) refuses a string of about 10.8 KB (roughly 350 entries joined as "{task_type}: {outcome}") with a 400 "the input length exceeds the context length", while accepting 9.3 KB. The embedding call comes before the store search, so an empty store does not avoid it.
An unbounded query would abort the run, the window would not advance, and the next tick's window would be larger and fail the same way until a restart. Nothing a model or the embedding backend receives grows with the number of entries.
The precedent query
It leads with the text of the window's drafted case summaries, newest first, whitespace collapsed. It uses at most half of the limit, and a lone summary longer than that is cut. The activity alone names no domain content and so cannot tell one topic from another: a query of activity alone scored every stored case alike against the reference backend. With no case summary in the window, the whole limit goes to the activity.
After the case text comes a |, then the activity:
- Entries are aggregated by task type and outcome, in first-seen order, with a count when a pair occurred more than once:
costing variance: flagged (3 times); reconcile: merged. - Its length follows the number of distinct pairs, not the number of entries. 5,000 entries over a handful of pairs is a few hundred characters.
- If the distinct pairs alone exceed the limit, the text is cut at a pair boundary and ends with
; ... and N more task/outcome pairs not shown. - A single pair longer than the limit is cut mid-pair, so the bound always holds.
The limit is the embedding profile's max_input_chars (embedding.max_input_chars, a positive whole number, default 6000).
Measured limits of the reference backend (Ollama, nomic-embed-text): a 10.8 KB input is refused with a 400, 9.3 KB is accepted, and a realistic 6,000-character query is accepted and returns the 768-dimension vector. The backend's limit is in tokens, so the characters-per-token ratio of the text matters, and the default leaves room for that. A backend or model with a smaller context needs a lower max_input_chars. Set it under that backend's own measured refusal point, not at it.
The embedding client does not retry a refusal
A 4xx answer from the backend (other than 408, 425 and 429) is deterministic for that input, so it raises on the first attempt instead of three. Timeouts, connection errors, 408, 425, 429 and 5xx are still retried up to max_attempts.
The error message carries the status code only, never the response body, which a cloud backend can fill with request or credential material. What the handoff does when retrieval fails is under Precedents in the draft below.
The window
shift_handoff.max_window_shifts (positive whole number, default 1) caps one drafted summary at that many shift_durations. shift_duration is interval_seconds (see above), not the shift_schedule duration.
- Splitting. A longer window (a long outage, a restart, a tick delayed past a boundary) is split into consecutive sub-windows, drafted oldest first. Up to three are drafted in one tick, and the rest wait for the next tick. A tick therefore cannot run an unbounded number of inference calls.
- A small overrun is drafted whole. A window over the cap by at most a tenth of it, or 15 minutes if that is more, is drafted whole. The scheduler waits the interval after each run finishes, so consecutive windows are the interval plus the run's own duration, and splitting at the exact cap would peel a sliver off every tick.
- A failure part-way through leaves the window start at the end of the last window drafted. The next tick covers exactly the remainder, so no interval is skipped or drafted twice.
- The first scheduled run after a start with nothing on file reaches back one shift before construction, plus whatever elapsed before that run. With the default cap it drafts one window (the extra seconds are inside the tail allowance), and drafts two only if the first run is more than the allowance late.
- A cap too large to use (so large that the reach below cannot be subtracted from a date, hundreds of thousands of shifts) is refused at startup with an error naming
max_window_shifts.
Restarts resume where drafting stopped
Every scheduled draft records the end of the window it covered in its own Activity Log entry (reference_ids.window_end). At its first scheduled run, the task reads the newest such entry for its node instance. If that entry ended within the reach (below), the task starts there instead of at the seed. The seed is, in order, the Production Scheduling peer boundary, the shift_schedule boundary or clock() - shift_duration.
A restart part-way through a backlog therefore drafts the rest gaplessly, instead of reseeding to the latest shift boundary and skipping it. The entry is read at the first run, not at construction, so the distance is measured from when drafting actually starts. A malformed entry is skipped.
No handoff reaches back further than one tick can draft
The reach is three window caps plus the tail allowance, and never less than eight hours. That is 24 h 48 min with the defaults and an 8-hour interval. A node's window cap is max_window_shifts times its interval_seconds, so the reach is always at least three ticks. It applies on every tick, not only after a restart.
Time older than the reach is not drafted.
- The node logs a warning and writes an Activity Log entry (outcome
skipped: ..., which the resume point never reads) saying how much was skipped, and starts at the reach. - While a backend stays down, every tick meets a new span. The spans are held and written as one entry when drafting next succeeds, or as soon as the held span reaches a whole reach, so a backend that never recovers still leaves a record about every reach.
- A write that fails is not fatal to the tick. The span is kept and written with the next entry. A restart loses at most the span not yet written, and then records what it seeds past (below).
- This covers a multi-day outage, an inference backend down for more than a day whether or not the node restarted, and a seed from a long-stopped clock.
- A handoff for a shift that ended days ago has no reader, and queueing one per shift would bury the reviewer in stale sign-offs.
- The skipped time stays in the Activity Log and can be drafted on demand with
run(window_start, window_end), which records no resume point and so never moves where a restart resumes. - With a short interval, the eight-hour floor means a backlog can hold up to a shift's worth of its own windows (96 five-minute windows), drained three per tick.
A restart treats the same time the same way when it can. A restart with no drafted handoff on file within the reach, on a node that has older Activity Log history, seeds past time nothing was drafted for. It writes a skipped: ... entry for the span between the start of the reach and the seed, the same entry a gap met while running gets. (A seed older than the reach is covered by the running-gap entry at the first tick.) A first start with no history writes none.
Ticks with nothing to draft, and clock problems
- No elapsed time. A tick with no elapsed time since the last drafted end drafts nothing, since an empty handoff is noise, and
run_scheduledreturnsNone. - A clock that steps back. A clock that reads earlier than the last drafted end is handled the way a restart handles it: the tick logs a warning, continues from the clock, and returns
None. The next tick drafts from the clock's time. A drafted entry that ends after the current time counts as ending now. In both cases nothing is skipped, and at worst the skewed span the earlier draft had already covered is drafted a second time. Holding the end at the stepped-back value instead would leave everything logged while the clock catches up undrafted. - An unreadable Activity Log at the first run. The tick fails with an error naming only the exception type, and is retried at the next interval. The seed is not used, so a transient database error never skips a backlog.
- Other errors in a tick. A database or operating-system error elsewhere in a tick (a read or write that fails) is raised the same way, as
ShiftHandoffSummaryErrornaming only the exception type, with the traceback in the log. The scheduler retries that failure at the next interval, where any other exception type would end the scheduled task until a restart. Any other exception type (a programming error) is not converted, so it still ends the task visibly instead of being retried forever.
The chat prompt
shift_handoff.max_prompt_entries (positive whole number, default 100) limits the Activity Log entries, the reconciliation events and the pending drafted entries that enter the prompt. Each list is limited to its most recent entries, still in chronological order.
- The payload always carries
activity_log_entries_omitted,reconciliation_events_omittedandpending_drafted_entries_omitted, 0 when nothing was left out. The licensed prompt asset (version 0.7.0) tells the model to say once that the summary covers the latest activity when any of them is above zero. - The record's own
activity_count,reconciliation_countandpending_case_countstay the true totals for the window. - The payload carries the same totals as a
countsblock, which the draft's stated counts are checked against (seeprompt-provenance-and-stated-counts.md).
Precedents in the draft
Retrieval is best-effort enrichment. A summary without precedents is still a correct summary, so a retrieval failure never stops the draft, ends the scheduled task or holds back the window.
Four kinds of failure are caught:
- the embedding endpoint (unreachable, or it refused the call);
- the database (a
psycopgerror); - the operating system (any other
OSError); - a dimension mismatch (the endpoint now answers at another width than the table was made for, or the table was filled by another model).
Any other exception type, a programming error, is not caught and ends the task visibly.
Every draft carries precedent_retrieval, one of:
| State | Meaning |
|---|---|
used |
One or more precedents were in the prompt. |
none_found |
Retrieval ran and nothing reached the relevance threshold (default 0.65). |
unavailable |
Retrieval failed. precedent_failure_class says embedding_endpoint, database, operating_system or dimension_mismatch. It carries the class only, never the driver's message, which can echo a connection string. The log line names the class and the exception type and no message. |
not_attempted |
Never looked: Unlicensed Mode, an undeclared backend_trust, inference disabled, or no retriever. |
What a reviewer can reconstruct.
- The record also carries
precedents, one entry per precedent in the prompt with itssource_document_id,chunk_idandsimilarity. - The draft's Activity Log entry carries the same state in
reference_ids(precedent_retrieval, andprecedent_failure_classwhen unavailable). Each precedent's ids are under numbered keys (precedent_1_source_document_id,precedent_1_chunk_id,precedent_2_...). - A reviewer sees what grounded a summary and can reconstruct it afterwards. A search of the Activity Log by a document's id finds every handoff that used it.
What reaches the model. A retrieved chunk enters the prompt with its source_document_id, chunk_id and text and nothing else. Its metadata, applicability and similarity do not reach the inference endpoint. The licensed asset (version 0.7.0) tells the model to use a precedent only when it matches something in the window, never to state a disposition, cause or outcome that is not in the precedent's text, and to name its source document.
The asset and the engine ship together
The engine pins the asset's version (SHIFT_HANDOFF_PROMPT_VERSION in engine/node_main.py), and the payload's field names are part of what the asset says. A Node that holds an older asset stops at start with PromptAssetVersionError. It does not fall back to Unlicensed Mode, which is only for an asset that is absent. Update the licensed asset when you update the engine.
Document intake entries
A node with a document_intake section writes an Activity Log entry for each document it ingests, each document it deactivates or activates, and each new configuration version of a document type. They are ordinary entries of the node, so the shift summary counts and shows them like any other, and a bulk load of documents can fill the most recent max_prompt_entries.
A site that would rather the summary describe only the floor sets shift_handoff.exclude_document_ingestion to true (default false). Those entries are then left out of the window altogether: not counted, not shown to the model and not part of the precedent query. The entries stay in the Activity Log.
The unlicensed and inference-disabled branches never call the embedding backend or the model, and build their summary from the same totals. The window split and resume point apply to them too, since they are about which interval a draft covers.
Upgrading
max_window_shifts, max_prompt_entries, exclude_document_ingestion and embedding.max_input_chars are additive and optional.
A configuration loads only when its node_type_version equals the MES Node Type's version exactly. After any upgrade that moves the Node Type (identity.version in node-types/mes/node_type.json; these settings arrived with 0.2.0), the configuration's node_type_version has to be edited to the current value before the node will start. Nothing else in it needs to change.
The license-gating wiring itself
raw_license_file = json.loads(Path(settings.license_file_path).read_text())
public_key = load_public_key(Path(settings.license_public_key_path))
license_file = verify_license_file(raw_license_file, public_key)
license_manager = LicenseManager(license_file)
# ... ShiftHandoffTask(..., license_state=lambda: license_manager.state, precedent_retriever=...)
What happens with the license file:
| License file | Result |
|---|---|
Absent (FileNotFoundError on settings.license_file_path) |
Not an error. No LicenseManager is built, and the license state is LICENSED unconditionally. |
Present but unusable: unparseable JSON or PEM, an unreadable file (permissions), or verify_license_file rejecting it (bad signature, schema-invalid payload) |
One LicenseFileInvalidError, raised at build_mes_runtime call time, before this Node instance ever starts its dispatch loop. This fails closed, the same stance verify_license_file's docstring takes, extended to cover the file-read step that function doesn't itself perform. |
| Valid, but not covering this Node Type | LicenseFileInvalidError ("does not cover node type"). |
Node-type coverage. After verification, build_mes_runtime checks coverage. The Node Type's name (node_type.identity.name, for example MES) is lowercased and must appear in the file's licensed_node_types, which are always lowercase because LicenseFilePayload normalises them. A validly signed file issued for other node types therefore cannot gate this one.
The licensed prompt asset overrides the no-license-file default.
- If the asset is absent (the state of an open-source clone with no
licensed/directory), the state is forced toUNLICENSEDandShiftHandoffTasktakes its deterministic fallback. - A present asset whose version differs from
SHIFT_HANDOFF_PROMPT_VERSIONraises aPromptAssetVersionErrorinstead.
No sync step. license_manager.state is a property, not a method with a return value to discard. ShiftHandoffTask reads it fresh on every drafting call (license_state=lambda: license_manager.state), so there is no sync step to wire into a ScheduledTask. Only ShiftHandoffTask.run_scheduled itself needs one.
Testing without a real day boundary
LicenseManager.state compares license_file.expires_at to the current date on every access (engine/license_server.py).
- The
UNLICENSEDpath.tests/test_node_main.py's UNLICENSED-path test issues a license file whoseexpires_atis already in the past (write_test_license(tmp_path, expires_at=date(2020, 1, 1))intests/conftest.py). It reachesUNLICENSEDdeterministically, with no license server of any kind involved and no dependence on a real calendar day elapsing. - The
LICENSEDpath. The test issues a genuinely valid, unexpired license file through the samewrite_test_licensehelper and runs"shift-handoff"directly. There is no separate sync step, sincelicense_manager.stateis computed live.ShiftHandoffTask.run_scheduledneeds noTriggerQueueor dispatch loop at all, because it submits straight toSignoffStore. TheScheduledTaskis therefore driven synchronously (task.run()), never throughrun_trigger_dispatch_loop. - Clients.
InferenceClientandEmbeddingClientare both patched at construction (engine.node_main.InferenceClientandengine.node_main.EmbeddingClient), the same way every other test in this file already patchesInferenceClient. A_capturing_embedding_clienthelper records every embedded text into a caller-owned list. A test can then assert that precedent retrieval genuinely fired (LICENSED) or genuinely didn't (UNLICENSED), without asserting anything aboutEmbeddingClient's internals.
Pitfalls
- Several
shift_schedulevalues that Configuration Schema validation waves through are still real mistakes.- An
anchorwith no UTC offset (for example"2026-01-01T00:00:00").node_type.config_schemamarks it"format": "date-time", butload_node_config'sjsonschema.validatecall never registers aFormatChecker. The format constraint is therefore purely documentation, not enforcement, the same gap every other"format"-annotated field in this schema has. - A
duration_secondsofInfinityorNaN. Both pass"exclusiveMinimum": 0, becausejsonschemaandjson.loadsboth accept them as ordinary numbers. _build_shift_handoff_runtime(engine/node_main.py) catches all of these. It handles theValueErrorandOverflowErrorofdatetime.fromisoformatandtimedelta(seconds=...), plusShiftSchedule.__post_init__'s naive-anchor and non-positive-duration checks (engine/shift_schedule.py). It wraps each into a clearConfigValidationErrornaming the actual field at fault.- The check runs first, before the license-file signature verification and any
embedding-configured DB schema-ensure work later in the same function. A malformedshift_scheduletherefore fails closed immediately (atbuild_mes_runtimecall time, i.e. Node instance startup). It doesn't pay for either on every failed restart, and doesn't crash later with a bareTypeErrororZeroDivisionErrorinsideShiftSchedule.most_recent_boundary. That method itself only ever runs eagerly insideShiftHandoffTask.__init__, so it is still at startup, not on some later first scheduled tick.
- An
ShiftSchedule.most_recent_boundary's fixed-offset arithmetic doesn't track daylight saving time.anchoris parsed throughdatetime.fromisoformat, which (per the schema) only accepts a numeric UTC offset orZ, never an IANA zone. A site whose real shifts start at a fixed local time (08:00, 16:00, 00:00) will see every computed boundary silently drift by the DST delta (typically 1 h) after the region's next transition, for every Node Type sharing that fragment, with no error or log. This is not fixed here. Doing so needszoneinfosupport and a per-site local-timezone config value, a materially larger change, and is not supported.- Tests pin their license inputs.
example_node_config.json(the shared example config every general-purpose test intests/test_node_main.pybuilds against throughCONFIG_PATH) always carries ashift_handofffragment. Tests that care which license state they reach pass their ownsettings=pointed at a throwaway license file issued bytests/conftest.py(_license_settingsandwrite_test_license). A missinglicense.jsondoes not fail the build (it runs ungated,LICENSED), so the explicitsettings=is for determinism, not to avoid a startup error. - The Playbook table is one shared physical table, not test-uniquely named the way
tests/test_case_precedent_retrieval.py'sEmbeddingStore(f"PrecedentTest-{uuid.uuid4()}", ...)tests are. The Node's store is named for the Node Type, so every test building a runtime withembeddingconfigured callsensure_schema()(idempotentCREATE TABLE IF NOT EXISTS) against the same real table. A test that asserts on retrieved content writes chunks with ids of its own and deletes them afterwards, and compares only those, because other tests' rows may be there. - A database that still holds
embeddings_case_library_<hash>from an earlier version keeps it: the Node neither reads nor writes it, and starting does not drop it. Drop it by hand when nothing needs it. embedding_clientisNonewhenembeddingisn't configured.main()'sfinallyblock guards it the same way it guards every other optional collaborator (deviation_connector,peer_clientand so on). A caller buildingMesRuntimeby hand must remember to close it, along with every connector the runtime holds.- A drafted date is not checked against the window.
_summarize_call(engine/shift_handoff.py) passeswindow_startandwindow_endas ISO 8601 strings in thepayloaddict handed todraft_narrative, so the real window is available to the model. But nothing in the code compares a calendar date the model writes against it. A draft can open with a date of its own (a year off, say) while the rest of it cites the real figures and record ids, and a reviewer skimming an otherwise plausible, correctly cited summary can miss a wrong date in the opening line.SignoffStore's mandatory-human-review step is the check: read any stated date against the window before approving.
Coverage gaps in a window
A coverage gap of this Node that overlaps the window (see "Coverage gaps" in database-reference.md) is named in the draft.
- The summary opens with a sentence written by code, not by the model. It says that coverage was incomplete in the window and names each gap's connector, cause and times, and nothing of what was missed, which the log cannot know.
- The same sentence leads the structured fact listing used when inference is disabled, when the Node is unlicensed and in the degraded fallback.
- A drafting model is given each gap as a fact (
coverage_gaps: connector, cause, outcome and window, from words the code vouches for), never as an entry in the free list of activity. Gap entries are not counted as activity. - The submitted draft carries the same facts as
coverage_gaps. - A window no gap touches is drafted exactly as before.
Release: v0.11.0