Skip to content

Commit cd4b31d

Browse files
committed
refactor(workflow-code): simplify pass over the audit changes
Check STRICT_FINDINGS keys against DiagnosticCode, inline the column-call head regex, drop a TSDoc left on baseOf by the changedFields move, and drop the wall-clock diff-filter test that source-status.test.ts (linear pathFilter) and the repeated-./ kinds test already cover.
1 parent 36ff416 commit cd4b31d

4 files changed

Lines changed: 4 additions & 16 deletions

File tree

‎apps/sim/lib/workspace-source/application/kinds/mcp/adapter.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ function serverIdOf(ctx: SourceContext, url: string): string {
122122
return generateMcpServerId(ctx.workspace.workspaceId, url)
123123
}
124124

125-
/** The top-level declaration fields whose canonical values differ. */
126125
function baseOf(record: StoredServer): BaseResource {
127126
return { id: record.id, fingerprint: storedFingerprint(record.state) }
128127
}

‎packages/sim-cli/src/commands/protocol/source-strict.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* names is broken. One table, so `check --help` and the directory guides name the same findings.
44
*/
55

6+
import type { DiagnosticCode } from '@sim/workflow-code/diagnostics/codes'
7+
68
/** Each strict warning code with what it finds, as the guides phrase it. */
79
export const STRICT_FINDINGS: ReadonlyMap<string, string> = new Map([
810
['W_REQUIRED_MISSING', 'a missing required field'],
@@ -18,7 +20,7 @@ export const STRICT_FINDINGS: ReadonlyMap<string, string> = new Map([
1820
['W_UNRESOLVED_REF', 'a reference that names nothing'],
1921
['W_REF_OUT_OF_SCOPE', 'an iteration field read outside its loop or parallel'],
2022
['W_LOOP_CONDITION_SYNTAX', 'a loop condition that is not a JavaScript expression'],
21-
])
23+
] satisfies Array<[DiagnosticCode, string]>)
2224

2325
const phrases = [...STRICT_FINDINGS.values()]
2426

‎packages/sim-cli/src/commands/protocol/workspace-source-dir.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,13 @@ function tableRowFindings(key: string, decl: TableDecl, text: string | undefined
425425
/** A table declaration as the codec reads it, with its findings. */
426426
type ParsedTable = ReturnType<ReturnType<typeof createTableCodec>['parse']>
427427

428-
/** The head of a column helper call: `column.select(`. */
429-
const COLUMN_CALL_HEAD = /\bcolumn\.(\w+)\s*\(/g
430-
431428
/**
432429
* Each column helper call in `source` with its arguments' text up to the first `)`:
433430
* `column.select({ options: [...] })`. The next call is looked for after that `)`, and the walk
434431
* stops at the first call no `)` follows, so a file of unclosed calls is read once.
435432
*/
436433
function* columnCalls(source: string): Generator<[type: string, args: string]> {
437-
const head = new RegExp(COLUMN_CALL_HEAD)
434+
const head = /\bcolumn\.(\w+)\s*\(/g
438435
for (let match = head.exec(source); match !== null; match = head.exec(source)) {
439436
const open = match.index + match[0].length
440437
const close = source.indexOf(')', open)

‎packages/sim-cli/src/commands/protocol/workspace-source-status.test.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -843,16 +843,6 @@ describe('workspaces source diff', () => {
843843
expect(mockRequest.mock.calls[0][1]).toMatchObject({ query: { kinds: 'table' } })
844844
})
845845

846-
it('reads a filter with a long run of slashes before its last segment in linear time', async () => {
847-
mockRequest.mockResolvedValue(served({ 'tables/leads.ts': LEADS }))
848-
const started = Date.now()
849-
850-
await expect(run('diff', '--server', `tables${'/'.repeat(100_000)}leads.ts`)).rejects.toThrow(
851-
'selects no file'
852-
)
853-
expect(Date.now() - started).toBeLessThan(2_000)
854-
})
855-
856846
it('reports a binary file by its sizes', async () => {
857847
const sha256 = createHash('sha256').update(NOTES).digest('hex')
858848
write('files/notes.bin', Buffer.concat([NOTES, Buffer.from(' and two')]))

0 commit comments

Comments
 (0)