Skip to content

Commit 73afe4e

Browse files
committed
fix(agent-tools): remove read freshness gating
Remove session-scoped Read freshness checks from Edit and Write, including state recording, mutation backfills, and obsolete contracts. Keep prompt guidance requiring agents to read files before editing. The gate cannot correct an inaccurate old_string. It adds rejection conditions beyond content matching: changes outside the target block can invalidate an otherwise applicable edit, while rollback or context replacement clears cached reads. Since the state is memory-only, restarting also loses Read records even when the restored conversation still contains the relevant file content. This follows established approaches in Codex and OpenCode: - Codex apply_patch reads current file content and matches patch context without requiring session-scoped prior-Read credentials. - OpenCode previously tracked read timestamps, mtime, and size per session and path, rejecting edits and overwrites without a prior Read or after metadata changes. Commit 76a141090, "chore: delete filetime module (#22999)", removed that module, its Read/Edit/Write integration, the disable-check flag, and associated tests. - Current OpenCode edit and apply_patch match against current content; write likewise has no runtime prior-Read gate. Preserve Deep Review range receipts in a separate store, including their session cleanup behavior. Improve old_string mismatch errors to mention external changes or incorrectly copied or generated text, retain nearby-content diagnostics, and direct agents to Read the current target region before correcting the edit and retrying.
1 parent 7a0cdba commit 73afe4e

23 files changed

Lines changed: 503 additions & 1693 deletions

