Skip to content

feat(journal): add protected repository-owned recovery primitives - #9936

Open
eshulman2 wants to merge 5 commits into
fullsend-ai:mainfrom
eshulman2:codex/journal-primitives
Open

eshulman2 wants to merge 5 commits into
fullsend-ai:mainfrom
eshulman2:codex/journal-primitives

Conversation

@eshulman2

@eshulman2 eshulman2 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expose explicit protected-host journal operations for workflows that must recover across separate jobs without replaying possibly accepted external writes. This extracts the domain-neutral journal implementation from eshulman2/fullsend#1, at 618a8eacba8f6413042ee4808547891fdec6c762, onto current upstream main.

The journal stores and checks mechanical progress. Existing agent runs, polling and dispatch do not opt in automatically. This draft does not migrate the CVE controller or include tracker-first orchestration, Jira admission changes, Pi tool selection or automatic schedules.

Related Issue

Partial implementation of #9253 under accepted ADR 0165. The issue remains open for hosted conformance and workflow integration.

Changes

  • Add a bounded, checksummed journal document with conditional transitions, fenced ownership generations, persistent budget consumption, immutable effect receipts and parent-record predicates in the same conditional transaction.
  • Add conditional versioned-file operations through forge.Client. GitLab uses the file's last_commit_id, sends writes once without redirects and distinguishes definite conditional rejections from uncertain outcomes. GitHub/Forgejo control-journal storage remains unsupported.
  • Add protected host configuration and a fullsend journal command for initialization, read/admission, leases, updates/rebinding, intents, effect confirmation and budget consumption. Only definite revision conflicts receive bounded fresh-transaction retries; ambiguous writes are held.
  • Require an independently credentialed administrator-registered journal writer and a protected, pre-provisioned control branch. Fix an inherited reference-implementation gap that allowed a custom journal role to reuse the Analyst credential; add a regression test. No ambient-token fallback is added.
  • Document installation requirements, CLI operations, conservative recovery, credential isolation, privacy, and implementation boundaries.

Testing

  • make lint passes with changes staged (repository-pinned link checker on PATH).
  • GOFLAGS=-buildvcs=false make go-test passes, including race detection and coverage. The test-only flag avoids an invalid outer /home/USER/.git directory discovered by Go VCS stamping; no product behavior or repository configuration is changed.
  • make go-vet passes.
  • Journal, host binding and forge adapter race tests pass; journal engine coverage is 92.2%, host binding 97.2%.
  • Targeted journal CLI race tests pass; new CLI functions have 92.3–100% coverage.
  • Regression rejects a journal registration reusing the Analyst credential.
  • Independent review rechecked the credential-isolation fix.
  • Approximate changed-block statement coverage is 90.1% (557/618), above the 80% target.

Remaining integration and acceptance

This is a draft of the journal primitives, not completion of #9253. No live GitLab conformance test, hosted inference or publication run was performed for this extraction. Periodic reconcilers, source/domain admission, running-attempt accounting, accepted-result/evidence retention and publish-only recovery require explicit workflow integration. Journal-operation trace instrumentation/correlation, retention/compaction policy and additional storage-backend conformance remain follow-up work. Unit and HTTP-adapter tests are not distributed acceptance.

Checklist

  • PR title follows Conventional Commits.
  • Human-directed commits carry DCO sign-off.
  • I wrote this contribution myself and can explain all changes in it.

Prepared with coding-agent assistance from the contributor's reference implementation; the personal-authorship attestation is left for the contributor.

Extract the generic journal engine, GitLab conditional-file backend,
protected host binding and explicit CLI operations from the contributor's
reference implementation. Preserve fenced ownership, persistent budgets,
parent-record predicates and immutable receipts across conservative retries.

Require an independently credentialed custom journal writer, rejecting
reuse of built-in assessment credentials. Keep workflow admission,
dispatch, reconciliation schedules and domain semantics outside this change.

Refs fullsend-ai#9253

