@fro.bot/systematic 3.18.7 → 3.18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  findCommandsInDir,
34
34
  findSkillsInDir,
35
35
  discoverSkills
36
- } from "./index-8wrkhjsx.js";
36
+ } from "./index-fpq5hwdt.js";
37
37
  var __defProp = Object.defineProperty;
38
38
  var __returnValue = (v) => v;
39
39
  function __exportSetter(name, newValue) {
@@ -2317,6 +2317,7 @@ var SynthesizedFindingFieldsSchema = object({
2317
2317
  suggested_fix: string().max(2048).nullable().optional(),
2318
2318
  validated: boolean().optional(),
2319
2319
  validation_reason: ReasonSchema.optional(),
2320
+ route_narrowing_reason: ReasonSchema.optional(),
2320
2321
  input_finding_ids: array(boundedText(MAX_INPUT_ID_LENGTH)).min(1).max(MAX_FINDINGS),
2321
2322
  provenance: ProvenanceSchema
2322
2323
  }).strict();
@@ -7874,7 +7874,7 @@ function createProfileBundleSchema(agentNames, qualifiedAgentIds) {
7874
7874
  name,
7875
7875
  ProfileOverlaySchema.optional()
7876
7876
  ]))).strict().optional().meta({
7877
- description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error, exactly like the top-level `agents` field.",
7877
+ description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
7878
7878
  examples: [
7879
7879
  { "correctness-reviewer": { model: "openai/gpt-6-astra" } }
7880
7880
  ]
@@ -7977,7 +7977,7 @@ function createSystematicConfigSchema(opts) {
7977
7977
  name,
7978
7978
  AgentOverlaySchema.optional()
7979
7979
  ]))).strict().default({}).meta({
7980
- description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
7980
+ description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config \u2014 a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
7981
7981
  examples: [
7982
7982
  { "correctness-reviewer": { temperature: 0.1 } },
7983
7983
  { "review/correctness-reviewer": { temperature: 0.1 } },
@@ -7985,7 +7985,7 @@ function createSystematicConfigSchema(opts) {
7985
7985
  ]
7986
7986
  }),
7987
7987
  categories: record(string(), CategoryOverlaySchema).default({}).meta({
7988
- description: "Per-category configuration overlays keyed by category name",
7988
+ description: "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config \u2014 a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
7989
7989
  examples: [{ review: { model: "anthropic/claude-opus-5" } }, {}]
7990
7990
  }),
7991
7991
  profiles: record(string(), createProfileBundleSchema(agentNames, qualifiedAgentIds)).default({}).meta({
@@ -8100,6 +8100,46 @@ var PROTECTED_OVERLAY_FIELD_PATHS = {
8100
8100
  }
8101
8101
  };
8102
8102
  var PROJECT_PROTECTED_FIELDS = new Set(["workflow_guard", "profiles"]);
8103
+ var MAX_DIAGNOSTIC_TEXT = 200;
8104
+ var MAX_STRIP_WARNINGS = 20;
8105
+ var DIAGNOSTIC_ELLIPSIS = "\u2026";
8106
+ function sanitizeDiagnosticText(input) {
8107
+ const budget = MAX_DIAGNOSTIC_TEXT - DIAGNOSTIC_ELLIPSIS.length;
8108
+ let rendered = "";
8109
+ let truncated = false;
8110
+ for (const char of input) {
8111
+ if (rendered.length >= budget) {
8112
+ truncated = true;
8113
+ break;
8114
+ }
8115
+ const code = char.codePointAt(0) ?? 0;
8116
+ const isControl = code <= 31 || code === 127 || code >= 128 && code <= 159 || code === 8232 || code === 8233;
8117
+ const piece = isControl ? `\\u${code.toString(16).padStart(4, "0")}` : char;
8118
+ if (rendered.length + piece.length > budget) {
8119
+ truncated = true;
8120
+ break;
8121
+ }
8122
+ rendered += piece;
8123
+ }
8124
+ return truncated ? `${rendered}${DIAGNOSTIC_ELLIPSIS}` : rendered;
8125
+ }
8126
+ function createBoundedStripWarningSink(warningSink) {
8127
+ let emitted = 0;
8128
+ let suppressed = 0;
8129
+ return {
8130
+ sink(message) {
8131
+ if (emitted < MAX_STRIP_WARNINGS) {
8132
+ emitted++;
8133
+ warningSink(message);
8134
+ } else {
8135
+ suppressed++;
8136
+ }
8137
+ },
8138
+ suppressedCount() {
8139
+ return suppressed;
8140
+ }
8141
+ };
8142
+ }
8103
8143
  var CURRENT_SKILL_NAMES_SET = new Set(BUNDLED_SKILL_NAMES);
8104
8144
  var CURRENT_AGENT_NAMES_SET = new Set([
8105
8145
  ...BUNDLED_AGENT_NAMES,
@@ -8252,7 +8292,7 @@ ${formatted.map((entry) => ` - ${entry}`).join(`
8252
8292
  issues
8253
8293
  });
8254
8294
  }
8255
- function loadConfigSource(filePath, trust, invalidSource) {
8295
+ function loadConfigSource(filePath, trust, invalidSource, warningSink) {
8256
8296
  try {
8257
8297
  const rawConfig = loadJsoncFile(filePath);
8258
8298
  if (!rawConfig) {
@@ -8262,7 +8302,8 @@ function loadConfigSource(filePath, trust, invalidSource) {
8262
8302
  };
8263
8303
  }
8264
8304
  const protectedFields = collectProjectProtectedFields(rawConfig, trust);
8265
- const config = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
8305
+ const topLevelStripped = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
8306
+ const config = trust === "project" ? stripProjectSecurityOverlayFields(topLevelStripped, filePath, warningSink) : topLevelStripped;
8266
8307
  const result = SystematicConfigSchema.safeParse(config);
8267
8308
  if (!result.success) {
8268
8309
  throwTopLevelConfigSchemaError(filePath, trust, result.error.issues, config);
@@ -8353,6 +8394,41 @@ function stripProjectProtectedFields(rawConfig) {
8353
8394
  }
8354
8395
  return config;
8355
8396
  }
8397
+ function stripProjectSecurityOverlayFields(rawConfig, filePath, warningSink) {
8398
+ const agents = stripSecurityOverlayEntries(rawConfig.agents, "agents", filePath, warningSink);
8399
+ const categories = stripSecurityOverlayEntries(rawConfig.categories, "categories", filePath, warningSink);
8400
+ if (agents === rawConfig.agents && categories === rawConfig.categories) {
8401
+ return rawConfig;
8402
+ }
8403
+ const result = { ...rawConfig };
8404
+ if (agents !== rawConfig.agents)
8405
+ result.agents = agents;
8406
+ if (categories !== rawConfig.categories)
8407
+ result.categories = categories;
8408
+ return result;
8409
+ }
8410
+ function stripSecurityOverlayEntries(overlayMap, mapKey, filePath, warningSink) {
8411
+ if (!isRecord2(overlayMap))
8412
+ return overlayMap;
8413
+ let changed = false;
8414
+ const result = {};
8415
+ for (const [key, value] of Object.entries(overlayMap)) {
8416
+ if (!isRecord2(value)) {
8417
+ result[key] = value;
8418
+ continue;
8419
+ }
8420
+ const stripped = stripProjectSecurityOverlay(filePath, `${mapKey}.${key}`, value, warningSink);
8421
+ if (stripped === value) {
8422
+ result[key] = stripped;
8423
+ continue;
8424
+ }
8425
+ changed = true;
8426
+ if (Object.keys(stripped).length === 0)
8427
+ continue;
8428
+ result[key] = stripped;
8429
+ }
8430
+ return changed ? result : overlayMap;
8431
+ }
8356
8432
  function isRecord2(value) {
8357
8433
  return typeof value === "object" && value !== null && !Array.isArray(value);
8358
8434
  }
@@ -8432,7 +8508,7 @@ function resolveActiveProfile(input) {
8432
8508
  const trustedDefault = trustedDefaultProfileName(input);
8433
8509
  const fallbackLookup = trustedDefault !== undefined && trustedDefault !== requested ? lookupProfileBundle(input, trustedDefault) : undefined;
8434
8510
  if (fallbackLookup !== undefined && trustedDefault !== undefined) {
8435
- input.warningSink(`[systematic] profile "${requested}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${trustedDefault}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
8511
+ input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${sanitizeDiagnosticText(trustedDefault)}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
8436
8512
  return {
8437
8513
  activeProfile: trustedDefault,
8438
8514
  profileSelectorSource: selection.source,
@@ -8442,8 +8518,8 @@ function resolveActiveProfile(input) {
8442
8518
  };
8443
8519
  }
8444
8520
  const sourceNote = selection.source === "user" ? "" : ` (selected by ${selection.source} config)`;
8445
- const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${trustedDefault}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
8446
- input.warningSink(`[systematic] profile "${requested}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
8521
+ const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${sanitizeDiagnosticText(trustedDefault)}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
8522
+ input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
8447
8523
  return {
8448
8524
  activeProfile: null,
8449
8525
  profileSelectorSource: selection.source,
@@ -8455,31 +8531,104 @@ function resolveActiveProfile(input) {
8455
8531
  function loadConfig(projectDir, options) {
8456
8532
  return loadConfigWithSources(projectDir, options).config;
8457
8533
  }
8534
+ function resolveAliasedCustomConfigPath(paths, includeProject) {
8535
+ if (!includeProject || paths.customConfig === undefined)
8536
+ return;
8537
+ const sameFile = resolveConfigSourcePath(paths.projectConfig) === resolveConfigSourcePath(paths.customConfig);
8538
+ return sameFile ? paths.customConfig : undefined;
8539
+ }
8540
+ function createAliasStripTracker(warningSink, aliasedCustomConfigPath) {
8541
+ if (aliasedCustomConfigPath === undefined) {
8542
+ return { sink: warningSink, buffered: [] };
8543
+ }
8544
+ const buffered = [];
8545
+ return {
8546
+ sink: (message) => {
8547
+ buffered.push(message);
8548
+ },
8549
+ buffered
8550
+ };
8551
+ }
8552
+ function isAliasNoticeEligible(input) {
8553
+ return input.aliasedCustomConfigPath !== undefined && (input.bufferedCount > 0 || input.hasProtectedFields);
8554
+ }
8555
+ function emitAliasFailureDiagnostics(input) {
8556
+ if (!isAliasNoticeEligible({
8557
+ aliasedCustomConfigPath: input.aliasedCustomConfigPath,
8558
+ bufferedCount: input.buffered.length,
8559
+ hasProtectedFields: input.hasProtectedFields
8560
+ })) {
8561
+ return;
8562
+ }
8563
+ if (input.projectLoaded && input.customLoaded)
8564
+ return;
8565
+ for (const message of input.buffered)
8566
+ input.warningSink(message);
8567
+ }
8568
+ function buildAliasSuccessNotice(input) {
8569
+ if (!isAliasNoticeEligible({
8570
+ aliasedCustomConfigPath: input.aliasedCustomConfigPath,
8571
+ bufferedCount: input.bufferedCount,
8572
+ hasProtectedFields: input.hasProtectedFields
8573
+ }) || !(input.projectLoaded && input.customLoaded) || input.aliasedCustomConfigPath === undefined) {
8574
+ return;
8575
+ }
8576
+ const aliasedCustomConfigPath = input.aliasedCustomConfigPath;
8577
+ const projectConfigPath = input.projectConfigPath;
8578
+ const warningSink = input.warningSink;
8579
+ return () => {
8580
+ warningSink(`[systematic] project config (${sanitizeDiagnosticText(projectConfigPath)}) and custom config (${sanitizeDiagnosticText(aliasedCustomConfigPath)}) resolve to the same file; protected fields stripped from the project pass (security-overlay fields, \`profiles\`, \`workflow_guard\`) apply through the custom-trust pass instead.`);
8581
+ };
8582
+ }
8458
8583
  function loadConfigWithSources(projectDir, options) {
8459
8584
  const includeProject = options?.includeProject ?? true;
8460
8585
  const invalidSource = options?.invalidSource ?? "throw";
8461
8586
  const paths = getConfigPaths(projectDir, options);
8462
8587
  const warningSink = options?.warningSink ?? console.warn;
8463
- const user = loadConfigSource(paths.userConfig, "user", invalidSource);
8464
- const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource) : {
8588
+ const aliasedCustomConfigPath = resolveAliasedCustomConfigPath(paths, includeProject);
8589
+ const projectStrip = createAliasStripTracker(warningSink, aliasedCustomConfigPath);
8590
+ const boundedProjectStrip = createBoundedStripWarningSink(projectStrip.sink);
8591
+ const user = loadConfigSource(paths.userConfig, "user", invalidSource, warningSink);
8592
+ const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource, boundedProjectStrip.sink) : {
8465
8593
  metadata: { kind: "project", presence: "absent" },
8466
8594
  source: null
8467
8595
  };
8468
- const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource) : {
8596
+ const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource, warningSink) : {
8469
8597
  metadata: { kind: "custom", presence: "absent" },
8470
8598
  source: null
8471
8599
  };
8472
8600
  const userSource = user.source;
8473
8601
  const projectSource = project.source;
8474
8602
  const customSource = custom.source;
8603
+ if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
8604
+ boundedProjectStrip.sink(`[systematic] \`profiles\` in project config (${sanitizeDiagnosticText(projectSource.path)}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`);
8605
+ }
8606
+ const suppressedStripCount = boundedProjectStrip.suppressedCount();
8607
+ if (suppressedStripCount > 0) {
8608
+ projectStrip.sink(`[systematic] ${suppressedStripCount} additional project-config protected-field warning(s) in (${sanitizeDiagnosticText(paths.projectConfig)}) were suppressed.`);
8609
+ }
8610
+ emitAliasFailureDiagnostics({
8611
+ aliasedCustomConfigPath,
8612
+ buffered: projectStrip.buffered,
8613
+ customLoaded: custom.source !== null,
8614
+ hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
8615
+ projectLoaded: project.source !== null,
8616
+ warningSink
8617
+ });
8618
+ const emitAliasSuccessNotice = buildAliasSuccessNotice({
8619
+ aliasedCustomConfigPath,
8620
+ bufferedCount: projectStrip.buffered.length,
8621
+ customLoaded: custom.source !== null,
8622
+ hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
8623
+ projectConfigPath: paths.projectConfig,
8624
+ projectLoaded: project.source !== null,
8625
+ warningSink
8626
+ });
8475
8627
  const sources = [userSource, projectSource, customSource].filter((source) => source !== null);
8476
8628
  const userConfig = userSource?.config;
8477
8629
  const projectConfig = projectSource?.config;
8478
8630
  const customConfig = customSource?.config;
8479
8631
  const warned = new Set;
8480
- if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
8481
- warningSink(`[systematic] \`profiles\` in project config (${projectSource.path}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`);
8482
- }
8483
8632
  assertAllProfileBundlesAreValid(userConfig, customConfig);
8484
8633
  const profileSelection = resolveActiveProfile({
8485
8634
  userConfig,
@@ -8551,6 +8700,7 @@ function loadConfigWithSources(projectDir, options) {
8551
8700
  disabled_skills: result.disabled_skills.filter((n) => !droppedSkillSet.has(n)),
8552
8701
  disabled_agents: result.disabled_agents.filter((n) => !droppedAgentSet.has(n))
8553
8702
  };
8703
+ emitAliasSuccessNotice?.();
8554
8704
  return {
8555
8705
  config: effectiveConfig,
8556
8706
  metadata: buildConfigObservationMetadata({
@@ -8593,7 +8743,7 @@ function buildConfigObservationMetadata(summary) {
8593
8743
  if (authority)
8594
8744
  authorities.push(authority);
8595
8745
  }
8596
- const protectedFields = summary.sources.flatMap((source) => source.protectedFields);
8746
+ const protectedFields = collectVisibleProtectedFields(summary.sources);
8597
8747
  const sources = dedupeSourceMetadata([summary.custom, summary.project, summary.user], sourcePaths);
8598
8748
  return {
8599
8749
  authorities: sortAuthorities(authorities),
@@ -8604,6 +8754,12 @@ function buildConfigObservationMetadata(summary) {
8604
8754
  profileFallback: summary.profileSelection.profileFallback
8605
8755
  };
8606
8756
  }
8757
+ function collectVisibleProtectedFields(sources) {
8758
+ const projectSource = sources.find((source) => source.trust === "project");
8759
+ const customSource = sources.find((source) => source.trust === "custom");
8760
+ const projectAppliedViaCustom = projectSource !== undefined && customSource !== undefined && projectSource.canonicalPath === customSource.canonicalPath;
8761
+ return sources.flatMap((source) => projectAppliedViaCustom && source.trust === "project" ? [] : source.protectedFields);
8762
+ }
8607
8763
  function dedupeSourceMetadata(metadata, sourcePaths) {
8608
8764
  const seen = new Set;
8609
8765
  return metadata.filter((source) => {
@@ -8719,9 +8875,6 @@ function mergeOverlayMap(target, source, mapKey) {
8719
8875
  if (!isRecord2(value)) {
8720
8876
  throwInvalidOverlay(source.path, keyPath);
8721
8877
  }
8722
- if (source.kind === "file" && source.trust === "project") {
8723
- rejectProjectSecurityOverlay(source.path, keyPath, value);
8724
- }
8725
8878
  const previous = target[key];
8726
8879
  const nextValue = resolveOverlayEntryValue(previous?.value, value, source);
8727
8880
  target[key] = {
@@ -8741,12 +8894,18 @@ function resolveOverlayEntryValue(previous, next, source) {
8741
8894
  return preserveSecurityFields(previous, next);
8742
8895
  return next;
8743
8896
  }
8744
- function rejectProjectSecurityOverlay(sourcePath, keyPath, value) {
8897
+ function stripProjectSecurityOverlay(sourcePath, keyPath, value, warningSink) {
8898
+ const safeKeyPath = sanitizeDiagnosticText(keyPath);
8899
+ const safeSourcePath = sanitizeDiagnosticText(sourcePath);
8900
+ let stripped;
8745
8901
  for (const field of SECURITY_OVERLAY_FIELDS) {
8746
8902
  if (Object.hasOwn(value, field)) {
8747
- throw new Error(`Invalid Systematic config in ${sourcePath}: ${keyPath}.${field} is only valid in user config or OPENCODE_CONFIG_DIR config`);
8903
+ stripped ??= { ...value };
8904
+ delete stripped[field];
8905
+ warningSink(`[systematic] \`${safeKeyPath}.${field}\` in project config (${safeSourcePath}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`);
8748
8906
  }
8749
8907
  }
8908
+ return stripped ?? value;
8750
8909
  }
8751
8910
  function preserveSecurityFields(previous, next) {
8752
8911
  const result = { ...next };
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  extractCommandFrontmatter,
20
20
  findSkillsInDir,
21
21
  discoverSkills
22
- } from "./index-8wrkhjsx.js";
22
+ } from "./index-fpq5hwdt.js";
23
23
 
24
24
  // src/index.ts
25
25
  import { createHash as createHash4 } from "crypto";
@@ -104,6 +104,7 @@ declare const SynthesizedFindingFieldsSchema: z.ZodObject<{
104
104
  suggested_fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
105
  validated: z.ZodOptional<z.ZodBoolean>;
106
106
  validation_reason: z.ZodOptional<z.ZodString>;
107
+ route_narrowing_reason: z.ZodOptional<z.ZodString>;
107
108
  input_finding_ids: z.ZodArray<z.ZodString>;
108
109
  provenance: z.ZodObject<{
109
110
  fingerprint: z.ZodString;
@@ -208,6 +209,7 @@ export declare const ReviewArtifactSchema: z.ZodObject<{
208
209
  suggested_fix?: string | null | undefined;
209
210
  validated?: boolean | undefined;
210
211
  validation_reason?: string | undefined;
212
+ route_narrowing_reason?: string | undefined;
211
213
  input_finding_ids: string[];
212
214
  provenance: {
213
215
  fingerprint: string;
@@ -232,6 +234,7 @@ export declare const ReviewArtifactSchema: z.ZodObject<{
232
234
  suggested_fix?: string | null | undefined;
233
235
  validated?: boolean | undefined;
234
236
  validation_reason?: string | undefined;
237
+ route_narrowing_reason?: string | undefined;
235
238
  input_finding_ids: string[];
236
239
  provenance: {
237
240
  fingerprint: string;
@@ -526,6 +526,7 @@ export declare const MergeOutputSchema: z.ZodObject<{
526
526
  pre_existing: z.ZodBoolean;
527
527
  fingerprint: z.ZodString;
528
528
  submitters: z.ZodArray<z.ZodString>;
529
+ route_narrowing_reason: z.ZodOptional<z.ZodString>;
529
530
  }, z.core.$strict>>;
530
531
  validator_requests: z.ZodArray<z.ZodObject<{
531
532
  finding_id: z.ZodString;
@@ -651,6 +652,7 @@ export declare const FinalizeInputSchema: z.ZodObject<{
651
652
  pre_existing: z.ZodBoolean;
652
653
  fingerprint: z.ZodString;
653
654
  submitters: z.ZodArray<z.ZodString>;
655
+ route_narrowing_reason: z.ZodOptional<z.ZodString>;
654
656
  }, z.core.$strict>>;
655
657
  validator_requests: z.ZodArray<z.ZodObject<{
656
658
  finding_id: z.ZodString;
@@ -966,6 +968,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
966
968
  suggested_fix?: string | null | undefined;
967
969
  validated?: boolean | undefined;
968
970
  validation_reason?: string | undefined;
971
+ route_narrowing_reason?: string | undefined;
969
972
  input_finding_ids: string[];
970
973
  provenance: {
971
974
  fingerprint: string;
@@ -996,6 +999,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
996
999
  suggested_fix?: string | null | undefined;
997
1000
  validated?: boolean | undefined;
998
1001
  validation_reason?: string | undefined;
1002
+ route_narrowing_reason?: string | undefined;
999
1003
  input_finding_ids: string[];
1000
1004
  provenance: {
1001
1005
  fingerprint: string;
@@ -1020,6 +1024,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1020
1024
  suggested_fix?: string | null | undefined;
1021
1025
  validated?: boolean | undefined;
1022
1026
  validation_reason?: string | undefined;
1027
+ route_narrowing_reason?: string | undefined;
1023
1028
  input_finding_ids: string[];
1024
1029
  provenance: {
1025
1030
  fingerprint: string;
@@ -1050,6 +1055,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1050
1055
  suggested_fix?: string | null | undefined;
1051
1056
  validated?: boolean | undefined;
1052
1057
  validation_reason?: string | undefined;
1058
+ route_narrowing_reason?: string | undefined;
1053
1059
  input_finding_ids: string[];
1054
1060
  provenance: {
1055
1061
  fingerprint: string;
@@ -1122,6 +1128,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1122
1128
  suggested_fix?: string | null | undefined;
1123
1129
  validated?: boolean | undefined;
1124
1130
  validation_reason?: string | undefined;
1131
+ route_narrowing_reason?: string | undefined;
1125
1132
  input_finding_ids: string[];
1126
1133
  provenance: {
1127
1134
  fingerprint: string;
@@ -1152,6 +1159,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1152
1159
  suggested_fix?: string | null | undefined;
1153
1160
  validated?: boolean | undefined;
1154
1161
  validation_reason?: string | undefined;
1162
+ route_narrowing_reason?: string | undefined;
1155
1163
  input_finding_ids: string[];
1156
1164
  provenance: {
1157
1165
  fingerprint: string;
@@ -1176,6 +1184,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1176
1184
  suggested_fix?: string | null | undefined;
1177
1185
  validated?: boolean | undefined;
1178
1186
  validation_reason?: string | undefined;
1187
+ route_narrowing_reason?: string | undefined;
1179
1188
  input_finding_ids: string[];
1180
1189
  provenance: {
1181
1190
  fingerprint: string;
@@ -1206,6 +1215,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1206
1215
  suggested_fix?: string | null | undefined;
1207
1216
  validated?: boolean | undefined;
1208
1217
  validation_reason?: string | undefined;
1218
+ route_narrowing_reason?: string | undefined;
1209
1219
  input_finding_ids: string[];
1210
1220
  provenance: {
1211
1221
  fingerprint: string;
@@ -1292,6 +1302,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1292
1302
  suggested_fix?: string | null | undefined;
1293
1303
  validated?: boolean | undefined;
1294
1304
  validation_reason?: string | undefined;
1305
+ route_narrowing_reason?: string | undefined;
1295
1306
  input_finding_ids: string[];
1296
1307
  provenance: {
1297
1308
  fingerprint: string;
@@ -1322,6 +1333,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1322
1333
  suggested_fix?: string | null | undefined;
1323
1334
  validated?: boolean | undefined;
1324
1335
  validation_reason?: string | undefined;
1336
+ route_narrowing_reason?: string | undefined;
1325
1337
  input_finding_ids: string[];
1326
1338
  provenance: {
1327
1339
  fingerprint: string;
@@ -1346,6 +1358,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1346
1358
  suggested_fix?: string | null | undefined;
1347
1359
  validated?: boolean | undefined;
1348
1360
  validation_reason?: string | undefined;
1361
+ route_narrowing_reason?: string | undefined;
1349
1362
  input_finding_ids: string[];
1350
1363
  provenance: {
1351
1364
  fingerprint: string;
@@ -1376,6 +1389,7 @@ export declare const FinalizeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1376
1389
  suggested_fix?: string | null | undefined;
1377
1390
  validated?: boolean | undefined;
1378
1391
  validation_reason?: string | undefined;
1392
+ route_narrowing_reason?: string | undefined;
1379
1393
  input_finding_ids: string[];
1380
1394
  provenance: {
1381
1395
  fingerprint: string;
@@ -170,6 +170,12 @@ export interface DerivedMergedFindingFields {
170
170
  readonly pre_existing: boolean;
171
171
  readonly fingerprint: string;
172
172
  readonly route: PipelineRoute;
173
+ /** Whether `route` actually differs from the route meet computed over
174
+ * `contributing` -- true only for a genuine narrowing, never merely
175
+ * because the model supplied a `proposed_route`. Assembly uses this,
176
+ * rather than presence of a proposal, to decide whether
177
+ * `route_narrowing_reason` belongs on the wire. */
178
+ readonly route_differs_from_meet: boolean;
173
179
  }
174
180
  type MergedFindingRejectReason = 'route widening' | 'route narrowing missing reason' | 'duplicate agreement credit reviewer' | 'agreement credit reviewer already a submitter' | 'agreement credit reviewer did not return';
175
181
  /** One bounded, payload-safe rejection diagnostic: a fixed reason code and a
@@ -320,7 +326,7 @@ export interface FinalizeContext {
320
326
  readonly rejected_payloads: readonly RejectedPayloadWeight[];
321
327
  readonly lost_risk_critical_personas: readonly LostRiskCriticalPersona[];
322
328
  }
323
- type FinalizeContextRejectReason = 'duplicate merged finding ID' | 'merged finding references unknown survivor' | 'survivor missing from merge inputs' | 'survivor claimed by multiple merged findings' | 'validator request references unknown merged finding' | 'dispatch record mismatch' | 'duplicate selection surface entry' | 'screen result missing for selected persona' | 'unexpected screen result for persona' | 'screen result outcome does not match dispatch record' | 'merged finding fields diverge from derivation' | 'confidence disposition references unscreened finding' | 'merged finding cites input from unavailable reviewer' | 'merged finding submitter not a cited reviewer' | 'merged finding agreement credit overlaps submitters' | 'surviving finding diverges from its screened finding' | 'surviving finding references unscreened input' | 'duplicate confidence disposition' | 'validation must be not_attempted at finalize';
329
+ type FinalizeContextRejectReason = 'duplicate merged finding ID' | 'merged finding references unknown survivor' | 'survivor missing from merge inputs' | 'survivor claimed by multiple merged findings' | 'validator request references unknown merged finding' | 'dispatch record mismatch' | 'duplicate selection surface entry' | 'screen result missing for selected persona' | 'unexpected screen result for persona' | 'screen result outcome does not match dispatch record' | 'merged finding fields diverge from derivation' | 'merged finding route narrowing reason mismatch' | 'confidence disposition references unscreened finding' | 'merged finding cites input from unavailable reviewer' | 'merged finding submitter not a cited reviewer' | 'merged finding agreement credit overlaps submitters' | 'surviving finding diverges from its screened finding' | 'surviving finding references unscreened input' | 'duplicate confidence disposition' | 'validation must be not_attempted at finalize';
324
330
  export interface FinalizeContextRejection {
325
331
  readonly path: string;
326
332
  readonly reason: FinalizeContextRejectReason;
@@ -692,6 +698,7 @@ export interface SynthesizedFindingProjection {
692
698
  readonly suggested_fix?: ReconciledFinding['suggested_fix'];
693
699
  readonly validated?: boolean;
694
700
  readonly validation_reason?: string;
701
+ readonly route_narrowing_reason?: string;
695
702
  readonly input_finding_ids: readonly string[];
696
703
  readonly provenance: SynthesizedFindingProvenanceProjection;
697
704
  }
package/dist/pi.js CHANGED
@@ -9542,7 +9542,7 @@ function createProfileBundleSchema(agentNames, qualifiedAgentIds) {
9542
9542
  name,
9543
9543
  ProfileOverlaySchema.optional()
9544
9544
  ]))).strict().optional().meta({
9545
- description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error, exactly like the top-level `agents` field.",
9545
+ description: "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
9546
9546
  examples: [
9547
9547
  { "correctness-reviewer": { model: "openai/gpt-6-astra" } }
9548
9548
  ]
@@ -9645,7 +9645,7 @@ function createSystematicConfigSchema(opts) {
9645
9645
  name,
9646
9646
  AgentOverlaySchema.optional()
9647
9647
  ]))).strict().default({}).meta({
9648
- description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
9648
+ description: "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
9649
9649
  examples: [
9650
9650
  { "correctness-reviewer": { temperature: 0.1 } },
9651
9651
  { "review/correctness-reviewer": { temperature: 0.1 } },
@@ -9653,7 +9653,7 @@ function createSystematicConfigSchema(opts) {
9653
9653
  ]
9654
9654
  }),
9655
9655
  categories: record(string2(), CategoryOverlaySchema).default({}).meta({
9656
- description: "Per-category configuration overlays keyed by category name",
9656
+ description: "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
9657
9657
  examples: [{ review: { model: "anthropic/claude-opus-5" } }, {}]
9658
9658
  }),
9659
9659
  profiles: record(string2(), createProfileBundleSchema(agentNames, qualifiedAgentIds)).default({}).meta({
@@ -9967,6 +9967,46 @@ var PROTECTED_OVERLAY_FIELD_PATHS = {
9967
9967
  }
9968
9968
  };
9969
9969
  var PROJECT_PROTECTED_FIELDS = new Set(["workflow_guard", "profiles"]);
9970
+ var MAX_DIAGNOSTIC_TEXT = 200;
9971
+ var MAX_STRIP_WARNINGS = 20;
9972
+ var DIAGNOSTIC_ELLIPSIS = "…";
9973
+ function sanitizeDiagnosticText(input) {
9974
+ const budget = MAX_DIAGNOSTIC_TEXT - DIAGNOSTIC_ELLIPSIS.length;
9975
+ let rendered = "";
9976
+ let truncated = false;
9977
+ for (const char of input) {
9978
+ if (rendered.length >= budget) {
9979
+ truncated = true;
9980
+ break;
9981
+ }
9982
+ const code = char.codePointAt(0) ?? 0;
9983
+ const isControl = code <= 31 || code === 127 || code >= 128 && code <= 159 || code === 8232 || code === 8233;
9984
+ const piece = isControl ? `\\u${code.toString(16).padStart(4, "0")}` : char;
9985
+ if (rendered.length + piece.length > budget) {
9986
+ truncated = true;
9987
+ break;
9988
+ }
9989
+ rendered += piece;
9990
+ }
9991
+ return truncated ? `${rendered}${DIAGNOSTIC_ELLIPSIS}` : rendered;
9992
+ }
9993
+ function createBoundedStripWarningSink(warningSink) {
9994
+ let emitted = 0;
9995
+ let suppressed = 0;
9996
+ return {
9997
+ sink(message) {
9998
+ if (emitted < MAX_STRIP_WARNINGS) {
9999
+ emitted++;
10000
+ warningSink(message);
10001
+ } else {
10002
+ suppressed++;
10003
+ }
10004
+ },
10005
+ suppressedCount() {
10006
+ return suppressed;
10007
+ }
10008
+ };
10009
+ }
9970
10010
  var CURRENT_SKILL_NAMES_SET = new Set(BUNDLED_SKILL_NAMES);
9971
10011
  var CURRENT_AGENT_NAMES_SET = new Set([
9972
10012
  ...BUNDLED_AGENT_NAMES,
@@ -10119,7 +10159,7 @@ ${formatted.map((entry) => ` - ${entry}`).join(`
10119
10159
  issues
10120
10160
  });
10121
10161
  }
10122
- function loadConfigSource(filePath, trust, invalidSource) {
10162
+ function loadConfigSource(filePath, trust, invalidSource, warningSink) {
10123
10163
  try {
10124
10164
  const rawConfig = loadJsoncFile(filePath);
10125
10165
  if (!rawConfig) {
@@ -10129,7 +10169,8 @@ function loadConfigSource(filePath, trust, invalidSource) {
10129
10169
  };
10130
10170
  }
10131
10171
  const protectedFields = collectProjectProtectedFields(rawConfig, trust);
10132
- const config = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
10172
+ const topLevelStripped = trust === "project" ? stripProjectProtectedFields(rawConfig) : rawConfig;
10173
+ const config = trust === "project" ? stripProjectSecurityOverlayFields(topLevelStripped, filePath, warningSink) : topLevelStripped;
10133
10174
  const result = SystematicConfigSchema.safeParse(config);
10134
10175
  if (!result.success) {
10135
10176
  throwTopLevelConfigSchemaError(filePath, trust, result.error.issues, config);
@@ -10220,6 +10261,41 @@ function stripProjectProtectedFields(rawConfig) {
10220
10261
  }
10221
10262
  return config;
10222
10263
  }
10264
+ function stripProjectSecurityOverlayFields(rawConfig, filePath, warningSink) {
10265
+ const agents = stripSecurityOverlayEntries(rawConfig.agents, "agents", filePath, warningSink);
10266
+ const categories = stripSecurityOverlayEntries(rawConfig.categories, "categories", filePath, warningSink);
10267
+ if (agents === rawConfig.agents && categories === rawConfig.categories) {
10268
+ return rawConfig;
10269
+ }
10270
+ const result = { ...rawConfig };
10271
+ if (agents !== rawConfig.agents)
10272
+ result.agents = agents;
10273
+ if (categories !== rawConfig.categories)
10274
+ result.categories = categories;
10275
+ return result;
10276
+ }
10277
+ function stripSecurityOverlayEntries(overlayMap, mapKey, filePath, warningSink) {
10278
+ if (!isRecord2(overlayMap))
10279
+ return overlayMap;
10280
+ let changed = false;
10281
+ const result = {};
10282
+ for (const [key, value] of Object.entries(overlayMap)) {
10283
+ if (!isRecord2(value)) {
10284
+ result[key] = value;
10285
+ continue;
10286
+ }
10287
+ const stripped = stripProjectSecurityOverlay(filePath, `${mapKey}.${key}`, value, warningSink);
10288
+ if (stripped === value) {
10289
+ result[key] = stripped;
10290
+ continue;
10291
+ }
10292
+ changed = true;
10293
+ if (Object.keys(stripped).length === 0)
10294
+ continue;
10295
+ result[key] = stripped;
10296
+ }
10297
+ return changed ? result : overlayMap;
10298
+ }
10223
10299
  function isRecord2(value) {
10224
10300
  return typeof value === "object" && value !== null && !Array.isArray(value);
10225
10301
  }
@@ -10299,7 +10375,7 @@ function resolveActiveProfile(input) {
10299
10375
  const trustedDefault = trustedDefaultProfileName(input);
10300
10376
  const fallbackLookup = trustedDefault !== undefined && trustedDefault !== requested ? lookupProfileBundle(input, trustedDefault) : undefined;
10301
10377
  if (fallbackLookup !== undefined && trustedDefault !== undefined) {
10302
- input.warningSink(`[systematic] profile "${requested}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${trustedDefault}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
10378
+ input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}" (selected by ${selection.source} config) is not defined in \`profiles\`; falling back to your default profile "${sanitizeDiagnosticText(trustedDefault)}". See ${PROFILE_DOCS_URL} for how to define a profile.`);
10303
10379
  return {
10304
10380
  activeProfile: trustedDefault,
10305
10381
  profileSelectorSource: selection.source,
@@ -10309,8 +10385,8 @@ function resolveActiveProfile(input) {
10309
10385
  };
10310
10386
  }
10311
10387
  const sourceNote = selection.source === "user" ? "" : ` (selected by ${selection.source} config)`;
10312
- const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${trustedDefault}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
10313
- input.warningSink(`[systematic] profile "${requested}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
10388
+ const alsoMissingNote = trustedDefault !== undefined && trustedDefault !== requested ? ` Your default profile "${sanitizeDiagnosticText(trustedDefault)}" is also not defined in \`profiles\`.` : trustedDefault === undefined ? " No default profile is configured (`profile` in your user config)." : "";
10389
+ input.warningSink(`[systematic] profile "${sanitizeDiagnosticText(requested)}"${sourceNote} is not defined in \`profiles\`; using base configuration (no profile).${alsoMissingNote} See ${PROFILE_DOCS_URL} for how to define a profile.`);
10314
10390
  return {
10315
10391
  activeProfile: null,
10316
10392
  profileSelectorSource: selection.source,
@@ -10319,31 +10395,104 @@ function resolveActiveProfile(input) {
10319
10395
  bundleSource: null
10320
10396
  };
10321
10397
  }
10398
+ function resolveAliasedCustomConfigPath(paths, includeProject) {
10399
+ if (!includeProject || paths.customConfig === undefined)
10400
+ return;
10401
+ const sameFile = resolveConfigSourcePath(paths.projectConfig) === resolveConfigSourcePath(paths.customConfig);
10402
+ return sameFile ? paths.customConfig : undefined;
10403
+ }
10404
+ function createAliasStripTracker(warningSink, aliasedCustomConfigPath) {
10405
+ if (aliasedCustomConfigPath === undefined) {
10406
+ return { sink: warningSink, buffered: [] };
10407
+ }
10408
+ const buffered = [];
10409
+ return {
10410
+ sink: (message) => {
10411
+ buffered.push(message);
10412
+ },
10413
+ buffered
10414
+ };
10415
+ }
10416
+ function isAliasNoticeEligible(input) {
10417
+ return input.aliasedCustomConfigPath !== undefined && (input.bufferedCount > 0 || input.hasProtectedFields);
10418
+ }
10419
+ function emitAliasFailureDiagnostics(input) {
10420
+ if (!isAliasNoticeEligible({
10421
+ aliasedCustomConfigPath: input.aliasedCustomConfigPath,
10422
+ bufferedCount: input.buffered.length,
10423
+ hasProtectedFields: input.hasProtectedFields
10424
+ })) {
10425
+ return;
10426
+ }
10427
+ if (input.projectLoaded && input.customLoaded)
10428
+ return;
10429
+ for (const message of input.buffered)
10430
+ input.warningSink(message);
10431
+ }
10432
+ function buildAliasSuccessNotice(input) {
10433
+ if (!isAliasNoticeEligible({
10434
+ aliasedCustomConfigPath: input.aliasedCustomConfigPath,
10435
+ bufferedCount: input.bufferedCount,
10436
+ hasProtectedFields: input.hasProtectedFields
10437
+ }) || !(input.projectLoaded && input.customLoaded) || input.aliasedCustomConfigPath === undefined) {
10438
+ return;
10439
+ }
10440
+ const aliasedCustomConfigPath = input.aliasedCustomConfigPath;
10441
+ const projectConfigPath = input.projectConfigPath;
10442
+ const warningSink = input.warningSink;
10443
+ return () => {
10444
+ warningSink(`[systematic] project config (${sanitizeDiagnosticText(projectConfigPath)}) and custom config (${sanitizeDiagnosticText(aliasedCustomConfigPath)}) resolve to the same file; protected fields stripped from the project pass (security-overlay fields, \`profiles\`, \`workflow_guard\`) apply through the custom-trust pass instead.`);
10445
+ };
10446
+ }
10322
10447
  function loadConfigWithSources(projectDir, options) {
10323
10448
  const includeProject = options?.includeProject ?? true;
10324
10449
  const invalidSource = options?.invalidSource ?? "throw";
10325
10450
  const paths = getConfigPaths(projectDir, options);
10326
10451
  const warningSink = options?.warningSink ?? console.warn;
10327
- const user = loadConfigSource(paths.userConfig, "user", invalidSource);
10328
- const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource) : {
10452
+ const aliasedCustomConfigPath = resolveAliasedCustomConfigPath(paths, includeProject);
10453
+ const projectStrip = createAliasStripTracker(warningSink, aliasedCustomConfigPath);
10454
+ const boundedProjectStrip = createBoundedStripWarningSink(projectStrip.sink);
10455
+ const user = loadConfigSource(paths.userConfig, "user", invalidSource, warningSink);
10456
+ const project = includeProject ? loadConfigSource(paths.projectConfig, "project", invalidSource, boundedProjectStrip.sink) : {
10329
10457
  metadata: { kind: "project", presence: "absent" },
10330
10458
  source: null
10331
10459
  };
10332
- const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource) : {
10460
+ const custom = paths.customConfig ? loadConfigSource(paths.customConfig, "custom", invalidSource, warningSink) : {
10333
10461
  metadata: { kind: "custom", presence: "absent" },
10334
10462
  source: null
10335
10463
  };
10336
10464
  const userSource = user.source;
10337
10465
  const projectSource = project.source;
10338
10466
  const customSource = custom.source;
10467
+ if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
10468
+ boundedProjectStrip.sink(`[systematic] \`profiles\` in project config (${sanitizeDiagnosticText(projectSource.path)}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`);
10469
+ }
10470
+ const suppressedStripCount = boundedProjectStrip.suppressedCount();
10471
+ if (suppressedStripCount > 0) {
10472
+ projectStrip.sink(`[systematic] ${suppressedStripCount} additional project-config protected-field warning(s) in (${sanitizeDiagnosticText(paths.projectConfig)}) were suppressed.`);
10473
+ }
10474
+ emitAliasFailureDiagnostics({
10475
+ aliasedCustomConfigPath,
10476
+ buffered: projectStrip.buffered,
10477
+ customLoaded: custom.source !== null,
10478
+ hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
10479
+ projectLoaded: project.source !== null,
10480
+ warningSink
10481
+ });
10482
+ const emitAliasSuccessNotice = buildAliasSuccessNotice({
10483
+ aliasedCustomConfigPath,
10484
+ bufferedCount: projectStrip.buffered.length,
10485
+ customLoaded: custom.source !== null,
10486
+ hasProtectedFields: (projectSource?.protectedFields.length ?? 0) > 0,
10487
+ projectConfigPath: paths.projectConfig,
10488
+ projectLoaded: project.source !== null,
10489
+ warningSink
10490
+ });
10339
10491
  const sources = [userSource, projectSource, customSource].filter((source) => source !== null);
10340
10492
  const userConfig = userSource?.config;
10341
10493
  const projectConfig = projectSource?.config;
10342
10494
  const customConfig = customSource?.config;
10343
10495
  const warned = new Set;
10344
- if (projectSource?.protectedFields.some((field) => field.fieldPath === "profiles")) {
10345
- warningSink(`[systematic] \`profiles\` in project config (${projectSource.path}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`);
10346
- }
10347
10496
  assertAllProfileBundlesAreValid(userConfig, customConfig);
10348
10497
  const profileSelection = resolveActiveProfile({
10349
10498
  userConfig,
@@ -10415,6 +10564,7 @@ function loadConfigWithSources(projectDir, options) {
10415
10564
  disabled_skills: result.disabled_skills.filter((n) => !droppedSkillSet.has(n)),
10416
10565
  disabled_agents: result.disabled_agents.filter((n) => !droppedAgentSet.has(n))
10417
10566
  };
10567
+ emitAliasSuccessNotice?.();
10418
10568
  return {
10419
10569
  config: effectiveConfig,
10420
10570
  metadata: buildConfigObservationMetadata({
@@ -10457,7 +10607,7 @@ function buildConfigObservationMetadata(summary) {
10457
10607
  if (authority)
10458
10608
  authorities.push(authority);
10459
10609
  }
10460
- const protectedFields = summary.sources.flatMap((source) => source.protectedFields);
10610
+ const protectedFields = collectVisibleProtectedFields(summary.sources);
10461
10611
  const sources = dedupeSourceMetadata([summary.custom, summary.project, summary.user], sourcePaths);
10462
10612
  return {
10463
10613
  authorities: sortAuthorities(authorities),
@@ -10468,6 +10618,12 @@ function buildConfigObservationMetadata(summary) {
10468
10618
  profileFallback: summary.profileSelection.profileFallback
10469
10619
  };
10470
10620
  }
10621
+ function collectVisibleProtectedFields(sources) {
10622
+ const projectSource = sources.find((source) => source.trust === "project");
10623
+ const customSource = sources.find((source) => source.trust === "custom");
10624
+ const projectAppliedViaCustom = projectSource !== undefined && customSource !== undefined && projectSource.canonicalPath === customSource.canonicalPath;
10625
+ return sources.flatMap((source) => projectAppliedViaCustom && source.trust === "project" ? [] : source.protectedFields);
10626
+ }
10471
10627
  function dedupeSourceMetadata(metadata, sourcePaths) {
10472
10628
  const seen = new Set;
10473
10629
  return metadata.filter((source) => {
@@ -10583,9 +10739,6 @@ function mergeOverlayMap(target, source, mapKey) {
10583
10739
  if (!isRecord2(value)) {
10584
10740
  throwInvalidOverlay(source.path, keyPath);
10585
10741
  }
10586
- if (source.kind === "file" && source.trust === "project") {
10587
- rejectProjectSecurityOverlay(source.path, keyPath, value);
10588
- }
10589
10742
  const previous = target[key];
10590
10743
  const nextValue = resolveOverlayEntryValue(previous?.value, value, source);
10591
10744
  target[key] = {
@@ -10605,12 +10758,18 @@ function resolveOverlayEntryValue(previous, next, source) {
10605
10758
  return preserveSecurityFields(previous, next);
10606
10759
  return next;
10607
10760
  }
10608
- function rejectProjectSecurityOverlay(sourcePath, keyPath, value) {
10761
+ function stripProjectSecurityOverlay(sourcePath, keyPath, value, warningSink) {
10762
+ const safeKeyPath = sanitizeDiagnosticText(keyPath);
10763
+ const safeSourcePath = sanitizeDiagnosticText(sourcePath);
10764
+ let stripped;
10609
10765
  for (const field of SECURITY_OVERLAY_FIELDS) {
10610
10766
  if (Object.hasOwn(value, field)) {
10611
- throw new Error(`Invalid Systematic config in ${sourcePath}: ${keyPath}.${field} is only valid in user config or OPENCODE_CONFIG_DIR config`);
10767
+ stripped ??= { ...value };
10768
+ delete stripped[field];
10769
+ warningSink(`[systematic] \`${safeKeyPath}.${field}\` in project config (${safeSourcePath}) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`);
10612
10770
  }
10613
10771
  }
10772
+ return stripped ?? value;
10614
10773
  }
10615
10774
  function preserveSecurityFields(previous, next) {
10616
10775
  const result = { ...next };
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "__schema2": {
70
70
  "default": {},
71
- "description": "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead.",
71
+ "description": "Per-agent configuration overlays keyed by bundled agent name (bare or qualified category/name). Unknown keys are rejected with a Zod parse error, except that a project config entry under an unknown key is discarded before that check if stripping trust-protected fields leaves it empty. To overlay a user-defined agent, configure it through OpenCode-native config (.opencode/opencode.json) instead. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
72
72
  "examples": [
73
73
  {
74
74
  "correctness-reviewer": {
@@ -994,7 +994,7 @@
994
994
  },
995
995
  "__schema42": {
996
996
  "default": {},
997
- "description": "Per-category configuration overlays keyed by category name",
997
+ "description": "Per-category configuration overlays keyed by category name. Trust-protected fields (model, variant, skills, permission, opencode, pi) are only valid in user config or OPENCODE_CONFIG_DIR config — a project config setting them has that field ignored with a warning; other fields in the same overlay still apply.",
998
998
  "examples": [
999
999
  {
1000
1000
  "review": {
@@ -1221,7 +1221,7 @@
1221
1221
  }
1222
1222
  },
1223
1223
  "__schema58": {
1224
- "description": "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error, exactly like the top-level `agents` field.",
1224
+ "description": "Per-agent routing overlays for this profile, keyed by bundled agent name (bare or qualified category/name), using the same routing-only field set as every profile entry. Unknown keys are rejected with a Zod parse error.",
1225
1225
  "examples": [
1226
1226
  {
1227
1227
  "correctness-reviewer": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/systematic",
3
- "version": "3.18.7",
3
+ "version": "3.18.9",
4
4
  "description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
5
5
  "type": "module",
6
6
  "homepage": "https://fro.bot/systematic",
@@ -105,7 +105,7 @@
105
105
  "@tintinweb/pi-subagents": "0.14.3",
106
106
  "@types/bun": "latest",
107
107
  "@types/js-yaml": "4.0.9",
108
- "@types/node": "26.5.1",
108
+ "@types/node": "26.6.1",
109
109
  "agent-browser": "0.34.0",
110
110
  "ajv": "8.20.0",
111
111
  "ajv-formats": "3.0.1",
@@ -138,14 +138,32 @@ supplies the arithmetic and the narrowing rule.
138
138
  **Input:** `{ prepared:<prepare output>, adjudication:<model envelope with decisions[]> }`.
139
139
  Build one `decisions[]` entry for every candidate-group member: a `merged`
140
140
  decision citing 2+ input IDs from the same group with the merged finding's
141
- `title`, `why_it_matters`, `evidence`, `line`, `proposed_route` (when the
142
- merge's route should narrow), `route_narrowing_reason` (required whenever
143
- `proposed_route` is present), and optional `disagreement_facts` and
144
- `eligible_agreement_credit`; or a `declined` decision citing exactly one
145
- input ID with a `declined_reason` explaining why it stays a separate defect.
146
- Every candidate-group member must be cited by exactly one decision -- no
147
- omissions, no double-citations. `prepare`'s true singletons need no decision
148
- at all.
141
+ `title`, `why_it_matters`, `evidence`, `line`, an optional `proposed_route`,
142
+ `route_narrowing_reason` (required whenever `proposed_route` is present),
143
+ and optional `disagreement_facts` and `eligible_agreement_credit`; or a
144
+ `declined` decision citing exactly one input ID with a `declined_reason`
145
+ explaining why it stays a separate defect. Every candidate-group member must
146
+ be cited by exactly one decision -- no omissions, no double-citations.
147
+ `prepare`'s true singletons need no decision at all.
148
+
149
+ Omit `proposed_route` unless the route genuinely narrows: strictly narrower
150
+ than every contributing finding's own route, per the authored
151
+ narrows-only transitions (`autofix_class`, `owner`, `requires_verification`
152
+ each only ever narrow, never widen). A proposal that turns out to equal the
153
+ resolved route meet over the group's contributors -- for example, proposing
154
+ `owner: 'release'` for a group whose members are already routed to
155
+ incomparable owners whose meet is `release` -- is accepted, not rejected;
156
+ the merge phase simply carries no reason forward for it, since
157
+ `route_narrowing_reason` is defined for the pipeline's route-narrowing
158
+ provenance, not for every proposal a model happens to submit. A proposal
159
+ that genuinely widens the route (or is incomparable to it) is rejected.
160
+
161
+ The pairing between a merged finding's carried route and its
162
+ `route_narrowing_reason` is enforced only inside this pipeline (the
163
+ finalize-phase verifier), not by the persisted artifact's schema -- a
164
+ hand-authored `review-summary.json` carrying a `route_narrowing_reason` next
165
+ to a route that does not actually narrow will still pass `systematic
166
+ validate-review-artifact`.
149
167
 
150
168
  **Output:** `{ merged_findings, validator_requests[{finding_id,file,line}], disagreement_facts }`.
151
169
  `validator_requests` names the merged findings that fall inside the Stage 5b
@@ -342,6 +342,12 @@
342
342
  "maxLength": 2048,
343
343
  "pattern": "\\S"
344
344
  },
345
+ "route_narrowing_reason": {
346
+ "type": "string",
347
+ "minLength": 1,
348
+ "maxLength": 2048,
349
+ "pattern": "\\S"
350
+ },
345
351
  "input_finding_ids": {
346
352
  "minItems": 1,
347
353
  "maxItems": 32,
@@ -2,7 +2,7 @@
2
2
  // biome-ignore-all assist/source/organizeImports: generated bundle
3
3
  // Generated by scripts/generate-ce-review-validator.ts; do not edit by hand.
4
4
  // Run `bun run ce-review-validator:build` to regenerate.
5
- // source-digest: a0479091cb09f961a6cfcef76af7b620d1491dd601fc21322093debadc76fd96
5
+ // source-digest: 7cf7f5a7fe9d032522bd53ea5df68b77c7564b9bf228fd7032c38eca13a50d49
6
6
  var __defProp = Object.defineProperty
7
7
  var __returnValue = (v) => v
8
8
  function __exportSetter(name, newValue) {
@@ -6453,6 +6453,7 @@ var SynthesizedFindingFieldsSchema = object({
6453
6453
  suggested_fix: string2().max(2048).nullable().optional(),
6454
6454
  validated: boolean2().optional(),
6455
6455
  validation_reason: ReasonSchema.optional(),
6456
+ route_narrowing_reason: ReasonSchema.optional(),
6456
6457
  input_finding_ids: array(boundedText(MAX_INPUT_ID_LENGTH))
6457
6458
  .min(1)
6458
6459
  .max(MAX_FINDINGS),
@@ -7180,6 +7181,7 @@ var MergedFindingSchema = object({
7180
7181
  pre_existing: ParentFindingSchema.shape.pre_existing,
7181
7182
  fingerprint: ProvenanceSchema.shape.fingerprint,
7182
7183
  submitters: ProvenanceSchema.shape.submitters,
7184
+ route_narrowing_reason: PipelineReasonSchema.optional(),
7183
7185
  }).strict()
7184
7186
  var MergeOutputSchema = object({
7185
7187
  merged_findings: array(MergedFindingSchema).max(MAX_FINDINGS),
@@ -8034,6 +8036,13 @@ function meetOverNarrowsTo(narrowsTo, values) {
8034
8036
  validCandidates.every((other) => narrowsTo[candidate].includes(other)),
8035
8037
  )
8036
8038
  }
8039
+ function routesEqual(a, b) {
8040
+ return (
8041
+ a.autofix_class === b.autofix_class &&
8042
+ a.owner === b.owner &&
8043
+ a.requires_verification === b.requires_verification
8044
+ )
8045
+ }
8037
8046
  function deriveRouteMeet(contributing) {
8038
8047
  const autofixClasses = contributing.map((finding) => finding.autofix_class)
8039
8048
  const owners = contributing.map((finding) => finding.owner)
@@ -8054,7 +8063,9 @@ function deriveRouteMeet(contributing) {
8054
8063
  }
8055
8064
  function deriveRoute(contributing, decision) {
8056
8065
  const meet = deriveRouteMeet(contributing)
8057
- if (!decision.proposed_route) return { ok: true, value: meet }
8066
+ if (!decision.proposed_route) {
8067
+ return { ok: true, value: meet, differsFromMeet: false }
8068
+ }
8058
8069
  if (!decision.route_narrowing_reason) {
8059
8070
  return rejectMergedFinding(
8060
8071
  formatReviewArtifactIssuePath(['route_narrowing_reason']),
@@ -8067,7 +8078,11 @@ function deriveRoute(contributing, decision) {
8067
8078
  'route widening',
8068
8079
  )
8069
8080
  }
8070
- return { ok: true, value: decision.proposed_route }
8081
+ return {
8082
+ ok: true,
8083
+ value: decision.proposed_route,
8084
+ differsFromMeet: !routesEqual(meet, decision.proposed_route),
8085
+ }
8071
8086
  }
8072
8087
  function deriveMergedFindingFields(input) {
8073
8088
  const submitters = deriveSubmitters(input.contributing)
@@ -8102,6 +8117,7 @@ function deriveMergedFindingFields(input) {
8102
8117
  pre_existing: preExisting,
8103
8118
  fingerprint,
8104
8119
  route: routeResult.value,
8120
+ route_differs_from_meet: routeResult.differsFromMeet,
8105
8121
  },
8106
8122
  }
8107
8123
  }
@@ -8192,6 +8208,9 @@ function assembleMergedGroupFinding(group, survivingIndex, returnedReviewers) {
8192
8208
  evidence: decision.evidence,
8193
8209
  suggested_fix: decision.suggested_fix,
8194
8210
  input_finding_ids: sortedInputIds,
8211
+ route_narrowing_reason: derived.value.route_differs_from_meet
8212
+ ? decision.route_narrowing_reason
8213
+ : undefined,
8195
8214
  },
8196
8215
  derived.value,
8197
8216
  ),
@@ -8226,6 +8245,9 @@ function assembleSingletonFinding(
8226
8245
  evidence: finding.evidence,
8227
8246
  suggested_fix: finding.suggested_fix,
8228
8247
  input_finding_ids: [finding.input_id],
8248
+ route_narrowing_reason: derived.value.route_differs_from_meet
8249
+ ? decisionFields.route_narrowing_reason
8250
+ : undefined,
8229
8251
  },
8230
8252
  derived.value,
8231
8253
  ),
@@ -8270,6 +8292,9 @@ function toMergedFindingWireShape(assembly) {
8270
8292
  ...(assembly.agreement_credit
8271
8293
  ? { agreement_credit: [...assembly.agreement_credit] }
8272
8294
  : {}),
8295
+ ...(assembly.route_narrowing_reason !== undefined
8296
+ ? { route_narrowing_reason: assembly.route_narrowing_reason }
8297
+ : {}),
8273
8298
  }
8274
8299
  }
8275
8300
  function mergeFindingIdCollisionReason(first, second) {
@@ -8755,26 +8780,37 @@ function eligibleAgreementCreditClaim(finding) {
8755
8780
  ? finding.agreement_credit
8756
8781
  : undefined
8757
8782
  }
8758
- function mergedFindingDivergesFromDerivation(
8759
- finding,
8760
- contributingByFindingId,
8761
- returnedReviewers,
8762
- ) {
8763
- const resolved = contributingByFindingId.get(finding.finding_id) ?? []
8764
- const contributing = toContributingTuple(
8765
- resolved.length >= 2 ? resolved : [...resolved, ...resolved],
8783
+ function mergedFindingRouteNarrowed(finding, meet) {
8784
+ return !routesEqual(
8785
+ {
8786
+ autofix_class: finding.autofix_class,
8787
+ owner: finding.owner,
8788
+ requires_verification: finding.requires_verification,
8789
+ },
8790
+ meet,
8766
8791
  )
8792
+ }
8793
+ function mergedFindingRouteReasonMismatch(finding, meet) {
8794
+ return mergedFindingRouteNarrowed(finding, meet)
8795
+ ? finding.route_narrowing_reason === undefined
8796
+ : finding.route_narrowing_reason !== undefined
8797
+ }
8798
+ function mergedFindingDivergesFromDerivation(context) {
8799
+ const { finding, resolved, contributing, meet, returnedReviewers } = context
8800
+ const narrowed = mergedFindingRouteNarrowed(finding, meet)
8767
8801
  const derivation = deriveMergedFindingFields({
8768
8802
  contributing,
8769
8803
  decision: {
8770
8804
  line: finding.line,
8771
8805
  eligible_agreement_credit: eligibleAgreementCreditClaim(finding),
8772
- proposed_route: {
8773
- autofix_class: finding.autofix_class,
8774
- owner: finding.owner,
8775
- requires_verification: finding.requires_verification,
8776
- },
8777
- route_narrowing_reason: 'carried route verification',
8806
+ proposed_route: narrowed
8807
+ ? {
8808
+ autofix_class: finding.autofix_class,
8809
+ owner: finding.owner,
8810
+ requires_verification: finding.requires_verification,
8811
+ }
8812
+ : undefined,
8813
+ route_narrowing_reason: finding.route_narrowing_reason,
8778
8814
  },
8779
8815
  returned_reviewers: returnedReviewers,
8780
8816
  })
@@ -8802,12 +8838,19 @@ function checkMergedFindingsMatchDerivation(
8802
8838
  returnedReviewers,
8803
8839
  ) {
8804
8840
  for (const [index, finding] of mergedFindings.entries()) {
8841
+ const resolved = contributingByFindingId.get(finding.finding_id) ?? []
8842
+ const contributing = toContributingTuple(
8843
+ resolved.length >= 2 ? resolved : [...resolved, ...resolved],
8844
+ )
8845
+ const meet = deriveRouteMeet(contributing)
8805
8846
  if (
8806
- mergedFindingDivergesFromDerivation(
8847
+ mergedFindingDivergesFromDerivation({
8807
8848
  finding,
8808
- contributingByFindingId,
8849
+ resolved,
8850
+ contributing,
8851
+ meet,
8809
8852
  returnedReviewers,
8810
- )
8853
+ })
8811
8854
  ) {
8812
8855
  return {
8813
8856
  path: formatReviewArtifactIssuePath([
@@ -8818,6 +8861,17 @@ function checkMergedFindingsMatchDerivation(
8818
8861
  reason: 'merged finding fields diverge from derivation',
8819
8862
  }
8820
8863
  }
8864
+ if (mergedFindingRouteReasonMismatch(finding, meet)) {
8865
+ return {
8866
+ path: formatReviewArtifactIssuePath([
8867
+ 'merge',
8868
+ 'merged_findings',
8869
+ index,
8870
+ 'route_narrowing_reason',
8871
+ ]),
8872
+ reason: 'merged finding route narrowing reason mismatch',
8873
+ }
8874
+ }
8821
8875
  }
8822
8876
  return
8823
8877
  }
@@ -9657,6 +9711,9 @@ function projectOneSynthesizedFinding(finding) {
9657
9711
  ...(finding.validation_reason !== undefined
9658
9712
  ? { validation_reason: finding.validation_reason }
9659
9713
  : {}),
9714
+ ...(finding.route_narrowing_reason !== undefined
9715
+ ? { route_narrowing_reason: finding.route_narrowing_reason }
9716
+ : {}),
9660
9717
  input_finding_ids: finding.input_finding_ids,
9661
9718
  provenance: {
9662
9719
  fingerprint: finding.fingerprint,