Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Scripts/Fixtures/test-suite-contract-ledger.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ root/RepoPromptTests.AgentToolTrackingControllerTests/testStopWaitsForCapturedOb
root/RepoPromptTests.AgentToolTrackingControllerTests/testToolObserverCallbacksReturnBeforeFIFOTranscriptDeliveryCompletes root Tests/RepoPromptTests/AgentMode/AgentToolTrackingControllerTests.swift RepoPromptTests.AgentToolTrackingControllerTests testToolObserverCallbacksReturnBeforeFIFOTranscriptDeliveryCompletes AgentMode unreviewed unreviewed root_swiftpm routine 1 unreviewed unreviewed 0.001000 unreviewed retain_pending_review 0 initial census source line 8
root/RepoPromptTests.AgentTranscriptActivationRepaintRemountPolicyTests/testDuplicateRevisionExceededLimitDetachedOrIdleActivationSuppressesRemount root Tests/RepoPromptTests/AgentMode/Transcript/AgentTranscriptActivationRepaintRemountPolicyTests.swift RepoPromptTests.AgentTranscriptActivationRepaintRemountPolicyTests testDuplicateRevisionExceededLimitDetachedOrIdleActivationSuppressesRemount AgentMode unreviewed unreviewed root_swiftpm routine 1 unreviewed unreviewed 0.000000 unreviewed retain_pending_review 0 initial census source line 20
root/RepoPromptTests.AgentTranscriptActivationRepaintRemountPolicyTests/testEnteredHydratedLiveBottomActivationProducesRemountKey root Tests/RepoPromptTests/AgentMode/Transcript/AgentTranscriptActivationRepaintRemountPolicyTests.swift RepoPromptTests.AgentTranscriptActivationRepaintRemountPolicyTests testEnteredHydratedLiveBottomActivationProducesRemountKey AgentMode unreviewed unreviewed root_swiftpm routine 1 unreviewed unreviewed 0.000000 unreviewed retain_pending_review 0 initial census source line 5
root/RepoPromptTests.AgentAssistantLineDerivationTests/testCRLFCountsAsTwoScalarSeparatorsAndMatchesPreview root Tests/RepoPromptTests/AgentMode/AgentAssistantLineDerivationTests.swift RepoPromptTests.AgentAssistantLineDerivationTests testCRLFCountsAsTwoScalarSeparatorsAndMatchesPreview AgentMode agent_mode.assistant_line_derivation.crlf_agreement assistant_collapse,crlf,newline_semantics,preview_agreement deterministic_regression root_swiftpm fast 2 CRLF increments the bounded scalar count twice, produces the same Foundation preview line count, and collapses consistently at the ten-line boundary. Character iteration could coalesce CRLF and make collapse eligibility disagree with preview and remaining-line counts. 0.000000 test_case retain 0 Corrective coverage for PR #584; explicitly preserves the established scalar-separator contract.
root/RepoPromptTests.AgentAssistantLineDerivationTests/testCombiningAndEmojiGraphemesDoNotCreateLines root Tests/RepoPromptTests/AgentMode/AgentAssistantLineDerivationTests.swift RepoPromptTests.AgentAssistantLineDerivationTests testCombiningAndEmojiGraphemesDoNotCreateLines AgentMode agent_mode.assistant_line_derivation.non_newline_graphemes combining_grapheme,emoji_zwj,newline_semantics deterministic_regression root_swiftpm fast 2 Combining and emoji ZWJ graphemes remain one exact line and pass through preview derivation unchanged. A grapheme-oriented optimization could misclassify complex non-newline text or change the owning scalar contract. 0.000000 test_case retain 0 Corrective coverage for PR #584 without a timing-sensitive CI benchmark.
root/RepoPromptTests.AgentAssistantLineDerivationTests/testEmptyAndTrailingSeparatorInputs root Tests/RepoPromptTests/AgentMode/AgentAssistantLineDerivationTests.swift RepoPromptTests.AgentAssistantLineDerivationTests testEmptyAndTrailingSeparatorInputs AgentMode agent_mode.assistant_line_derivation.empty_trailing_contract empty_input,trailing_separator,crlf,newline_semantics boundary_contract root_swiftpm fast 9 Empty text remains one line; every trailing Foundation newline scalar retains an empty final component, with CRLF contributing two components. An optimized scanner could drop trailing empty lines or change empty-input and CRLF preview behavior. 0.000000 test_case retain 0 Corrective coverage for PR #584 across the complete trailing-separator matrix.
root/RepoPromptTests.AgentAssistantLineDerivationTests/testLimitBoundariesReportExactnessAndMatchPreviewDecision root Tests/RepoPromptTests/AgentMode/AgentAssistantLineDerivationTests.swift RepoPromptTests.AgentAssistantLineDerivationTests testLimitBoundariesReportExactnessAndMatchPreviewDecision AgentMode agent_mode.assistant_line_derivation.limit_exactness limit_zero,limit_boundary,is_exact,preview_agreement boundary_contract root_swiftpm fast 6 Limits 0, 9, 10, and 11 return the exact bounded sentinel and isExact state while matching the preview collapse decision at and above each boundary. Early exit could return the wrong sentinel or exactness and suppress or spuriously trigger assistant collapse. 0.000000 test_case retain 0 Corrective boundary coverage for PR #584.
root/RepoPromptTests.AgentAssistantLineDerivationTests/testRecognizesEveryFoundationNewlineScalar root Tests/RepoPromptTests/AgentMode/AgentAssistantLineDerivationTests.swift RepoPromptTests.AgentAssistantLineDerivationTests testRecognizesEveryFoundationNewlineScalar AgentMode agent_mode.assistant_line_derivation.newline_scalar_membership lf,cr,vt,ff,nel,line_separator,paragraph_separator contract_matrix root_swiftpm fast 7 LF, CR, VT, FF, NEL, U+2028, and U+2029 each increment the exact bounded count once and normalize to LF in preview text. A native-property substitution could narrow or otherwise change the established Foundation newline scalar membership. 0.000000 test_case retain 0 Corrective membership coverage for PR #584.
root/RepoPromptTests.AgentTranscriptAssistantPreviewTests/testTerminalResponseDoesNotCrossTrailingNonAssistantBoundary root Tests/RepoPromptTests/AgentMode/Transcript/AgentTranscriptAssistantPreviewTests.swift RepoPromptTests.AgentTranscriptAssistantPreviewTests testTerminalResponseDoesNotCrossTrailingNonAssistantBoundary AgentMode agent_mode.transcript.terminal_assistant_preview assistant_tail,tool_boundary,response_span lifecycle_regression root_swiftpm routine 1 Terminal response preview joins only the asserted trailing assistant fragments and respects non-assistant/tool boundaries. Terminal conclusions could lose assistant tails or cross a tool boundary and misrepresent the final response. 0.000000 test_case retain 0 Authoritative test-list reconciliation for the current integration worktree.
root/RepoPromptTests.AgentTranscriptAssistantPreviewTests/testTerminalResponseJoinsFragmentsAcrossResponseSpans root Tests/RepoPromptTests/AgentMode/Transcript/AgentTranscriptAssistantPreviewTests.swift RepoPromptTests.AgentTranscriptAssistantPreviewTests testTerminalResponseJoinsFragmentsAcrossResponseSpans AgentMode agent_mode.transcript.terminal_assistant_preview assistant_tail,tool_boundary,response_span lifecycle_regression root_swiftpm routine 1 Terminal response preview joins only the asserted trailing assistant fragments and respects non-assistant/tool boundaries. Terminal conclusions could lose assistant tails or cross a tool boundary and misrepresent the final response. 0.000000 test_case retain 0 Authoritative test-list reconciliation for the current integration worktree.
root/RepoPromptTests.AgentTranscriptAssistantPreviewTests/testTerminalResponseJoinsTrailingFragmentsAndPreservesFullDetailRows root Tests/RepoPromptTests/AgentMode/Transcript/AgentTranscriptAssistantPreviewTests.swift RepoPromptTests.AgentTranscriptAssistantPreviewTests testTerminalResponseJoinsTrailingFragmentsAndPreservesFullDetailRows AgentMode agent_mode.transcript.terminal_assistant_preview assistant_tail,tool_boundary,response_span lifecycle_regression root_swiftpm routine 1 Terminal response preview joins only the asserted trailing assistant fragments and respects non-assistant/tool boundaries. Terminal conclusions could lose assistant tails or cross a tool boundary and misrepresent the final response. 0.000000 test_case retain 0 Authoritative test-list reconciliation for the current integration worktree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,8 @@ enum AgentAssistantLineDerivation {
return (count, false)
}