‎scripts/core-boundaries/rules/source/forbidden-rules.mjs‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,22 +1665,27 @@ export const forbiddenContentRules = [
16651665
],
16661666
},
16671667
{
1668-
path: 'src/crates/assembly/core/src/agentic/session/file_read_state.rs',
1668+
path: 'src/crates/assembly/core/src/agentic/session/review_read_receipt.rs',
16691669
patterns: [
16701670
{
1671-
regex: /\bpub struct FileReadState\b/,
1671+
regex: /\bpub struct FileRevision\b/,
16721672
message:
1673-
'core file_read_state must not own file-read state DTOs; use openbitfun-agent-runtime file_read_state',
1673+
'core review_read_receipt must not own file revision DTOs; use openbitfun-agent-runtime review_read_receipt',
16741674
},
16751675
{
1676-
regex: /\bpub struct FileReadStateStore\b/,
1676+
regex: /\bpub struct ReviewReadCoverage\b/,
16771677
message:
1678-
'core file_read_state must not own in-memory file-read state store; use openbitfun-agent-runtime file_read_state',
1678+
'core review_read_receipt must not own review coverage DTOs; use openbitfun-agent-runtime review_read_receipt',
1679+
},
1680+
{
1681+
regex: /\bpub struct ReviewReadReceiptStore\b/,
1682+
message:
1683+
'core review_read_receipt must not own the receipt store; use openbitfun-agent-runtime review_read_receipt',
16791684
},
16801685
{
16811686
regex: /\bDashMap\b/,
16821687
message:
1683-
'core file_read_state must not own file-read state storage maps; use openbitfun-agent-runtime file_read_state',
1688+
'core review_read_receipt must not own receipt storage maps; use openbitfun-agent-runtime review_read_receipt',
16841689
},
16851690
],
16861691
},
@@ -2715,12 +2720,12 @@ export const forbiddenContentRules = [
27152720
],
27162721
},
27172722
{
2718-
path: 'src/crates/assembly/core/src/agentic/tools/file_read_state_runtime.rs',
2723+
path: 'src/crates/assembly/core/src/agentic/tools/review_read_receipt_runtime.rs',
27192724
patterns: [
27202725
{
27212726
regex: /framework::(?:\{[^}]*\bToolUseContext\b[^}]*\}|\bToolUseContext\b)/,
27222727
message:
2723-
'file read-state runtime must import ToolUseContext from tool_context_runtime, not the framework re-export',
2728+
'review read receipt runtime must import ToolUseContext from tool_context_runtime, not the framework re-export',
27242729
},
27252730
],
27262731
},
@@ -3047,16 +3052,6 @@ export const forbiddenContentRules = [
30473052
},
30483053
],
30493054
},
3050-
{
3051-
path: 'src/crates/assembly/core/src/agentic/tools/file_read_state_runtime.rs',
3052-
patterns: [
3053-
{
3054-
regex: /\bnormalize_string\b/,
3055-
message:
3056-
'core file read-state runtime must delegate pure freshness normalization to openbitfun-agent-tools',
3057-
},
3058-
],
3059-
},
30603055
{
30613056
path: 'src/crates/assembly/core/src/agentic/tools/tool_result_storage.rs',
30623057
patterns: [

‎scripts/core-boundaries/rules/source/public-api-rules.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const agentRuntimeRootPublicModules = [
3030
'event_source',
3131
'events',
3232
'evidence_ledger',
33-
'file_read_state',
33+
'review_read_receipt',
3434
'native_hooks',
3535
'output_surface',
3636
'permission',

‎scripts/core-boundaries/rules/source/required-rules.mjs‎

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -975,29 +975,29 @@ export const requiredContentRules = [
975975
],
976976
},
977977
{
978-
path: 'src/crates/execution/agent-runtime/src/file_read_state.rs',
978+
path: 'src/crates/execution/agent-runtime/src/review_read_receipt.rs',
979979
reason:
980-
'agent-runtime must own provider-neutral file-read state facts and session-scoped in-memory store',
980+
'agent-runtime must own provider-neutral code-review read receipts and their session-scoped in-memory store',
981981
patterns: [
982982
{
983-
regex: /\bpub struct FileReadState\b/,
984-
message: 'missing agent-runtime file-read state DTO',
983+
regex: /\bpub struct FileRevision\b/,
984+
message: 'missing agent-runtime file revision DTO',
985985
},
986986
{
987-
regex: /\bpub fn is_full_file_read\b/,
988-
message: 'missing agent-runtime file-read completeness policy',
987+
regex: /\bpub struct ReviewReadCoverage\b/,
988+
message: 'missing agent-runtime review read coverage DTO',
989989
},
990990
{
991-
regex: /\bpub struct FileReadStateStore\b/,
992-
message: 'missing agent-runtime file-read state store',
991+
regex: /\bpub struct ReviewReadReceiptStore\b/,
992+
message: 'missing agent-runtime review read receipt store',
993993
},
994994
{
995-
regex: /\bfile_read_state_accepts_nonempty_whole_file\b/,
996-
message: 'missing agent-runtime file-read completeness regression',
995+
regex: /\breview_read_receipt_store_scopes_entries_by_session\b/,
996+
message: 'missing review read receipt session scoping regression',
997997
},
998998
{
999-
regex: /\bfile_read_state_store_scopes_entries_by_session\b/,
1000-
message: 'missing agent-runtime file-read state session scoping regression',
999+
regex: /\breview_read_receipt_covers_only_previously_returned_lines\b/,
1000+
message: 'missing review read receipt coverage regression',
10011001
},
10021002
],
10031003
},
@@ -2853,14 +2853,17 @@ export const requiredContentRules = [
28532853
],
28542854
},
28552855
{
2856-
path: 'src/crates/assembly/core/src/agentic/session/file_read_state.rs',
2856+
path: 'src/crates/assembly/core/src/agentic/session/review_read_receipt.rs',
28572857
reason:
2858-
'core file_read_state path must stay a compatibility facade over agent-runtime',
2858+
'core review_read_receipt path must stay a compatibility facade over agent-runtime',
28592859
patterns: [
28602860
{
2861-
regex:
2862-
/pub use openbitfun_agent_runtime::file_read_state::\{FileReadState, FileReadStateStore\};/,
2863-
message: 'missing agent-runtime file-read state compatibility re-export',
2861+
regex: /openbitfun_agent_runtime::review_read_receipt::\{/,
2862+
message: 'missing agent-runtime review read receipt compatibility re-export',
2863+
},
2864+
{
2865+
regex: /\bReviewReadReceiptStore\b/,
2866+
message: 'missing review read receipt store compatibility re-export',
28642867
},
28652868
],
28662869
},
@@ -5629,28 +5632,6 @@ export const requiredContentRules = [
56295632
},
56305633
],
56315634
},
5632-
{
5633-
path: 'src/crates/execution/tool-contracts/src/file_read_freshness.rs',
5634-
reason: 'agent-tools owns pure file-read freshness policy for Read/Edit/Write guardrails',
5635-
patterns: [
5636-
{
5637-
regex: /\bpub struct FileReadFreshnessFacts\b/,
5638-
message: 'missing file-read freshness facts contract',
5639-
},
5640-
{
5641-
regex: /\bpub fn normalize_tool_file_content\b/,
5642-
message: 'missing provider-neutral file content normalization helper',
5643-
},
5644-
{
5645-
regex: /\bpub fn file_read_facts_content_matches\b/,
5646-
message: 'missing file-read content equivalence helper',
5647-
},
5648-
{
5649-
regex: /\bpub fn file_read_facts_are_fresh\b/,
5650-
message: 'missing file-read freshness policy helper',
5651-
},
5652-
],
5653-
},
56545635
{
56555636
path: 'src/crates/execution/tool-contracts/src/tool_result_storage.rs',
56565637
reason:

‎scripts/core-boundaries/self-test.mjs‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,12 +2368,17 @@ export function runManifestParserSelfTest({
23682368
) {
23692369
throw new Error('agentic system boundary rule must forbid terminal provider construction');
23702370
}
2371-
const coreFileReadStateRuleText = forbiddenRuleTextForPath(
2372-
'src/crates/assembly/core/src/agentic/session/file_read_state.rs',
2371+
const coreReviewReadReceiptRuleText = forbiddenRuleTextForPath(
2372+
'src/crates/assembly/core/src/agentic/session/review_read_receipt.rs',
23732373
);
2374-
for (const contract of ['FileReadState', 'FileReadStateStore', 'DashMap']) {
2375-
if (!coreFileReadStateRuleText.includes(contract)) {
2376-
throw new Error(`core file_read_state boundary rule must forbid ${contract}`);
2374+
for (const contract of [
2375+
'FileRevision',
2376+
'ReviewReadCoverage',
2377+
'ReviewReadReceiptStore',
2378+
'DashMap',
2379+
]) {
2380+
if (!coreReviewReadReceiptRuleText.includes(contract)) {
2381+
throw new Error(`core review_read_receipt boundary rule must forbid ${contract}`);
23772382
}
23782383
}
23792384
const coreEvidenceLedgerRuleText = forbiddenRuleTextForPath(
@@ -3180,13 +3185,13 @@ export function runManifestParserSelfTest({
31803185
],
31813186
},
31823187
{
3183-
path: 'src/crates/execution/agent-runtime/src/file_read_state.rs',
3188+
path: 'src/crates/execution/agent-runtime/src/review_read_receipt.rs',
31843189
contracts: [
3185-
'FileReadState',
3186-
'is_full_file_read',
3187-
'FileReadStateStore',
3188-
'file_read_state_accepts_nonempty_whole_file',
3189-
'file_read_state_store_scopes_entries_by_session',
3190+
'FileRevision',
3191+
'ReviewReadCoverage',
3192+
'ReviewReadReceiptStore',
3193+
'review_read_receipt_store_scopes_entries_by_session',
3194+
'review_read_receipt_covers_only_previously_returned_lines',
31903195
],
31913196
},
31923197
{
@@ -3643,15 +3648,6 @@ export function runManifestParserSelfTest({
36433648
'is_file_tool_guidance_message',
36443649
],
36453650
},
3646-
{
3647-
path: 'src/crates/execution/tool-contracts/src/file_read_freshness.rs',
3648-
contracts: [
3649-
'FileReadFreshnessFacts',
3650-
'normalize_tool_file_content',
3651-
'file_read_facts_content_matches',
3652-
'file_read_facts_are_fresh',
3653-
],
3654-
},
36553651
{
36563652
path: 'src/crates/execution/tool-contracts/src/tool_result_storage.rs',
36573653
contracts: [

‎src/crates/assembly/core/src/agentic/session/file_read_state.rs‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎src/crates/assembly/core/src/agentic/session/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub mod compression;
66
pub mod context_store;
77
mod context_usage;
88
pub mod evidence_ledger;
9-
pub mod file_read_state;
109
pub mod prompt_cache;
1110
pub(crate) mod revert;
11+
pub mod review_read_receipt;
1212
pub mod session_manager;
1313
pub mod session_store_port;
1414
pub mod token_anchor;
@@ -19,8 +19,8 @@ pub use compression::*;
1919
pub use context_store::*;
2020
pub use context_usage::*;
2121
pub use evidence_ledger::*;
22-
pub use file_read_state::*;
2322
pub use prompt_cache::*;
23+
pub use review_read_receipt::*;
2424
pub use session_manager::*;
2525
pub use session_store_port::*;
2626
pub use token_anchor::*;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Compatibility facade for session-scoped code-review read receipts.
2+
3+
pub use openbitfun_agent_runtime::review_read_receipt::{
4+
FileRevision, ReviewReadCoverage, ReviewReadReceiptStore,
5+
};

0 commit comments

Comments
 (0)