Files
accounted/lib/agent/intents/__tests__/shared-rules.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

43 lines
2.0 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { renderAgentGroundRules, AGENT_GROUND_RULES } from '../shared-rules'
// AGENT_GROUND_RULES is rendered into the first user message of the bookkeeping
// intents that inject it (general.help, vat-review, invoice-draft,
// supplier_invoice.review, bokslut.step, verifikation.draft). It owns the
// bookkeeping-specific HEURISTICS: underlag-first, no BAS numbers in chat,
// counterparty history, representation, known-counterparty defaults.
//
// The cross-cutting EPISTEMICS rules (load before quoting a rate; don't infer
// the business from an SNI code) deliberately do NOT live here anymore. They
// live exactly once, in the always-on system prompt (buildIdentityBlock: see
// system-prompt.test.ts), which is re-sent every turn in the high-salience
// system position. This file guards both: that the heuristics stay, and that
// the epistemics are not re-duplicated back into the first user message.
const text = renderAgentGroundRules()
describe('agent ground rules: bookkeeping heuristics it owns', () => {
it('keeps underlag-first, no-BAS-in-chat, history, representation, known counterparties', () => {
expect(text).toContain('UNDERLAG FÖRST')
expect(text).toContain('INGA BAS-KONTONUMMER')
expect(text).toContain('KOLLA HISTORIK FÖRST')
expect(text).toContain('REPRESENTATION')
expect(text).toContain('KÄNDA MOTPARTER')
})
it('still renders as a non-trivial joined block', () => {
expect(AGENT_GROUND_RULES.length).toBeGreaterThan(10)
expect(text.split('\n').length).toBeGreaterThan(10)
})
})
describe('agent ground rules: epistemics live in the system prompt, not here', () => {
it('does not re-duplicate the always-on epistemics / anti-speculation rules', () => {
// These moved to buildIdentityBlock (always-on Block 2). Re-adding them here
// restores the triplication this cleanup removed.
expect(text).not.toContain('12 %→6 %')
expect(text).not.toContain('GISSA INTE BOLAGETS VERKSAMHET')
expect(text).not.toContain('är du säker?')
})
})