Repository navigation
CONTRACT: fix(ui-server): retry crontab module discovery, name its cause and record a skip - #3382
Merged
Merged
Conversation
…use and record a skip `brain-ui-cron crontab` added module jobs only when discovery succeeded at the moment cron started; a transient failure fell back to core jobs with no signal until the next restart (#3381). Discovery moves into `cron/module-discovery.ts`. Each attempt qualifies the host afresh and reports why it yielded nothing: the `brain module list` exit code and stderr tail, unreadable output, a host not reconciled, or a missing native configuration. Retryable causes get two more attempts, after 5s and 15s. The final outcome is recorded as a finished `modules` job: a cron_runs row (`/api/status` cronJobs) and a `cron` root span in Activity, `error` with `module cron skipped: <cause>` or `success`. It writes only to a UI database outside the brain that exists or sits behind a qualified host, so the unqualified fallback still creates no UI state. Successful crontab bytes are unchanged. Additive contract: integration-contract index and wire component updated. Closes #3381 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Collision report before confirm (head |
This was referenced Nov 2, 2026
Closed
Merged
# Conflicts: # docs/integration-contract.md
Owner
Author
|
Orchestrator refresh: merged current main ( |
schlessera
marked this pull request as ready for review
November 3, 2026 12:51
8 tasks done
This was referenced Nov 3, 2026
# Conflicts: # docs/integration-contract.md
7 of 8 tasks
8 tasks done
Merged
7 of 9 tasks
schlessera
added a commit
that referenced
this pull request
Nov 15, 2026
… cron jobs on the host (#4008) * CONTRACT: feat(ui-server): fetch allow-listed repositories for module cron jobs on the host A module job runs in a maintenance worker that holds no Git credential, so a module that needs another repository, such as a private one with scripts it runs, could not reach it from cron (#3380). Per the maintainer's 2026-11-02 slice (b) rulings: - A module's config block declares the repositories it wants with a new core-owned `repositories` key, validated and stripped before the module's schema like `enabled`. `brain module list --json` reports it on each configured module, and `LoadedModule` gains the optional field. - The host grants only the intersection with the operator's allow-list, `BRAIN_UI_MODULE_REPOSITORIES`, read by the cron runner from host configuration and never forwarded to a job. An edit to brain.config.ts alone therefore cannot widen access. - Before each module job the runner runs a credential-free `brain module list --json` and maps the job to its module by its `<module>-<entry>` name and command. The crontab layout is unchanged. - The sync transport fetches each granted repository with the host's sync credential into a host-private bare mirror beside the sync mirror, never mounting the brain. The job's worker gets the mirror read-only and `url.file://<mirror>.insteadOf` rewrites, and never holds the credential. - A refused or failed fetch refuses the job before it starts: exit 1, with the repository and the setting named on stderr and in cron_runs. Contract: docs/integration-contract.md, the cli and package-api components, docs/modules.md and the hosting guide. The ruling is recorded in docs/decisions/governed-writable-workers.md. Moved citations follow their anchors. Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(ui-server): read a job's module list through the crontab discovery reader #3382 landed readModuleList, which names why a module list read failed. The job's repository step now uses it instead of a duplicate reader, so a job that cannot learn its module says why on stderr. Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: follow citations moved by the module repositories change Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ui-server): read no module list for a scheduled command that is not brain A module job always runs `brain <command>`. A dashed job name running anything else is no module's job, so it now skips the module list and prints no note. Refs #3380 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3381
What changed
brain-ui-cron crontabno longer drops every module job silently when module discovery fails at container start. Each attempt qualifies the host afresh and says why it yielded nothing: thebrain module listexit code and stderr tail, a timeout, empty or unreadable output, a host not reconciled, or a missing native configuration. A retryable cause gets two more attempts, after 5s and 15s. When every attempt fails, the crontab still carries the core jobs (the same# (brain module list unavailable — module cron skipped)comment), stderr names the cause, and the outcome is recorded as a finishedmodulesjob: acron_runsrow, so/api/statuscronJobsshows it, and acronroot span in Activity. A skip iserrorwithmodule cron skipped: <cause>. A later successful start recordssuccessand clears it. A successful crontab is byte-for-byte unchanged.Why this shape
getCronStatusalready lists every job name incron_runs, and the Activitycronroot span is the shape both schedulers write. So the skip shows up where an operator already looks, with no new route or frame. The job namemoduleshas no-, so no module job (<module>-<entry>) can collide with it.runrequires before it creates the database. That keeps the existing invariant that the unqualified fallback creates no UI state. Trade-off: a host that never qualified and has no database yet reports on stderr only.modulescron job and span are new observable values, so this is an additiveCONTRACT:change. The index entry and the wire component paragraph ship in the same commit. ui-server: a module cron job in a maintenance worker has no durable state area and no credential for another repository #3380 (module cron state and credentials) is untouched.Proof
Head
8c0856b3b58fbc10d1557fd1b0dc6647ae8246c7, baseorigin/main@f8284d6cc.Acceptance criteria:
discoverModules > a discovery that fails once and then succeeds emits the module job(CRON_DISCOVERY_RETRY_RECOVERS_MODULE_JOB, stubbed boundary). The native subprocess version isqualified native module discovery that fails once is retried and emits its job(NATIVE_CRON_DISCOVERY_RETRY_EMITS_JOB).CRON_DISCOVERY_FAILURE_NAMES_CAUSE,CRON_DISCOVERY_SKIP_IS_OPERATOR_VISIBLE(cron_runserror andcronJobsstatus, Activity span outcome, reason and attributes), and the subprocess testCRON_BIN_RECORDS_SKIPPED_MODULE_CRON.emit.tsis untouched.cron-emit.test.tsgoldens pass, and the retry test asserts that a retried crontab equals a first-time one.Failing first: the new subprocess test run against
origin/main'sbrain-ui-cron.tsfails on the stderr assertion. Main reportsmodule discovery unavailable; emitting core jobs only. …with no attempt count and records nothing.Mutations, each restored afterwards (
cmpconfirmed):[]): the 3 retry tests fail.CRON_DISCOVERY_FAILURE_NAMES_CAUSE.CRON_DISCOVERY_SKIP_IS_OPERATOR_VISIBLE.CRON_BIN_RECORDS_SKIPPED_MODULE_CRON.Local gap: hosted CI must prove the native-worker tests. This host has no unprivileged user namespaces (
unshare: write failed /proc/self/uid_map: Operation not permitted, even with the sandbox disabled). Five existingcron-bin.test.tsnative tests fail the same way on a pristineorigin/maincheckout (run records a row…,run re-admits…,crontab reads the resolved brain path…,module discovery stays credential-free…,qualified native module discovery emits…). The new native retry test also fails here for that reason. Incidentally, the new reporting now names exactly that cause on stderr; before this change that case was silent. The 52 non-native cron tests pass locally.Checklist
docs/reflect the change, or nothing documented moved.docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.Anything left open
🤖 Generated with Claude Code
check:pr receipt
{"version":1,"kind":"brain-check-pr-receipt","head":"072d0a1ced24917eee613c0a8d26b54bf177c04b","base":"origin/main","mode":"focused","startedAt":"2026-11-03T12:50:41.540Z","finishedAt":"2026-11-03T12:51:35.741Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":9183.654936000003},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":169.60493700000006},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":158.833885},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":57.36061300000074},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":44610.69949}]}