/**
 * Guard test for the model-lookup safety wrapper that receipts and
 * the audit log depend on. The original bug this defends against:
 *
 *   Call sites used `getRuntimeMainLoopModel()` (a selector that
 *   requires a `{ permissionMode, mainLoopModel }` params object) as
 *   if it were a zero-arg accessor. The destructure blew up
 *   synchronously inside FileWriteTool/FileEditTool's receipt arg
 *   list, killing the Write tool mid-flight in v2.2.0.
 *
 * This test asserts the wrapper never throws — even when the
 * underlying state is uninitialized — so re-introducing a similar
 * misuse fails CI instead of shipping to users.
 */

import { describe, it, expect } from 'vitest'
import { safeGetMainLoopModel } from '../safeGetMainLoopModel.js'

describe('safeGetMainLoopModel', () => {
  it('never throws, even with no bootstrap state set', () => {
    expect(() => safeGetMainLoopModel()).not.toThrow()
  })

  it('returns either a string or undefined — never null, never an object', () => {
    const out = safeGetMainLoopModel()
    expect(out === undefined || typeof out === 'string').toBe(true)
  })
})