for char in text where char.isNewline {
let newlineScalars = CharacterSet.newlines
for scalar in text.unicodeScalars where newlineScalars.contains(scalar) {
count += 1
if count > limit {
return (count, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import Foundation
@testable import RepoPromptApp
import XCTest

final class AgentAssistantLineDerivationTests: XCTestCase {
func testRecognizesEveryFoundationNewlineScalar() {
let separators: [(name: String, scalar: Unicode.Scalar)] = [
("LF", "\n"),
("CR", "\r"),
("VT", "\u{000B}"),
("FF", "\u{000C}"),
("NEL", "\u{0085}"),
("line separator", "\u{2028}"),
("paragraph separator", "\u{2029}")
]

for separator in separators {
let text = "before\(String(separator.scalar))after"
let bounded = AgentAssistantLineDerivation.lineCount(upTo: 10, in: text)
let preview = AgentAssistantLineDerivation.previewSummary(
for: text,
previewLineCount: 10
)

XCTAssertEqual(bounded.count, 2, separator.name)
XCTAssertTrue(bounded.isExact, separator.name)
XCTAssertEqual(preview.lineCount, 2, separator.name)
XCTAssertEqual(preview.previewText, "before\nafter", separator.name)
XCTAssertFalse(preview.needsCollapse, separator.name)
}
}

func testCRLFCountsAsTwoScalarSeparatorsAndMatchesPreview() {
let shortText = "before\r\nafter"
let shortCount = AgentAssistantLineDerivation.lineCount(upTo: 10, in: shortText)
let shortPreview = AgentAssistantLineDerivation.previewSummary(
for: shortText,
previewLineCount: 10
)

XCTAssertEqual(shortCount.count, 3, "CRLF must increment once for CR and once for LF")
XCTAssertTrue(shortCount.isExact)
XCTAssertEqual(shortPreview.lineCount, shortCount.count)
XCTAssertEqual(shortPreview.previewText, "before\n\nafter")
XCTAssertFalse(shortPreview.needsCollapse)

let lineLimit = 10
let boundaryText = String(repeating: "line\n", count: 8) + "line\r\nfinal"
let boundaryCount = AgentAssistantLineDerivation.lineCount(upTo: lineLimit, in: boundaryText)
let boundaryPreview = AgentAssistantLineDerivation.previewSummary(
for: boundaryText,
previewLineCount: lineLimit
)

XCTAssertEqual(boundaryCount.count, 11)
XCTAssertFalse(boundaryCount.isExact)
XCTAssertEqual(boundaryPreview.lineCount, boundaryCount.count)
XCTAssertTrue(boundaryPreview.needsCollapse)
XCTAssertEqual(!boundaryCount.isExact || boundaryCount.count > lineLimit, boundaryPreview.needsCollapse)
}

func testEmptyAndTrailingSeparatorInputs() {
let cases: [(name: String, text: String, count: Int, preview: String)] = [
("empty", "", 1, ""),
("trailing LF", "value\n", 2, "value\n"),
("trailing CR", "value\r", 2, "value\n"),
("trailing VT", "value\u{000B}", 2, "value\n"),
("trailing FF", "value\u{000C}", 2, "value\n"),
("trailing NEL", "value\u{0085}", 2, "value\n"),
("trailing line separator", "value\u{2028}", 2, "value\n"),
("trailing paragraph separator", "value\u{2029}", 2, "value\n"),
("trailing CRLF", "value\r\n", 3, "value\n\n")
]

for testCase in cases {
let bounded = AgentAssistantLineDerivation.lineCount(upTo: 10, in: testCase.text)
let preview = AgentAssistantLineDerivation.previewSummary(
for: testCase.text,
previewLineCount: 10
)

XCTAssertEqual(bounded.count, testCase.count, testCase.name)
XCTAssertTrue(bounded.isExact, testCase.name)
XCTAssertEqual(preview.lineCount, testCase.count, testCase.name)
XCTAssertEqual(preview.previewText, testCase.preview, testCase.name)
XCTAssertFalse(preview.needsCollapse, testCase.name)
}
}

func testCombiningAndEmojiGraphemesDoNotCreateLines() {
let cases: [(name: String, text: String)] = [
("combining grapheme", "e\u{0301}"),
("emoji ZWJ grapheme", "👩🏽‍💻")
]

for testCase in cases {
let bounded = AgentAssistantLineDerivation.lineCount(upTo: 10, in: testCase.text)
let preview = AgentAssistantLineDerivation.previewSummary(
for: testCase.text,
previewLineCount: 10
)

XCTAssertEqual(bounded.count, 1, testCase.name)
XCTAssertTrue(bounded.isExact, testCase.name)
XCTAssertEqual(preview.lineCount, 1, testCase.name)
XCTAssertEqual(preview.previewText, testCase.text, testCase.name)
XCTAssertFalse(preview.needsCollapse, testCase.name)
}
}

func testLimitBoundariesReportExactnessAndMatchPreviewDecision() {
let cases: [(limit: Int, lineCount: Int, expectedCount: Int, isExact: Bool)] = [
(0, 11, 1, false),
(9, 9, 9, true),
(9, 10, 10, false),
(10, 10, 10, true),
(10, 11, 11, false),
(11, 11, 11, true)
]

for testCase in cases {
let text = Array(repeating: "line", count: testCase.lineCount).joined(separator: "\n")
let bounded = AgentAssistantLineDerivation.lineCount(upTo: testCase.limit, in: text)
let preview = AgentAssistantLineDerivation.previewSummary(
for: text,
previewLineCount: testCase.limit
)
let message = "limit=\(testCase.limit), lines=\(testCase.lineCount)"

XCTAssertEqual(bounded.count, testCase.expectedCount, message)
XCTAssertEqual(bounded.isExact, testCase.isExact, message)
XCTAssertEqual(!bounded.isExact || bounded.count > testCase.limit, preview.needsCollapse, message)
}
}
}
Loading