/**
 * "Improve this agent" — the ASI coverage entries must carry per-area
 * remediation (what's wrong + how to fix), so the portal can turn a scan into an
 * actionable improvement plan with concrete code/config to inject.
 *
 * Red → Green: before this, AsiCoverageEntry carried only counts/severity, so the
 * remediation strings the scanner already produces never reached the UI. Now each
 * entry exposes its findings' remediation text.
 */
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { scanAgent } from './owasp-agentic-scanner.js';
describe('ASI coverage carries remediation for the "Improve this agent" surface', () => {
    it('an agent with no governance hooks exposes hook-wiring remediation on an ASI entry', () => {
        const report = scanAgent({
            agentId: 'improve-test',
            name: 'no-hooks-bot',
            tools: ['shell_exec', 'network_request', 'file_write'],
            hooks: { preToolUse: false, postToolUse: false, postResponse: false },
            llmProvider: 'anthropic',
            killSwitchCapable: true,
        });
        const withRemediation = report.asiCoverage.filter((e) => e.remediations.length > 0);
        assert.ok(withRemediation.length > 0, 'at least one ASI area must carry remediation');
        // Every remediation entry must have the actionable fields.
        for (const e of withRemediation) {
            for (const r of e.remediations) {
                assert.equal(typeof r.title, 'string');
                assert.equal(typeof r.detail, 'string');
                assert.ok(r.remediation.length > 0, `remediation text present for ${e.asi}`);
            }
        }
        // The hook-wiring fix (the most common build-axis gap) must be discoverable.
        const all = withRemediation.flatMap((e) => e.remediations.map((r) => r.remediation.toLowerCase()));
        assert.ok(all.some((r) => r.includes('hook')), 'hook-wiring remediation must be present');
    });
    it('remediation count matches the per-area finding count', () => {
        const report = scanAgent({
            agentId: 'improve-test-2',
            name: 'bot',
            tools: ['Read'],
            hooks: { preToolUse: false, postToolUse: false, postResponse: false },
            llmProvider: 'anthropic',
            killSwitchCapable: true,
        });
        for (const e of report.asiCoverage) {
            assert.equal(e.remediations.length, e.findingCount, `ASI ${e.asi}: remediations should match findingCount`);
        }
    });
});
//# sourceMappingURL=asi-remediation-flow.test.js.map