Files
ruflo/plugins/ruflo-loop-workers/tests/textsof.test.ts
ruv 1d1394aa53 fix(mods): live-check W5 — guards read key names and every field; trader gates the package's real order tools
Found by driving each plugin's mod live (/SHORT-mod status ran for all 19; status.json parsed, version 1) and probing the guards.

- 13 guards (jujutsu, knowledge-graph, loop-workers, market-data, metaharness, rag-memory, ruvector, ruvllm, rvf, security-audit, sparc,
  workflows, x-gateway): textsOf dropped the key name, so {"api_key": "abcdef1234567890abcdef"} was never an assignment; and one long
  field (a 40 KB base64 blob) used the whole 20 KB budget so a key in the next field was never read. Strings now lead with their key and
  each is charged at most 20 KB of a 100 KB budget.
- neural-trader: the live-order gate matched execute_trade only; the package's execute_multi_asset_trade and place_prediction_order_tool
  went through unconfirmed. Paper/simulated tools stay ungated.
- tsconfig.json for knowledge-graph, loop-workers, market-data, metaharness (the host writes it on load; jujutsu already commits it).
- Patch bump for the 14 plugins; smoke step 1 pins updated.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-04 19:11:10 -04:00

23 lines
818 B
TypeScript

import { describe, expect, test, tier } from 'claude-code/testing'
import { textsOf } from '../hooks/guard'
import { hasSecret } from '../hooks/screen'
tier('user')
const AWS = `AKIA${'IOSFODNN7EXAMPLE'}`
const BIG = 'QUJD'.repeat(10_000)
const found = (input: unknown) => textsOf(input).some(hasSecret)
describe('what the guard reads', () => {
test('a key name leads its string value, so an object-shaped assignment is caught', () => {
expect(found({ meta: { api_key: 'abcdef1234567890abcdef' } })).toBe(true)
expect(found({ meta: { maxTokens: 4096, name: 'refresh policy' } })).toBe(false)
})
test('a long field does not starve the fields after it', () => {
expect(found({ value: BIG, note: AWS })).toBe(true)
expect(found({ a: BIG, b: BIG, c: BIG, d: 'plain text' })).toBe(false)
})
})