Signed-off-by: eshulman2 <ellashulman1@gmail.com>
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Site preview

Preview: https://159ef19e-site.fullsend-ai.workers.dev

Commit: 9498f5a3f1ee15e2c99f0a27a6795e52d1f28c52

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

@eshulman2
eshulman2 marked this pull request as ready for review November 30, 2026 11:34
@eshulman2
eshulman2 requested a review from a team as a code owner November 30, 2026 11:34
@qodo-code-review

qodo-code-review Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add protected, repository-owned recovery journal primitives

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add an opt-in journal for durable ownership, budgets, effect receipts, and parent-record checks.
• Expose protected GitLab storage and explicit CLI operations without changing existing workflow
 dispatch.
• Retry only definite revision conflicts; hold ambiguous checkpoints for reconciliation.
Merge Risk 🔴 High

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The CLI, journal engine, host authorization, parent requirement wrapper, and GitLab conditional-file adapter jointly implement one bounded journal authority.
  • Leases, parent bindings, effect states, budgets, authorization, branch-pinned reads, and persistence govern the same recovery operation rather than separate user outcomes.
  • Initialization, reads, admissions, lease operations, effect checkpoints, and conditional persistence are operations on the same protected journal integration.
  • A denied writer, unavailable branch protection check, unsupported backend, failed opt-in, branch-resolution failure, uncertain acknowledgment, or conditional-write failure removes this bounded capability without reaching ordinary dispatch or source-forge behaviors.
Sources

internal/journal/journal.go[80-84]

// Backend must atomically replace the entire document only at the supplied revision.
// There is no retry after an ambiguous write. All effect authority lives in this one file.
type Backend interface {
	Load(context.Context) (Document, string, error)
	CompareAndSwap(context.Context, string, Document) (string, error)
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before, the repository had no protected journal transaction path.
  • After, lease generations, parent bindings, effect receipts, budgets, checksums, strict decoding, writer-isolated authorization, branch-commit pinning, exact GitLab conditional-write classification, explicit opt-in, uncertainty handling, and bounded fresh-transaction retries coordinate across the CLI, engine, host policy, and forge adapter.
  • Before, these cross-record and cross-service invariants did not exist.
  • After, authorization and mutation must remain valid together at the final conditional write; branch and file metadata must refer to the same immutable commit; stale leases and effect transitions must remain fenced; only definitive conflicts may be replayed; ambiguous initialization and writes must not be replayed; and concurrent writers must be prevented from losing updates by an external lock.
  • Compatibility correctness also spans unsupported GitHub behavior, GitLab revision semantics, exact API error messages, localized responses, and explicit opt-in.
  • These are newly interacting conditions, not complexity inherited merely from using JSON, maps, or a retry helper.
Sources

internal/journal/journal.go[80-84]

// Backend must atomically replace the entire document only at the supplied revision.
// There is no retry after an ambiguous write. All effect authority lives in this one file.
type Backend interface {
	Load(context.Context) (Document, string, error)
	CompareAndSwap(context.Context, string, Document) (string, error)
Potential damage 🔴 High 🩹 Integrity

  • A concurrent lost update can omit leases, budgets, parent bindings, or effect receipts and authorize duplicate or stale external work.
  • The new exact conflict classification and branch pinning reduce false retries and ref ambiguity but cannot make GitLab file revision checks atomic without the documented external lock.
  • Reverting stops new journal decisions, but persisted journal state and already authorized external effects require reconciliation, repair, or compensation.
  • The PR adds no automatic external reconciler.
Sources

internal/journal/journal.go[80-84]

// Backend must atomically replace the entire document only at the supplied revision.
// There is no retry after an ambiguous write. All effect authority lives in this one file.
type Backend interface {
	Load(context.Context) (Document, string, error)
	CompareAndSwap(context.Context, string, Document) (string, error)
Assessed commit e986313
Diagram

graph TD
  CLI["Journal CLI"] --> Host["Host authorization"] --> Engine["Journal engine"] --> Backend["Forge backend"] --> GitLab["GitLab adapter"] --> Repo[("Protected control repo")]
  Host --> Registry["Role registry"]
  Host --> GitLab
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Separate file per operation
  • ➕ Reduces contention and whole-document size pressure.
  • ➖ Cannot atomically check a parent record alongside a child mutation using one file revision.
2. Dedicated coordination database
  • ➕ Offers native transactions and greater scaling headroom.
  • ➖ Adds an operated dependency and departs from the accepted repository-owned journal design.

Recommendation: Keep the single protected document for this opt-in implementation: one conditional write preserves the parent, ownership, budget, and effect invariants together. Revisit storage only if hosted conformance or document-size limits establish a concrete need.

Files changed (29) +2867 / -0

Enhancement (10) +1141 / -0
journal.goImplement explicit journal CLI transactions +172/-0

Implement explicit journal CLI transactions

• Adds initialization, reads, leases, mutations, effect tracking, and budget commands. Bounds JSON input, sanitizes errors, and retries fresh transactions only after definite revision conflicts.

internal/cli/journal.go

root.goRegister the journal subcommand +1/-0

Register the journal subcommand

• Makes the explicit journal command available from the root CLI.

internal/cli/root.go

forge.goExtend forge client with conditional file operations +12/-0

Extend forge client with conditional file operations

• Defines revision-bearing reads and single-attempt conditional whole-file writes for control-journal storage.

internal/forge/forge.go

versioned_file.goLeave GitHub control-journal storage unsupported +15/-0

Leave GitHub control-journal storage unsupported

• Implements the extended forge interface with explicit unsupported results pending backend conformance.

internal/forge/github/versioned_file.go

versioned_file.goImplement GitLab revision-guarded journal files +81/-0

Implement GitLab revision-guarded journal files

• Uses GitLab file last-commit revisions for conditional writes, sends each write once without redirects, and classifies definite rejections separately from unknown outcomes.

internal/forge/gitlab/versioned_file.go

forge.goPersist and verify authorized journal checkpoints +145/-0

Persist and verify authorized journal checkpoints

• Adds a forge-backed document store with scoped authorization and conditional writes. Treats uncertain writes or failed readback as non-retryable while allowing engine transactions to verify their exact target record.

internal/journal/forge.go

journal.goAdd the bounded journal state machine +454/-0

Add the bounded journal state machine

• Introduces checksummed records, fenced leases, persistent counters, immutable effect receipts, and validated transitions. Writes the complete document conditionally so competing mutations cannot silently overwrite authority.

internal/journal/journal.go

json.goReject ambiguous journal JSON +63/-0

Reject ambiguous journal JSON

• Adds strict decoding that rejects duplicate object keys, trailing values, and unknown typed fields before state is trusted.

internal/journal/json.go

requirements.goFence mutations against current parent records +52/-0

Fence mutations against current parent records

• Adds parent ID, binding, and data-digest requirements checked on fresh loads and within the conditional child write. Reads remain available after a parent changes.

internal/journal/requirements.go

profile.goBind journal access to protected host policy +146/-0

Bind journal access to protected host policy

• Validates a strict GitLab control-repository profile and requires a custom role with its own write credential. Rechecks scope, credential, and branch protection without ambient-token fallback.

internal/journalhost/profile.go

Tests (13) +1543 / -0
journal_retry_test.goTest conservative CLI retry and recovery behavior +292/-0

Test conservative CLI retry and recovery behavior

• Covers fresh-state rechecks after conflicts, stale parent and ownership rejection, cancellation, and refusal to replay uncertain checkpoints.

internal/cli/journal_retry_test.go

journal_test.goTest journal CLI lifecycle and input boundaries +163/-0

Test journal CLI lifecycle and input boundaries

• Exercises initialization through release, parent-bound operations, malformed input, ownership rejection, and sanitized errors.

internal/cli/journal_test.go

fake.goTrack revisions in the fake forge client +3/-0

Track revisions in the fake forge client

• Adds revision state needed to simulate conditional file operations in tests.

internal/forge/fake.go

fake_test.goInclude conditional file methods in fake-client coverage +4/-0

Include conditional file methods in fake-client coverage

• Adds the new forge methods to the fake-client call matrix.

internal/forge/fake_test.go

fake_versioned_file.goSimulate revision-guarded files in the fake forge +51/-0

Simulate revision-guarded files in the fake forge

• Implements copied reads and atomic, revision-checked creation and replacement for journal tests.

internal/forge/fake_versioned_file.go

fake_versioned_file_test.goTest fake file revisions and stale-write rejection +40/-0

Test fake file revisions and stale-write rejection

• Verifies create-only behavior, stale revision conflicts, ABA protection, and copied read content.

internal/forge/fake_versioned_file_test.go

versioned_file_test.goTest GitHub journal-storage rejection +16/-0

Test GitHub journal-storage rejection

• Confirms both conditional-file methods report unsupported storage.

internal/forge/github/versioned_file_test.go

versioned_file_test.goTest GitLab conditional writes and response classification +133/-0

Test GitLab conditional writes and response classification

• Covers revision metadata, create-only writes, exact reference-race recognition, single-attempt behavior, and redirect refusal.

internal/forge/gitlab/versioned_file_test.go

forge_checkpoint_test.goTest checkpoint verification and uncertain outcomes +231/-0

Test checkpoint verification and uncertain outcomes

• Distinguishes unrelated-record advances from changed target records, lost acknowledgements, invalid readbacks, and mixed conflict errors.

internal/journal/forge_checkpoint_test.go

forge_test.goTest backend scope, initialization, and lost acknowledgements +79/-0

Test backend scope, initialization, and lost acknowledgements

• Checks authorization, existing-branch initialization, corrupt state, stale revisions, and retention of an in-flight effect after a lost acknowledgement.

internal/journal/forge_test.go

journal_test.goTest journal transitions, concurrency, and integrity +234/-0

Test journal transitions, concurrency, and integrity

• Covers restart recovery, lease fencing, budget preservation, effect transitions, concurrent writers, invalid arguments, and corrupt or duplicate-key documents.

internal/journal/journal_test.go

requirements_test.goTest parent predicates across races and no-op mutations +142/-0

Test parent predicates across races and no-op mutations

• Verifies stale parents reject child changes, including idempotent paths, and that concurrent parent updates conflict with the whole-document transaction.

internal/journal/requirements_test.go

profile_test.goTest host policy and credential isolation +155/-0

Test host policy and credential isolation

• Covers unsafe profiles, scope and branch checks, credential changes, missing secrets, and rejection of a journal role that reuses the Analyst credential.

internal/journalhost/profile_test.go

Documentation (6) +183 / -0
config.tsAdd journal command to documentation navigation +1/-0

Add journal command to documentation navigation

• Adds the journal CLI reference to the site sidebar.

docs/.vitepress/config.ts

README.mdList the explicit journal command +1/-0

List the explicit journal command

• Adds the journal command to the CLI index and distinguishes it from automatic dispatch or effect replay.

docs/cli/README.md

journal.mdDocument protected journal setup and recovery operations +136/-0

Document protected journal setup and recovery operations

• Describes installation, commands, parent predicates, conservative retries, and ambiguous-outcome handling. Clarifies credential isolation, privacy obligations, and the current GitLab-only boundary.

docs/cli/journal.md

forge-abstraction.mdSpecify conditional journal-file semantics +18/-0

Specify conditional journal-file semantics

• Documents revision-guarded file operations and explains why the journal requires whole-file conditional replacement rather than an unconditional branch write.

docs/contributing/forge-abstraction.md

cli-internals.mdInclude journal operations in the CLI architecture guide +6/-0

Include journal operations in the CLI architecture guide

• Adds the journal command tree and identifies its CLI implementation.

docs/guides/dev/cli-internals.md

operations.mdExplain how operators opt in to journaling +21/-0

Explain how operators opt in to journaling

• Adds protected-branch and writer-credential prerequisites and emphasizes that initialization does not integrate existing workflows.

docs/guides/getting-started/operations.md

@qodo-code-review

qodo-code-review Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Workers can alter protected journal state ✓ Resolved Bug Security

Resolving commit: db7ba9b

Resolution reason
Authorizer now calls verifyWriterIsolation after the protected-branch check. It lists
protected-branch rules, checks every rule matching the journal branch (exact and wildcard), fails
closed on group, deploy-key, role-level (AccessLevel != 0) or other-user grants, requires at least
one push grant for the authenticated writer user ID, and fails on missing grant metadata or unknown
patterns. Tests cover developer push, maintainer merge, other user, group, deploy key, and wildcard
overlap cases. Docs were updated to require writer-only push/merge grants.
Description
Profile.Authorizer checks only whether a branch is protected, not whether its effective push rules
exclude credentials other than the journal writer’s. If a control project also grants a worker
Developer access and a matching protection rule allows Developer pushes, that worker’s API-scoped
token can write the journal file directly through GitLab, bypassing the CLI’s dedicated-role check.

2. Procedure runs before its prerequisites ✓ Resolved Skill insight Quality

Resolving commit: db7ba9b

Resolution reason
Added a labelled "### Prerequisites" subsection before any commands in the recovery journal section,
and restructured the initialize/read commands into numbered steps that follow it.
Description
The new Opt in to a recovery journal procedure in the operations guide puts the `fullsend journal
initialize and read` commands first, and only afterwards, in prose, states the required protected
branch, trusted profile and registered GitLab role. The guide has no labelled prerequisites block
that precedes these steps, so an operator can run the commands before satisfying the requirements
the prose lists.

3. Parent-digest guards reject every non-empty parent ✓ Resolved Bug Correctness

Resolving commit: db7ba9b

Resolution reason
The guard now hashes json.Marshal(record.Data), the compact HTML-escaped form the CLI emits, instead
of the indented stored bytes, and the digest contract is documented as compact JSON. This makes
CLI-derived digests of structured parents match.
Description
requiredBackend.validateMutation hashes Record.Data as decoded from the indented file written by
Encode, while fullsend journal read exposes a compact serialization of that data. When a caller
hashes the CLI-observed data of a structured parent for --require-data-digest, the bytes differ
despite an unchanged parent and the guarded mutation reaches ErrBinding; existing tests use {}
parents, which do not expose the difference.


Remediation recommended

4. Invalid writes retry as revision races ✓ Resolved Bug Correctness

Resolving commit: db7ba9b

Resolution reason
The broad conflict classification was removed in internal/forge/gitlab/versioned_file.go. Now only
exact reference-CAS rejection, exact file-exists/file-changed 400 messages for POST/PUT, and HTTP
409 map to ErrConflict; 404 and other 400 responses (empty commit message, last_commit invalid,
missing branch, etc.) no longer return ErrConflict. Tests were added for missing project/branch and
unrelated validation messages, matching the suggested fix's intent though with a different mechanism
(exact message matching plus method check instead of a pure status/keyword split).
Description
WriteFileIfRevision labels every HTTP 404 and broad HTTP 400 message matches such as empty or
last_commit as a definite revision conflict. A missing project or branch, or a request-validation
error containing one of those words, consequently enters the CLI’s fresh-transaction retry path
despite not indicating that another writer changed the file.

5. Recovery journal term is never defined ✓ Resolved Skill insight Quality

Resolving commit: 9498f5a

Resolution reason
Added an inline definition of "recovery journal" as a protected, conditionally updated record of
operations directly after the section heading in operations.md, and restructured the section with a
Prerequisites subsection linking to the journal command reference.
Description
The operations guide introduces recovery journal as the heading of a new section and uses
journal throughout without defining it inline or linking to a glossary entry. The glossary
contains no journal entry, so a reader of this guide has no definition for the term the procedure
depends on.

6. Journal docs overstate the retry count for conflicting writes ✓ Resolved Rule violation Maintainability

Resolving commit: db7ba9b

Resolution reason
The docs sentence was changed from "retries a mutation at most three times" to "retries a mutation
at most twice (three attempts total)", so the documented retry count now matches the
implementation's three total attempts.
Description
The CLI reference says the journal command retries a mutation at most three times after a
definitive conditional-write rejection. The implementation in retryJournalTransaction makes at
most three attempts in total (attempt == 2 stops the loop), which means two retries after the
first call, and the retry tests assert exactly three calls. A reader sizing automation or conflict
handling from the page will expect one more retry than the CLI performs.


Informational

7. Pending journal work lacks a planned callout ✓ Resolved Skill insight Correctness

Resolving commit: db7ba9b

Resolution reason
Pending work statements about hosted conformance and trace instrumentation/correlation were moved
into "> **Planned:**" blockquotes, each linking issue #9253, separating them from current-behaviour
text.
Description
The new journal reference says trace spans, payload-free instrumentation and trace correlation
remain implementation work in #9253, but the sentence is plain prose rather than a `>
**Planned:**` blockquote callout. Readers scanning the CLI reference cannot tell this unbuilt
capability from shipped behaviour, and the issue reference is not linked at this point. The same
file also names hosted conformance as tracked in #9253 (line 121-123) without the callout format.

Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 96 rules
✅ Skills: 5 invoked
  writing-user-docs
  writing-adrs
  check-patch-coverage
  cutting-releases
  adr-corner
✅ Cross-repo context — repo relationships
  Explored: repo: fullsend-ai/agents (sha: ef1bb846) — View relationship
Review mode: Auto: 🧠 Deep: Security-sensitive journal, CAS, leases, credentials, and many independent code paths.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread docs/cli/journal.md Resolved
Comment thread internal/journalhost/profile.go Resolved
Comment thread internal/forge/gitlab/versioned_file.go Resolved
Comment thread internal/journal/requirements.go Resolved
Signed-off-by: eshulman2 <ellashulman1@gmail.com>
@eshulman2

Copy link
Copy Markdown
Contributor Author

Addressed the seven review findings in db7ba9b, including the summary-only planned-feature callout request. Hosted conformance/migration and trace instrumentation now use linked Planned callouts.

Validation: race-enabled tests for internal/cli, internal/journal, internal/journalhost and internal/forge/gitlab; make go-vet; staged make lint. All passed. The new writer-isolation check and changed parent-guard/write-classification functions have 100% local function coverage. Used GOFLAGS=-buildvcs=false for the existing local VCS-discovery environment issue.

@jflowers jflowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Council verdict: REQUEST CHANGES

Seven review personas ran against main...codex/journal-primitives (d83d2ec7 → 48cc7d133). Five approved with advisories, one approved, and the testing reviewer requested changes. Consolidation lands on REQUEST CHANGES on one HIGH finding.

This PR extracts the protected-host recovery journal onto current main: a checksummed journal document with conditional transitions and ownership fencing, conditional versioned-file operations through forge.Client (GitLab backend, GitHub/Forgejo stubs), a journalhost profile with credential isolation, and the fullsend journal CLI. The engine, the forge integration, and the credential boundaries look solid overall; the gap sits in test coverage for the parent-digest contract.

Counts: 21 findings from 7 reviewers, 20 unique after cross-persona dedup (1 HIGH, 6 MEDIUM, 13 LOW). All CI checks pass on the head commit.

The blocking finding (internal/cli/journal_test.go:139, inline below): Requirement.DataDigest hashes the raw json.RawMessage bytes, while every re-marshal compacts that content. could a digest computed from journal read output, or from Admit/Update/Rebind return values, ever match requiredBackend.validateMutation for non-trivial parent data? from what I can tell the stale-parent fence then rejects every such mutation; fail-closed, but the path looks unusable. Document.checksum avoids the trap by hashing the compacted marshal. Pinning the byte representation (or canonicalizing the way checksum() does), plus a test deriving a digest from the CLI surface, would settle it.

Remaining findings not attached inline:

  • test structure: TestAdmissionOwnershipAndRestart, TestInvalidArgumentsAndMissingRecords, and TestRequiredParentStateFencesChildEffects chain 10+ scenarios each; could they split into t.Run subtests (internal/journal/journal_test.go:36)?
  • defensive branches without coverage: the Claim generation-overflow guard, unknown effectID, receipt on a non-confirmed effect, and the validateDocument cardinality caps (internal/journal/journal.go:171).
  • the operations guide could carry a protected-host journal tutorial once hosted conformance lands (docs/guides/getting-started/operations.md:236).
  • positive notes worth recording: the profile validation is strict (duplicate-key rejection, DisallowUnknownFields, HTTPS-only, traversal checks; built-in roles refused for journal credentials), and the GitLab-only initial storage with guidance to never recreate a journal is documented clearly.

Prior review context: the qodo bot flagged requirements.go:47 (parent-digest guards rejecting non-empty parents). The HIGH finding above is related but distinct; it concerns which byte representation the digest covers, not the guard logic itself.

This review was generated by /uf.review-pr (AI-assisted).

Comment thread internal/cli/journal_test.go Resolved
Comment thread internal/journal/journal_test.go Resolved
Comment thread internal/cli/journal.go Resolved
Comment thread internal/cli/journal.go Resolved
Comment thread internal/forge/forge.go Resolved
Comment thread internal/cli/journal_retry_test.go Resolved
Comment thread internal/forge/gitlab/versioned_file.go Resolved
Comment thread internal/journalhost/profile.go Resolved
Signed-off-by: eshulman2 <ellashulman1@gmail.com>

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review-only pass: three findings inline (two HIGH, one MEDIUM). None duplicates an existing thread.

Comment thread internal/forge/gitlab/versioned_file.go Resolved
Comment thread internal/journalhost/profile.go Resolved
Comment thread internal/forge/gitlab/versioned_file.go Resolved
Signed-off-by: eshulman2 <ellashulman1@gmail.com>
@eshulman2
eshulman2 requested a review from waynesun09 December 1, 2026 08:28

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review-only pass: three MEDIUM findings inline. None duplicates an existing thread.

Comment thread internal/forge/gitlab/versioned_file.go Resolved
Comment thread internal/forge/gitlab/versioned_file.go Resolved
Comment thread internal/cli/journal.go Resolved
Signed-off-by: eshulman2 <ellashulman1@gmail.com>

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review-only pass: three MEDIUM findings inline. None duplicates an existing thread.

}
matched, canPush := false, false
for _, rule := range rules {
if rule.Name == "" || strings.ContainsAny(rule.Name, "\\?[] \t\r\n") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: An unrelated protected-branch rule with a bracket, ? or space in its name disables the journal

verifyWriterIsolation checks each rule name for a blocked character (backslash, ?, [, ], space, tab, CR, LF) and returns errWriterGrants before it checks whether the rule matches the journal branch. GitLab treats only * as a wildcard in protected-branch names, so a rule named like release/[1.0] is just a literal name. Any such rule anywhere in the control project, even one for another branch, makes every journal command fail. The operator then sees "journal requires writer-only branch push, merge and unprotect grants", which sends them to the journal branch's grants instead of the rule that actually caused the failure. The tests cover an unrelated wildcard rule (other*) but not an unrelated rule with one of these characters.

Suggestion: Match the rule first, using QuoteMeta plus * -> .*, which already handles the other characters literally. Fail closed only for rules that match the journal branch, and return a rule-specific message when you do. Add a regression test with an unrelated release/[1.0] rule.

Verified: read code at head (profile.go:149-157, profile_test.go:186) at e986313; raised by: DeepSeek

}

// Credential refuses built-in roles: journal writes do not widen Analyst or Poller.
func (p Profile) Credential(getenv func(string) string) (string, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: The journal writer credential can be the same token or GitLab user as the Analyst, Coder or Poller roles

Credential only requires a registered custom role with credential kind own and write_repository. Nothing checks that the journal token's value, or the GitLab user behind it, differs from the other registered roles' credentials. verifyWriterIsolation confirms that "the writer user" is the only one who can push, merge and unprotect. If an operator gives the journal role the same PAT as FULLSEND_GITLAB_ANALYST_TOKEN or CODER_TOKEN, or a PAT for the same bot user, that check passes, and any process holding the assessment token can rewrite journal state. So the independent writer identity the docs require is enforced only by convention. The existing thread on line 123 dealt with branch grants, not with the writer identity overlapping another role's.

Suggestion: In Credential or the Authorizer, reject a journal token equal (constant-time compare) to any other registered role token present in the host env. Where those tokens are available, also resolve each one's /user ID and refuse when it matches the writer's ID. Add tests for both the same-value case and the same-user case.

Verified: read code at head (profile.go:66-79, 133-190) at e986313; raised by: Claude

Comment thread internal/journal/forge.go
}
data, rev, err := b.client.ReadVersionedFile(ctx, b.location.Owner, b.location.Repo, b.location.Branch, b.location.Path)
if err != nil {
return Document{}, "", conflict(nonretryableReadError(err))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM: An uninitialized journal or missing control branch shows the generic "inspect permissions" error

Load wraps forge.ErrNotFound from ReadVersionedFile via conflict(nonretryableReadError(err)), and Initialize returns the GetBranchRef error unchanged (line 37). sanitizeJournalError recognizes journal.ErrNotFound (the record-level sentinel) and the journalhost operator sentinels, but not forge.ErrNotFound. So journal read before journal initialize, and journal initialize on a branch that does not exist, both print "journal operation failed; inspect control repository and connection permissions". The docs say the branch must already exist and that missing state needs manual recovery, but the operator never sees which case they hit. The earlier sanitizer thread (cli/journal.go:140, fixed in e986313) covered the host and JSON-input guidance strings only, not storage not-found errors.

Suggestion: In Load, map forge.ErrNotFound to a fixed sentinel such as "journal not initialized". In Initialize, map it to "journal control branch missing". Add both sentinels to sanitizeJournalError's pass-through list and keep redaction for every other error. Add CLI tests for read-before-initialize and initialize-on-missing-branch.

Verified: read code at head (journal/forge.go:32-66,148-153; cli/journal.go:128-141; journalhost/errors.go) at e986313; raised by: DeepSeek

@ascerra ascerra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the docs and the forge changes at e986313. I have a follow-up for #9253 in two parts, and I don't think either belongs in this PR.

The new section covers opting in by hand (here) and says workflow integration is explicit, which matches ADR 0165 (here). What I couldn't find tracked is a setting that turns journal-backed recovery on for one repository, if the workflows Fullsend installs come to use it. I'd like that in repos.yaml, per repository and per agent, or per workflow if that's the unit that fits the ADR better. repos.yaml already declares each repository's .fullsend/config.yaml (here). The protected profile would still decide where the journal lives and who may write it (here).

The open question we added to the problem doc asks whether Fullsend should ship reusable adapters, and it points to #9253 for shared journal integration (here). Could #9253 get an item for that setting? The second part is the trace work that the command reference points to #9253 for (here). It isn't in the issue's list either, only in a comment of mine (here).

Verified: the docs and forge changes read at e986313 and compared with main ad41a65; raised by: Claude

This branch was successfully deployed

1 active (outdated) deployment
site-preview — 9498f5a3 Deployed Nov 30, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants