mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
Third audit wave. The detector looked for production modules exporting three
or more symbols that no production file imports — only tests do. That shape is
the authoring gate's fourth question failing: a test needing a production seam
no caller needs belongs at the real boundary instead.
Most hits were detector false positives and were left alone; the scanner misses
re-export barrels and dynamic imports, so every module was re-verified with rg
before any edit. Where a private predicate's behavior was already covered
through the module's real entry point, the duplicate cases are gone and the
symbol is module-private again. Where it was NOT covered anywhere else, the test
stays — this audit removes tests, it does not author replacements.
Production code deleted where tests were its only callers: the superseded
`filesystem-directory-listing-limit` module, the unused
`format{Hourly,Daily,Adhoc}Version` helpers and their orphaned prerelease
identifiers, the dead `filterByAutomationListSearch*` family superseded by
`matchAutomationListSearchRowKeys`, and the dead
`getAiVaultResumeWorktreeTargetStatus` copy of the live workspace branch.
Also drops two call-shape source greps in `relay-sweep-schedule.test.ts` that
asserted `index.ts` spells `jitteredSweepIntervalMs(30_000)`; the jitter math
has a behavioral owner at the top of the same file. The structural census that
counts role-gated vs total `setInterval(` calls stays — an ungated sweep runs in
every cell, and nothing else can catch that.
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { MarkdownDocument } from './filesystem-entry-types'
|
|
import {
|
|
assertMarkdownDocumentsWithinLimit,
|
|
createMarkdownDocumentListingBudget,
|
|
MARKDOWN_DOCUMENT_LISTING_ERROR_CODE,
|
|
MarkdownDocumentListingCapacityError,
|
|
retainMarkdownDocument,
|
|
visitMarkdownDocumentListingEntry
|
|
} from './markdown-document-listing-limits'
|
|
|
|
function document(path: string): MarkdownDocument {
|
|
return {
|
|
filePath: `/repo/${path}`,
|
|
relativePath: path,
|
|
basename: path,
|
|
name: path
|
|
}
|
|
}
|
|
|
|
describe('Markdown document listing limits', () => {
|
|
it('rejects the first document beyond the count limit with a typed error', () => {
|
|
const budget = createMarkdownDocumentListingBudget({ maxDocuments: 2 })
|
|
retainMarkdownDocument(budget, document('one.md'))
|
|
retainMarkdownDocument(budget, document('two.md'))
|
|
|
|
expect(() => retainMarkdownDocument(budget, document('three.md'))).toThrow(
|
|
MarkdownDocumentListingCapacityError
|
|
)
|
|
expect(() => retainMarkdownDocument(budget, document('three.md'))).toThrow(
|
|
expect.objectContaining({ code: MARKDOWN_DOCUMENT_LISTING_ERROR_CODE })
|
|
)
|
|
})
|
|
|
|
it('rejects aggregate metadata, visited-entry, path, and depth overflow', () => {
|
|
expect(() =>
|
|
assertMarkdownDocumentsWithinLimit([document('a'.repeat(100))], {
|
|
maxMetadataBytes: 100
|
|
})
|
|
).toThrow(MarkdownDocumentListingCapacityError)
|
|
|
|
const visited = createMarkdownDocumentListingBudget({
|
|
maxVisitedEntries: 1,
|
|
maxPathBytes: 4,
|
|
maxDepth: 1
|
|
})
|
|
visitMarkdownDocumentListingEntry(visited, 'a', 1)
|
|
expect(() => visitMarkdownDocumentListingEntry(visited, 'b', 1)).toThrow(
|
|
MarkdownDocumentListingCapacityError
|
|
)
|
|
|
|
const path = createMarkdownDocumentListingBudget({ maxPathBytes: 4 })
|
|
expect(() => visitMarkdownDocumentListingEntry(path, 'ééé', 1)).toThrow(
|
|
MarkdownDocumentListingCapacityError
|
|
)
|
|
|
|
const depth = createMarkdownDocumentListingBudget({ maxDepth: 1 })
|
|
expect(() => visitMarkdownDocumentListingEntry(depth, 'a/b', 2)).toThrow(
|
|
MarkdownDocumentListingCapacityError
|
|
)
|
|
})
|
|
})
|