File size: 1,592 Bytes
105e2f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Sol-specific policy authored from the Sol discovery baseline.
// TARGET: exact_content_or_scope_mismatch

import { customPolicies, allow, instruct } from "failproofai";
import { load, save, promptOf, shouldNudge } from "../_lib/state.mjs";
import { profileNudgeLimit } from "../_lib/profile.mjs";

const RESTRICTED = /\b(only (?:edit|change|modify)|do not (?:edit|change|modify|touch|delete)|not (?:delete|modify|change|touch)|must not|leave .*unchanged|exact(?:ly)?|identical|byte-for-byte|preserve|no other files|without changing|be careful|consistent across|should not read|may not|must be)\b/i;

customPolicies.add({
  name: "sol-scope-track",
  match: { events: ["UserPromptSubmit"] },
  fn: async (ctx) => {
    const s = load(ctx);
    if (RESTRICTED.test(promptOf(ctx))) s.solExactScope = true;
    save(ctx, s);
    return allow();
  },
});

customPolicies.add({
  name: "sol-exact-diff",
  match: { events: ["Stop"] },
  fn: async (ctx) => {
    const s = load(ctx);
    if (!s.solExactScope || !shouldNudge(s, "sol-scope", profileNudgeLimit("scope", 1))) return allow();
    save(ctx, s);
    return instruct(
      `Perform an exact final diff audit. Account for every changed byte against the allowed transformation, ` +
      `including indentation, key ordering, spaces, quoting, and the trailing newline. Verify protected content ` +
      `is byte-identical and that only permitted files changed. Semantic equivalence or valid parsing is not ` +
      `enough when the task specifies exact content or restricted scope. Revert every unlicensed difference.`
    );
  },
});