You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 72a1f03
Browse filesBrowse the repository at this point in the historyBrowse files
.NET: Replace the runtime alignment check with a documented contract
From @westey-m's review. Policing implementations that are not per spec is not
worth the cost at runtime; the expectation belongs on the type an implementer is
reading when they get it wrong. A conformance test library, which is the real
answer for checking an implementation, is tracked separately as microsoft#7931.
SearchAlignment and BaseSearchResults are deleted, along with
ReportsAlignedLineNumbers and its two overrides and DisableSearchAlignmentCheck
on both provider options. SearchAsync returns its results directly instead of a
tagged list, and neither provider verifies what a store reports.
The contract those types enforced now sits on SearchAsync itself: a store
overriding it must number FileSearchMatch.LineNumber as a 1-based coordinate
into SplitLines of the content ReadAsync returns, ScanContent builds that
correctly, and numbering against anything else is a bug whose failure mode is
silent -- the search looks right, and the damage appears when a later line edit
applies to a line the caller never saw.
Two doc comments elsewhere still said the tools verify the numbering, which is
no longer true of either. The FileSearchMatch and FileEditor remarks also scoped
the rule to the stores shipped here rather than stating what implementers owe;
both now read as expectations, which the same review asked for.
Descriptions that state the line-counting rule now also say the numbers are
1-based, so a model counting lines from a whole-file read knows where to start.
Eight tests went with the check: seven alignment cases and their six helper
stores in AgentFileStoreContractTests, and the memory-refusal test with its
skewed store in FileMemoryProviderTests. Nothing exercised the removed types
otherwise; the remaining 2099 unit tests pass.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
/// <param name="fileName">The name of the file to read.</param>
305
303
/// <param name="cancellationToken">A token to cancel the operation.</param>
306
304
/// <returns>The file content or a not-found message.</returns>
307
-
[Description("Read the content of a file by name. Returns the file content or a message indicating the file was not found. To edit by line number afterwards, count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
305
+
[Description("Read the content of a file by name. Returns the file content or a message indicating the file was not found. To edit by 1-based line number afterwards, count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
/// The line numbers agree with the ones <c>file_access_grep</c> reports, because
325
323
/// <see cref="AgentFileStore.SearchAsync"/> must number by <see cref="AgentFileStore.SplitLines"/> —
326
324
/// the split this method and <c>file_access_replace_lines</c> use. A store overriding it owns that
327
-
/// numbering, so <c>file_access_grep</c> verifies it and refuses results that do not line up.
325
+
/// numbering; getting it wrong makes an edit land on a line the caller never saw.
328
326
/// </remarks>
329
327
/// <exception cref="ArgumentException">
330
328
/// Thrown when either bound is not positive, when <paramref name="endLine"/> precedes
331
329
/// <paramref name="startLine"/>, or when <paramref name="startLine"/> is past the last line.
332
330
/// </exception>
333
-
[Description("Read part of a file by 1-based inclusive line number; omit endLine to read to the end of the file, and an endLine past the last line is clamped. Each line is prefixed with its number and a tab; everything after that tab is verbatim, including the line's own terminator, so it can be reused as a file_access_replace_lines new_line. Line numbers count lines terminated by \\n, \\r\\n, or a lone \\r, and content ending in a terminator has no extra empty line after it.")]
331
+
[Description("Read part of a file by 1-based inclusive line number; omit endLine to read to the end of the file, and an endLine past the last line is clamped. Each line is prefixed with its number and a tab; everything after that tab is verbatim, including the line's own terminator, so it can be reused as a file_access_replace_lines new_line. Line numbers are 1-based and count lines terminated by \\n, \\r\\n, or a lone \\r, and content ending in a terminator has no extra empty line after it.")]
/// <param name="edits">The list of 1-based line numbers and their literal replacement text.</param>
434
432
/// <param name="cancellationToken">A token to cancel the operation.</param>
435
433
/// <returns>A confirmation message including the number of lines replaced, or a failure message.</returns>
436
-
[Description("Replace lines in a file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers. Line numbers count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
434
+
[Description("Replace lines in a file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers. Line numbers are 1-based and count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
- '**' matches across subdirectories, so use \"**/*.md\" to match markdown files at any depth, or \"reports/**\" to restrict the search to the 'reports' subtree.
474
472
475
473
Returns matching results whose file names are paths relative to the store root (usable with file_access_read), along with snippets and matching lines with line numbers.
476
-
Line numbers count lines terminated by \n, \r\n, or a lone \r, and content ending in a terminator has no extra empty line after it.
474
+
Line numbers are 1-based and count lines terminated by \n, \r\n, or a lone \r, and content ending in a terminator has no extra empty line after it.
/// <param name="fileName">The name of the file to read.</param>
224
216
/// <param name="cancellationToken">A token to cancel the operation.</param>
225
217
/// <returns>The file content or a not-found message.</returns>
226
-
[Description("Read the content of a memory file by name. Returns the file content or a message indicating the file was not found. To edit by line number afterwards, count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
218
+
[Description("Read the content of a memory file by name. Returns the file content or a message indicating the file was not found. To edit by 1-based line number afterwards, count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
/// <param name="edits">The list of 1-based line numbers and their literal replacement text.</param>
365
357
/// <param name="cancellationToken">A token to cancel the operation.</param>
366
358
/// <returns>A confirmation message including the number of lines replaced, or a failure message.</returns>
367
-
[Description("Replace lines in a memory file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers. Line numbers count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
359
+
[Description("Replace lines in a memory file. Provide a list of edits, each with a 1-based line_number and a literal new_line (include your own trailing newline); an empty new_line deletes the line, including its line break. Fails on out-of-range or duplicate line numbers. Line numbers are 1-based and count lines terminated by \\n, \\r\\n, or a lone \\r; each line keeps its own terminator, and content ending in a terminator has no extra empty line after it.")]
0 commit comments