Skip to content

Commit db10ffa

Browse files
icecrasher321claude
andcommitted
test(provenance): restore two tests that the length floor had hollowed out
Greptile caught the byte-limit test: lengthening the catalog fixture without the `recordResolved` value beside it left them mismatched, so the registry latched and `projectResolvedSecretModelJsonContent` returned `{ safe: false }` at its completeness guard — before any alias projection. The test passed while covering nothing it is named for. It now records the same literal it catalogs, sizes the limit between the raw bytes and the projected bytes, and asserts both directions so a limit applied to the wrong side fails it. Auditing every changed test for the same shape — a `recordResolved` value that does not match its own catalog entry — found one more, pre-dating this branch: the legacy-memory test drew its teeth from substituting the one-character secret `x` inside `Box`, which the floor no longer substitutes, so it too had become vacuous. Its fixture is now a full-length secret that appears in the message, which is what makes "not projected" meaningful. The three remaining mismatches are deliberate: those tests are about a resolution that fails to verify. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent eeb1001 commit db10ffa

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

apps/sim/executor/handlers/agent/memory.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,11 @@ describe('Memory', () => {
465465

466466
it('does not project unrelated active secrets into legacy memory', async () => {
467467
const registry = new ResolvedSecretTraceRegistry([
468-
{ name: 'TOKEN', plaintext: 'x', encryptedValue: 'ciphertext' },
468+
{ name: 'TOKEN', plaintext: 'unrelated-secret', encryptedValue: 'ciphertext' },
469469
])
470-
registry.recordResolved('TOKEN', 'x')
470+
expect(registry.recordResolved('TOKEN', 'unrelated-secret')).toBe(true)
471471
vi.spyOn(memoryService as any, 'fetchMemory').mockResolvedValueOnce({
472-
messages: [{ role: 'assistant', content: 'Box' }],
472+
messages: [{ role: 'assistant', content: 'Box unrelated-secret' }],
473473
provenance: { status: 'exact', entries: [] },
474474
})
475475

@@ -478,7 +478,7 @@ describe('Memory', () => {
478478
inputs
479479
)
480480

481-
expect(messages).toEqual([{ role: 'assistant', content: 'Box' }])
481+
expect(messages).toEqual([{ role: 'assistant', content: 'Box unrelated-secret' }])
482482
})
483483

484484
it('does not activate provenance from a message dropped by the selected window', async () => {

apps/sim/executor/utils/resolved-secret-content-projection.test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,22 @@ describe('projectResolvedSecretModelJsonContent', () => {
411411

412412
it('enforces the byte limit after secret aliases are projected', () => {
413413
const registry = new ResolvedSecretTraceRegistry([
414-
{ name: 'X', plaintext: 'xxxxxxxx', encryptedValue: 'ciphertext' },
414+
{ name: 'X_LONGER_NAME', plaintext: 'xxxxxxxx', encryptedValue: 'ciphertext' },
415415
])
416-
registry.recordResolved('X', 'x')
417-
418-
expect(projectResolvedSecretModelJsonContent({ a: 'x' }, registry, 9)).toEqual({ safe: false })
416+
expect(registry.recordResolved('X_LONGER_NAME', 'xxxxxxxx')).toBe(true)
417+
418+
/**
419+
* `{"a":"xxxxxxxx"}` is 16 bytes and fits; projecting it to
420+
* `{"a":"{{X_LONGER_NAME}}"}` takes it to 25. The limit has to be applied to the projected
421+
* bytes, so the first call must fail and the second must not.
422+
*/
423+
expect(projectResolvedSecretModelJsonContent({ a: 'xxxxxxxx' }, registry, 16)).toEqual({
424+
safe: false,
425+
})
426+
expect(projectResolvedSecretModelJsonContent({ a: 'xxxxxxxx' }, registry, 25)).toEqual({
427+
safe: true,
428+
value: { a: '{{X_LONGER_NAME}}' },
429+
})
419430
})
420431
})
421432

0 commit comments

Comments
 (0)