Skip to content

Close relation campaign and structural debt - #12

Merged
heyoub merged 1 commit into
mainfrom
feat/crunch-closeout
Jul 16, 2026
Merged

Close relation campaign and structural debt#12
heyoub merged 1 commit into
mainfrom
feat/crunch-closeout

Conversation

@heyoub

@heyoub heyoub commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Enforce a hard global semantic candidate-pair page budget with a durable cursor, resumable completion, and one-shot equivalence.
  • Add an explicit rejudge path that evicts the selected cache entry while preserving the first durable judgment as authority.
  • Keep a targeted rejudge of an already-complete campaign complete instead of restarting candidate paging; reject requests whose pair left the current semantic set.
  • Persist relation-campaign checkpoints with closed Partial/Complete states, exact-frontier replay, checkpoint-last ordering, temporal-evidence identity, and settlement gates.
  • Give campaign checkpoints transition-aware BatPak identities so Complete-after-Partial is durable while exact retries still return the original receipt.
  • Use one exact durable settlement predicate across compile, agent context, workspace status, and knowledge triangulation.
  • Make compile and agent-context settlement-safe by default; callers must deliberately choose --allow-unsettled for the offline heuristic demo path.
  • Split the operation registry and oversized production/test modules into concern-oriented files; every Rust function is at most 100 AST lines and every production Rust file is at most 800 lines.
  • Replace frozen Helios behavioral assertions with a rendering-only fixture plus a key-gated live oracle E2E.
  • Remove every lint suppression attribute and Cargo lint allowance; add durable Clippy denies for oversized functions and argument lists.
  • Remove the stale cargo-deny advisory exception and unused license policy entries.
  • Make the semantic demo page until actual completion before compiling.
  • Correct the relate effect contract: declare the actual deferral event and require texo.cap.model at host admission, with descriptor and no-capability regression tests.

Root causes

Candidate enumeration previously had no hard global page boundary, relation progress was not represented as durable campaign state, and output/status paths inferred completion from incomplete proxies. Large mixed-concern modules also hid state and control-flow boundaries, while lint suppressions allowed structural debt to accumulate.

User and operator impact

texo relate now reports page budget and resume cursor in human and JSON output, completed campaigns are durable no-ops, and suspect verdicts can be explicitly rejudged without reopening a settled campaign. Workspace status and knowledge triangulation now agree with default compile/context about whether settlement is complete. Default compile and agent-context calls reject absent, partial, or stale campaign state. The offline heuristic demo and startup hook use a conspicuous allow_unsettled opt-out where incomplete semantic settlement is intentional.

Validation

  • cargo check --all-targets
  • cargo clippy --all-targets -- -D warnings
  • cargo deny check — advisories, bans, licenses, and sources all clean with no warnings
  • just verify — 296 unit tests plus all integration, compile-fail, and doc tests passed
  • just test-invariants — projection laws, compile-fail laws, and BatPak-family spikes passed
  • Focused durable campaign, completed-rejudge, noncurrent-rejudge rejection, settlement-status, renderer, rejudge durability, MCP, knowledge-index, remote-replication, and Helios rendering tests passed
  • Fresh isolated just demo-fresh generated all six artifacts; texo verify --json reported zero errors with journal/projection/transitions all true
  • Direct default compile and agent-context calls were verified to fail closed without a complete campaign and emit no strict compile artifact
  • Missing-key semantic demo and live oracle gate fail closed; a hosted live run still requires TEXO_LLM_API_KEY

Closes #1
Closes #3
Closes #5
Closes #6
Closes #7
Closes #8

Greptile Summary

This PR adds durable, resumable relation campaigns and makes semantic settlement the default for authority-bearing output. The main changes are:

  • Bounded candidate-pair paging with durable cursors and completion checkpoints.
  • Targeted rejudging without reopening completed campaigns.
  • Shared settlement checks across compile, agent context, workspace status, and knowledge output.
  • Explicit --allow-unsettled opt-outs for offline demo paths.
  • Concern-oriented module splits and stricter Rust lint limits.
  • Rendering-only Helios fixtures with a key-gated live oracle test.

Confidence Score: 5/5

This looks safe to merge.

The compile and agent-context gates now default to requiring complete settlement. Callers must explicitly opt out with allow_unsettled. No blocking issues were found in the updated settlement paths.

T-Rex T-Rex Logs

What T-Rex did

  • Compared the before-commit campaign-validation log with the after-commit log to confirm the new test targets were absent in the parent and that the HEAD run completed successfully with the expected test names and totals.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/ops/handlers/compile.rs Compilation now requires complete settlement unless the caller explicitly sets allow_unsettled.
