Repository navigation
feat(journal): add protected repository-owned recovery primitives #9936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eshulman2
wants to merge
5
commits into
fullsend-ai:main
Choose a base branch
from
eshulman2:codex/journal-primitives
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,474
−23
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48cc7d1
feat(journal): add protected repository-owned recovery primitives
eshulman2 db7ba9b
fix(journal): address isolation and recovery review findings
eshulman2 9498f5a
fix(journal): address recovery journal review findings
eshulman2 4657e1a
fix(journal): gate experimental GitLab storage
eshulman2 e986313
fix(journal): pin branch reads and preserve safe guidance
eshulman2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| --- | ||
| title: fullsend journal | ||
| --- | ||
|
|
||
| # fullsend journal | ||
|
|
||
| Experimentally read and conditionally update the saga journal in the GitLab control repository. | ||
| It provides the storage and host-operation primitives described in | ||
| [ADR 0165](../ADRs/0165-recover-work-through-repository-owned-operation-journals.md). | ||
| It performs no inference. The JSON output is durable state only after the remote | ||
| checkpoint is accepted; a failed or ambiguous call is not permission to repeat | ||
| an external action. | ||
|
|
||
| ## Protected host profile | ||
|
|
||
| Set `FULLSEND_JOURNAL_PROFILE` in trusted host installation state. Its strict JSON | ||
| fields are `forge` (`gitlab`), `base_url` (HTTPS site origin), `owner` (namespace), | ||
| `repo`, `branch`, `path` (relative JSON file), `role`, and | ||
| `experimental_gitlab` (boolean, defaults to false). Source checkouts, tracker | ||
| properties and model output cannot supply this profile. The journal branch must | ||
| already exist and be protected. Every exact or wildcard rule matching the | ||
| branch must allow push and merge only to the journal writer's numeric user ID | ||
| (or nobody), with at least one push grant for the writer. Role-level, group | ||
| and deploy-key grants are refused, including | ||
| Maintainer grants. Every matching rule must explicitly grant unprotect access | ||
| only to that writer. GitLab treats an empty unprotect list as its default | ||
| policy, so the journal refuses missing or empty lists. It also refuses custom | ||
| member-role grants. An overlapping permissive rule blocks access. The | ||
| credential must be able to list protection rules and identify its user. | ||
| Named-user protection grants require | ||
| [GitLab Premium or Ultimate](https://docs.gitlab.com/user/project/repository/branches/protected/#in-a-project). | ||
| Instances without these grants cannot host this journal backend. | ||
| Set `experimental_gitlab` to `true` only for a controlled trial. Serialize all | ||
| journal mutations externally under one shared lock per journal, for example a | ||
| single GitLab CI resource group when all writers run in the same project. The | ||
| Files API checks `last_commit_id` separately from the branch update, so | ||
| concurrent writers can lose updates. Hosted conformance remains pending. | ||
|
|
||
| The profile selects its exact scope; there are no command flags to redirect | ||
| writes elsewhere. | ||
|
|
||
| Register `role` as a custom identity through the existing protected | ||
| `FULLSEND_GITLAB_ROLE_REGISTRY`, with `write_repository` capability and its own | ||
| secret reference. The built-in Analyst, Poller and Coder roles are refused for | ||
| this journal command. Journal credentials stay on trusted hosts. The client | ||
| rechecks scope, current profile, authenticating credential and branch protection | ||
| on access. Neither ambient `GITLAB_TOKEN` nor a local database is a fallback. | ||
|
|
||
| ## Operations | ||
|
|
||
| ```sh | ||
| fullsend journal initialize | ||
| printf '%s' '{"phase":"admitted"}' | fullsend journal admit \ | ||
| --id case-001 --binding "reviewed-input-digest" | ||
| fullsend journal claim --id case-001 --owner controller-001 --ttl 5m | ||
| fullsend journal read --id case-001 | ||
| ``` | ||
|
|
||
| `initialize` creates the journal on the pre-provisioned branch and refuses an | ||
| occupied path. Missing or corrupt existing state requires operator recovery; | ||
| ordinary commands never initialize or reset it. | ||
|
|
||
| After admission and claim, leased mutations require `--id`, `--owner` and the | ||
| `--generation` returned by `claim`. `admit` and `claim` use the flags in the table: | ||
|
|
||
| | Operation | Other flags / standard input | | ||
| | --- | --- | | ||
| | `admit` | `--binding`; bounded JSON data on stdin | | ||
| | `claim` | `--owner`, optional `--ttl` (default 5m, maximum 24h) | | ||
| | `renew` | Optional `--ttl` | | ||
| | `release` | Releases the current lease | | ||
| | `update` | Bounded replacement domain data on stdin; retains budgets/effects | | ||
| | `rebind` | `--binding` plus new reviewed domain data on stdin; preserves consumed bounds and effects | | ||
| | `intent` | `--effect-id`, `--kind`, `--binding` | | ||
| | `effect` | `--effect-id`, `--status`; confirmed receipt JSON on stdin | | ||
| | `spend` | `--counter`, `--limit`; consumption survives later attempts | | ||
| | `read` | No mutation flags or stdin | | ||
|
|
||
| The effect states are `intended`, `in_flight`, `ambiguous` and `confirmed`. | ||
| Transition checks and immutable receipts prevent a stale owner or repeated | ||
| in-flight admission from authorizing another external write. The CLI retries a | ||
| mutation at most twice (three attempts total), only when the conditional write | ||
| was definitively rejected. It reloads state and rechecks all predicates on each | ||
| attempt, with short cancellation-aware backoff. It reads stdin once. Initialization and reads are not | ||
| replayed. Exhausted conflicts still require caller recovery; do not force-push or | ||
| merge competing JSON claims. These retries do not invoke an agent or repeat an | ||
| external action. | ||
|
|
||
| The GitLab Files API adapter recognizes exact HTTP 400 rejection | ||
| messages. The recognized reference-update messages are | ||
| `9:reference update: reference does not point to expected object.` and | ||
| `Could not update refs/heads/<branch>. Please refresh and try again.` for the | ||
| requested branch. File-revision and file-exists recognition also depends on | ||
| exact English text. Generic HTTP 409, localized HTTP 400, and other unrecognized rejection | ||
| responses are treated as uncertain. Use an English response locale for trials that require these | ||
| automatic retries. Hosted verification across GitLab versions is pending. | ||
|
|
||
| A lost acknowledgement or failed checkpoint verification returns | ||
| `journal checkpoint outcome uncertain` and is never automatically retried. Mixed | ||
| conflict/unknown errors, invalid readback, and changes to the target record stay | ||
| uncertain. Ownership, binding, integrity and budget failures do not retry either. | ||
| Reads and write verification resolve the configured branch through GitLab’s | ||
| branch API and read the file at the reported commit. This avoids ambiguity | ||
| when a tag has the same name. | ||
|
|
||
| The backend keeps all authority in one bounded document, using GitLab's file | ||
| revision guard in deployments that serialize writers. After an acknowledged Engine | ||
| write, it validates the readback document and its exact intended record; unrelated | ||
| records may advance. Direct backend callers retain whole-document verification. | ||
|
|
||
| A checksum detects accidental corruption; it does not authenticate an actor. | ||
| Protected storage and current host authorization remain required. No delivery | ||
| or publication guarantee is described as exactly once. | ||
|
|
||
| ### Bind child mutations to current parent admission | ||
|
|
||
| Promotion controllers can pass all three flags on journal commands: | ||
|
|
||
| ```text | ||
| --require-record CASE_ID --require-binding MANIFEST_DIGEST --require-data-digest PARENT_DATA_SHA256 | ||
| ``` | ||
|
|
||
| The data digest is SHA256 of the compact JSON bytes of the parent record's | ||
| `data` value as emitted by `fullsend journal read`, excluding surrounding | ||
| whitespace or a trailing newline. This uses Go's `encoding/json` HTML escaping | ||
| (for example, `<` becomes `\u003c`) and preserves object key order and number | ||
| spellings. Extract the raw value without parsing and reserializing it through a | ||
| serializer that changes those bytes. Go callers can use `json.Marshal(record.Data)` | ||
| to obtain the same representation. Storage indentation does not affect the digest. | ||
| Every mutation checks all parent requirements on its fresh loaded snapshot, including idempotent no-op paths, and again in the | ||
| whole-document conditional write. A changed parent rejects the mutation. A | ||
| concurrent revision conflict can trigger the bounded transaction retry above; | ||
| a newly stale parent then fails its fresh check. This does not retry a model call | ||
| or external publication. | ||
| Reads remain available for recovery even after a parent changes. Requirements | ||
| cannot refer to the mutated record itself. They supplement the child operation's | ||
| own ownership generation and do not replace source, Jira or human-approval gates. | ||
|
|
||
| ## Integration and acceptance boundary | ||
|
|
||
| Installing fullsend does not activate a journal, add schedules, or journal ordinary | ||
| agent runs. A workflow must install a protected host profile, explicitly admit | ||
| work, supply authorized host adapters and reconcile its external effects. The | ||
| journal records intent and receipts; it never performs those external actions. | ||
| Assessment sandboxes and their pre/post scripts must not inherit the journal | ||
| writer credential merely because they participate in a workflow. | ||
|
|
||
| The storage backend is initially GitLab only. GitHub and Forgejo source targets | ||
| remain independent of the journal location; their control-journal backends stay | ||
| unsupported pending conformance. No journal access to source repositories is | ||
| needed. Local fake-backend and HTTP-adapter tests do not establish hosted | ||
| acceptance. | ||
|
|
||
| > **Planned:** Hosted cross-machine conformance and end-to-end workflow migration | ||
| > remain tracked in [#9253](https://github.com/fullsend-ai/fullsend/issues/9253). | ||
|
|
||
| Store only bounded identities, digests and receipts. Checksums detect corruption, | ||
| not a writer's identity. Protected storage and host authorization supply that | ||
| boundary. Run artifact-level filters do not remove data from journal commits. | ||
| Use a separately authorized immutable evidence store when recovery evidence | ||
| cannot be retained in run artifacts. Retention, reader access and compaction are | ||
| installation responsibilities; exhaustion holds work rather than discarding | ||
| unresolved operations. | ||
|
|
||
| This initial command does not create journal-operation trace spans or capture | ||
| journal payloads into telemetry. A journal receipt is not a replacement for the | ||
| run's detailed telemetry or proof of a domain outcome. | ||
|
|
||
| > **Planned:** Journal-operation trace spans, journal/run trace correlation and | ||
| > metadata-only instrumentation remain implementation work in | ||
| > [#9253](https://github.com/fullsend-ai/fullsend/issues/9253). | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOW (content): the new
fullsend journalcapability reads like a strong blog subject once the hosted conformance work lands. could a short post walk through the problem it solves for protected hosts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m deferring the blog post until hosted conformance lands and leaving this thread open as a reminder.