src/ops/handlers/agent_context.rs Agent context now fails closed by default and checks settlement against the selected snapshot view.

Reviews (6): Last reviewed commit: "close relation campaign and structural d..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 160 files, which is 110 over the limit of 50.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

Upgrade to a paid plan to raise the limit.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c9235ed-3d41-40e0-9784-b898a92a39a5

📥 Commits

Reviewing files that changed from the base of the PR and between cc0b7ba and 3013b5b.

📒 Files selected for processing (161)
  • Cargo.toml
  • deny.toml
  • justfile
  • src/backup.rs
  • src/backup/create.rs
  • src/backup/filesystem.rs
  • src/backup/model.rs
  • src/backup/restore.rs
  • src/backup/verify.rs
  • src/bin/texo.rs
  • src/claims/campaign.rs
  • src/claims/mod.rs
  • src/claims/status.rs
  • src/code_index.rs
  • src/code_index/analysis.rs
  • src/code_index/artifact.rs
  • src/code_index/contract.rs
  • src/code_index/persistence.rs
  • src/code_index/scip_import.rs
  • src/code_index/util.rs
  • src/config.rs
  • src/config/model.rs
  • src/doctor.rs
  • src/doctor/model.rs
  • src/error.rs
  • src/events/coordinate.rs
  • src/events/ids.rs
  • src/events/inventory.rs
  • src/events/machines.rs
  • src/events/mod.rs
  • src/events/payloads.rs
  • src/events/payloads/campaign.rs
  • src/events/payloads/session.rs
  • src/extract/cache.rs
  • src/extract/faithfulness.rs
  • src/extract/heuristics.rs
  • src/extract/hints.rs
  • src/extract/markdown.rs
  • src/extract/mod.rs
  • src/extract/normalize.rs
  • src/extract/word_match.rs
  • src/gateway.rs
  • src/gateway/model.rs
  • src/host/mod.rs
  • src/host/model.rs
  • src/host/module.rs
  • src/install.rs
  • src/install/adapter.rs
  • src/install/entry.rs
  • src/install/filesystem.rs
  • src/install/model.rs
  • src/install/tests.rs
  • src/knowledge.rs
  • src/knowledge/contracts.rs
  • src/knowledge/tests.rs
  • src/ops/agent.rs
  • src/ops/agent/chat.rs
  • src/ops/backend.rs
  • src/ops/backend/effect.rs
  • src/ops/backend/policy.rs
  • src/ops/env.rs
  • src/ops/env/context.rs
  • src/ops/handlers.rs
  • src/ops/handlers/agent_context.rs
  • src/ops/handlers/claims.rs
  • src/ops/handlers/common.rs
  • src/ops/handlers/compile.rs
  • src/ops/handlers/conflicts.rs
  • src/ops/handlers/host.rs
  • src/ops/handlers/ingest.rs
  • src/ops/handlers/ingest/supersession.rs
  • src/ops/handlers/knowledge.rs
  • src/ops/handlers/knowledge_read.rs
  • src/ops/handlers/model.rs
  • src/ops/handlers/relate.rs
  • src/ops/handlers/relate/authority.rs
  • src/ops/handlers/relate/backend.rs
  • src/ops/handlers/relate/campaign.rs
  • src/ops/handlers/relate/publication.rs
  • src/ops/handlers/render.rs
  • src/ops/handlers/stats.rs
  • src/ops/handlers/verify.rs
  • src/ops/handlers/workspace.rs
  • src/reconcile.rs
  • src/reconcile/domain.rs
  • src/relate/settlement.rs
  • src/replication.rs
  • src/replication/evidence.rs
  • src/replication/lifecycle.rs
  • src/replication/materialize.rs
  • src/replication/remote.rs
  • src/semantics/mod.rs
  • src/semantics/openrouter.rs
  • src/semantics/openrouter/tests.rs
  • src/semantics/pipeline.rs
  • src/semantics/pipeline/candidate.rs
  • src/semantics/pipeline/reduction.rs
  • src/semantics/pipeline/runtime.rs
  • src/semantics/pipeline/tests/basic.rs
  • src/semantics/pipeline/tests/mod.rs
  • src/semantics/pipeline/tests/parallel.rs
  • src/semantics/pipeline/tests/settlement.rs
  • src/semantics/pipeline/tests/temporal.rs
  • src/semantics/score.rs
  • src/semantics/traits.rs
  • src/surfaces/bootstrap.rs
  • src/surfaces/bootstrap/model.rs
  • src/surfaces/bootstrap/resolver.rs
  • src/surfaces/cli/dispatch/durability.rs
  • src/surfaces/cli/dispatch/integrations.rs
  • src/surfaces/cli/dispatch/mod.rs
  • src/surfaces/cli/dispatch/semantics.rs
  • src/surfaces/cli/dispatch/surfaces.rs
  • src/surfaces/cli/dispatch/workspace.rs
  • src/surfaces/cli/mod.rs
  • src/surfaces/cli/render.rs
  • src/surfaces/cli/render/tests.rs
  • src/surfaces/http/chunked.rs
  • src/surfaces/http/client.rs
  • src/surfaces/http/client/tests.rs
  • src/surfaces/http/codec.rs
  • src/surfaces/http/mod.rs
  • src/surfaces/http/request.rs
  • src/surfaces/http/response.rs
  • src/surfaces/http/retry.rs
  • src/surfaces/http/schedule.rs
  • src/surfaces/http/server.rs
  • src/surfaces/http/types.rs
  • src/surfaces/openai.rs
  • src/topology.rs
  • src/topology/model.rs
  • tests/agent_catalog.rs
  • tests/agent_context.rs
  • tests/backend_relation_rejudge_durability.rs
  • tests/compile_fail/illegal_claim_reverse.stderr
  • tests/compile_journaled.rs
  • tests/demo_flow.rs
  • tests/e2e_pipeline.rs
  • tests/eval_helios.rs
  • tests/golden_agent_context.rs
  • tests/golden_compile.rs
  • tests/golden_ingest.rs
  • tests/golden_staleness.rs
  • tests/helios_e2e.rs
  • tests/helios_frozen.rs
  • tests/http_server.rs
  • tests/ingest_contract.rs
  • tests/knowledge_index.rs
  • tests/mcp_stdio.rs
  • tests/ops_kit.rs
  • tests/oracle_live.rs
  • tests/relation_campaign_gate.rs
  • tests/remote_replication.rs
  • tests/session_lanes.rs
  • tests/spike_family.rs
  • tests/staleness_courtroom.rs
  • tests/support/courtroom.rs
  • tests/support/mod.rs
  • tests/support/model.rs
  • tests/support/sample.rs
  • tests/topology_scaleout.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Review on demand using usage pricing
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/crunch-closeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/ops/handlers/compile.rs Outdated
Comment thread src/ops/handlers/agent_context.rs
@heyoub
heyoub marked this pull request as ready for review July 16, 2026 00:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9efc5dc19f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ops/handlers/relate.rs Outdated
let already_complete =
campaign_start == CampaignStart::AlreadyComplete && rejudge_pair.is_none();
let candidate_cursor = match campaign_start {
CampaignStart::AlreadyComplete => CandidateCursor::start(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep rejudge from reopening complete campaigns

When rejudge_pair is requested for a campaign that is already Complete, already_complete is forced false but this branch restarts normal campaign paging from cursor 0. On any workspace whose total candidate space exceeds max_candidate_pairs, the rejudge succeeds and then publishes a new Partial checkpoint, making the latest durable campaign partial and causing strict compile/context calls to fail until the whole campaign is replayed.

Useful? React with 👍 / 👎.

Comment thread src/ops/handlers/compile.rs Outdated
Comment on lines +90 to +91
#[serde(default)]
strict_settlement: bool,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Default compile to the settlement gate

When an existing or direct texo.compile.run caller omits strict_settlement, this default makes it false, so the handler skips require_complete_settlement. In workspaces with no checkpoint, a partial checkpoint, or a stale complete checkpoint, compile can still write public artifacts and append OnboardingCompiledV2, bypassing the closed-campaign gate added by this change.

Useful? React with 👍 / 👎.

Comment thread src/ops/handlers/agent_context.rs Outdated
Comment on lines +50 to +51
#[serde(default)]
strict_settlement: bool,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Default agent context to the settlement gate

Callers that omit strict_settlement still get false here; the MCP get_agent_context adapter is one such path because it only sends subject and include_stale. That lets agent context expose current claims before an absent, partial, or stale relation campaign has settled supersession/conflict authority, even though strict settlement is the new gate for authority-bearing context.

Useful? React with 👍 / 👎.

@heyoub
heyoub force-pushed the feat/crunch-closeout branch from 9efc5dc to e750943 Compare July 16, 2026 00:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e750943967

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ops/handlers/workspace.rs Outdated
freshness: view.freshness,
claims_total: view.claims.len(),
open_conflicts: view.conflicts.iter().filter(|card| card.phase == 1).count(),
settlement_complete: unresolved_pairs == 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report incomplete until durable campaign completes

When a workspace has no matching RelationCampaignCheckpointV1 or only a pagination Partial checkpoint with no failed pairs, authoritative_settlements still yields unresolved_pairs == 0, so texo.workspace.status reports settlement_complete: true. Default texo.context.agent and texo.compile.run now call require_complete_settlement and will reject those same frontiers, so MCP/CLI users can be told settlement is complete immediately before authority-bearing calls fail; this flag needs to include the same complete-checkpoint test as the gate.

Useful? React with 👍 / 👎.

let mut output = empty_relate_output(prepared.claims.len(), prepared.candidate_pair_budget);
output.receipts = take_receipts()?;
return Ok(output);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject rejudge before the trivial campaign shortcut

When rejudge_pair is supplied but fewer than two claims are currently eligible (for example, the authoritative pair was later superseded or put in conflict), this shortcut returns a successful complete campaign before rejudge_authoritative_pair runs. The requested cache eviction and fresh judgment are silently skipped and rejudged_pair stays null, so the command should either process the rejudge first or return an input error instead of taking the trivial-complete path.

Useful? React with 👍 / 👎.

@heyoub
heyoub force-pushed the feat/crunch-closeout branch from e750943 to a439df2 Compare July 16, 2026 01:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a439df2872

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ops/backend/policy.rs Outdated
Comment on lines +457 to +458
let key = IdempotencyKey::for_operation(
"texo.relation.campaign.checkpoint.v1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow complete checkpoints to supersede later partials

When a workspace already has an older matching Complete checkpoint and then gets a later Partial checkpoint for the same basis/policy, a successful resume attempts to append the same complete checkpoint identity used by the old event. Because this idempotency key is independent of journal position, BatPak returns the old complete receipt instead of writing a new checkpoint after the partial, so latest_checkpoint still sees the partial and strict compile/context remain stuck. Fresh evidence is that the checkpoint backend now deduplicates complete checkpoints by phase/digests, even though the relation gate depends on the latest checkpoint in commit order.

Useful? React with 👍 / 👎.

@heyoub
heyoub force-pushed the feat/crunch-closeout branch from a439df2 to 795f095 Compare July 16, 2026 01:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

appends_events = ["evt.e001", "evt.e002", "evt.e003", "evt.e004", "evt.e009", "evt.e00a"],

P2 Badge Declare campaign checkpoint writes from session end

When texo.agent.session.end has a relate model configured, run_session_relate calls run_relate_pass, and the new relation campaign flow appends a RelationCampaignCheckpointV1 (evt.e012) for trivial, partial, and complete runs. Because this operation descriptor still omits evt.e012, the host manifest under-declares a write that happens on every session-end relate pass with a model key.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/ops/handlers/relate.rs Outdated
input_schema = "texo.relate.run.input.v2",
output_schema = "texo.relate.run.output.v2",
receipt_kind = "receipt.texo.relate.run.v2",
appends_events = ["evt.e003", "evt.e004", "evt.e009", "evt.e010", "evt.e012"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Declare the actual deferral event kind

When a relate page records unresolved pairs, append_relation_deferrals appends RelationDeferredV1; that payload is type_id 10 and is advertised elsewhere as evt.e00a, not evt.e010. This descriptor now omits the real deferral event and claims an unrelated event kind, so the host/module manifest and ops catalog under-declare partial/failure-page writes and over-declare an event this operation does not append.

Useful? React with 👍 / 👎.

Comment thread src/ops/handlers/relate.rs Outdated
output_schema = "texo.relate.run.output.v2",
receipt_kind = "receipt.texo.relate.run.v2",
appends_events = ["evt.e003", "evt.e004", "evt.e009", "evt.e010", "evt.e012"],
queries_projections = ["texo.workspace.view.v2"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore model-capability admission for relate

For environments without a model key, the host only grants texo.cap.model when grants_model_capability sees a non-empty key, and other model-backed operations still require that capability. This descriptor dropped the requirement for texo.relate.run, so texo relate is admitted without a model capability and fails later in the OpenRouter backend instead of through the central fail-closed admission path (op.denied/503-style behavior).

Useful? React with 👍 / 👎.

@heyoub
heyoub force-pushed the feat/crunch-closeout branch from 795f095 to 072d1ae Compare July 16, 2026 02:03
@heyoub
heyoub force-pushed the feat/crunch-closeout branch from 072d1ae to 3013b5b Compare July 16, 2026 02:26
@heyoub
heyoub merged commit 9b23d12 into main Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant