superbee 0.4.3-pre.6 → 0.4.3-pre.7

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.
Files changed (2) hide show
  1. package/dist/superbee.mjs +57 -14
  2. package/package.json +1 -1
package/dist/superbee.mjs CHANGED
@@ -44,7 +44,7 @@ var __toESM = (mod, isNodeMode, target3) => (target3 = mod != null ? __create(__
44
44
  var define_SUPERBEE_BUILD_IDENTITY_default;
45
45
  var init_define_SUPERBEE_BUILD_IDENTITY = __esm({
46
46
  "<define:__SUPERBEE_BUILD_IDENTITY__>"() {
47
- define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.3-pre.6" }, source: { commit: "e4dbff30e3806cbcb70d658e41f3a29d46d069c8", dirty: false }, artifact: { channel: "npm-package" }, compatibility_contracts: { skill: 1, hook: 1, mcp: 1 } };
47
+ define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.3-pre.7" }, source: { commit: "9d53ab5b75db0b4c25ab0a214551d4211cc150a8", dirty: false }, artifact: { channel: "npm-package" }, compatibility_contracts: { skill: 1, hook: 1, mcp: 1 } };
48
48
  }
49
49
  });
50
50
 
@@ -88299,17 +88299,16 @@ function monotonicEvolutionBlockers(current, desired, blockers) {
88299
88299
  );
88300
88300
  }
88301
88301
  }
88302
- const currentDeclared = /* @__PURE__ */ new Set([...current.fields.required, ...current.fields.optional]);
88303
88302
  const desiredDeclared = /* @__PURE__ */ new Set([...desired.fields.required, ...desired.fields.optional]);
88304
88303
  for (const [field, desiredValues] of Object.entries(desired.fields.values)) {
88305
88304
  const currentValues = current.fields.values[field];
88306
88305
  if (!currentValues) {
88307
- if (desiredDeclared.has(field) && !currentDeclared.has(field)) continue;
88306
+ if (desiredDeclared.has(field)) continue;
88308
88307
  evolutionBlocker(
88309
88308
  blockers,
88310
88309
  "RECIPE_EVOLUTION_NON_MONOTONIC",
88311
88310
  desired.id,
88312
- `automatic evolution cannot add an enum restriction to '${field}' for '${desired.governs}'; only a field newly declared by the same plan may gain one`,
88311
+ `automatic evolution cannot add an enum restriction to '${field}' for '${desired.governs}'; declare '${field}' in fields.required or fields.optional first`,
88313
88312
  field
88314
88313
  );
88315
88314
  continue;
@@ -88368,6 +88367,20 @@ function monotonicEvolutionBlockers(current, desired, blockers) {
88368
88367
  );
88369
88368
  }
88370
88369
  }
88370
+ function addedFieldRestrictions(current, desired) {
88371
+ const types = /* @__PURE__ */ new Map();
88372
+ for (const [field, type] of Object.entries(desired.fields.types ?? {})) {
88373
+ if (!Object.hasOwn(current.fields.types ?? {}, field)) types.set(field, type);
88374
+ }
88375
+ const currentDeclared = /* @__PURE__ */ new Set([...current.fields.required, ...current.fields.optional]);
88376
+ const values = /* @__PURE__ */ new Map();
88377
+ for (const [field, allowed] of Object.entries(desired.fields.values)) {
88378
+ if (!Object.hasOwn(current.fields.values, field) && currentDeclared.has(field)) {
88379
+ values.set(field, allowed.map((value) => String(value)));
88380
+ }
88381
+ }
88382
+ return { types, values };
88383
+ }
88371
88384
  function addedLinkTypes(current, desired) {
88372
88385
  const currentLinks = current.links ?? {};
88373
88386
  return Object.keys(desired.links ?? {}).filter((linkType) => !Object.hasOwn(currentLinks, linkType));
@@ -88423,6 +88436,7 @@ async function prepareRecipeEvolution(bundle, sourceRecipe) {
88423
88436
  const proofs = [];
88424
88437
  const desiredKinds = /* @__PURE__ */ new Map();
88425
88438
  const addedLinkTexts = /* @__PURE__ */ new Set();
88439
+ const addedRestrictions = /* @__PURE__ */ new Map();
88426
88440
  const skippedConventions = [];
88427
88441
  const installedConventions = await query2(bundle, { prefix: CONVENTIONS_PREFIX, type: "Convention" }, {
88428
88442
  onSkip: (skipped) => skippedConventions.push(skipped)
@@ -88567,6 +88581,7 @@ async function prepareRecipeEvolution(bundle, sourceRecipe) {
88567
88581
  });
88568
88582
  if (!unchanged2 && existing.doc.frontmatter.type === "Convention" && parsedCurrent.ok && parsedCandidate.ok && parsedCurrent.kind.governs === parsedCandidate.kind.governs) {
88569
88583
  monotonicEvolutionBlockers(parsedCurrent.kind, parsedCandidate.kind, blockers);
88584
+ addedRestrictions.set(parsedCandidate.kind.governs, addedFieldRestrictions(parsedCurrent.kind, parsedCandidate.kind));
88570
88585
  for (const linkType of addedLinkTypes(parsedCurrent.kind, parsedCandidate.kind)) addedLinkTexts.add(linkType);
88571
88586
  }
88572
88587
  }
@@ -88651,6 +88666,8 @@ async function prepareRecipeEvolution(bundle, sourceRecipe) {
88651
88666
  );
88652
88667
  }
88653
88668
  for (const kind2 of changingKinds) {
88669
+ const added = addedRestrictions.get(kind2.governs);
88670
+ const violations = /* @__PURE__ */ new Map();
88654
88671
  for (const doc2 of docs) {
88655
88672
  if (String(doc2.frontmatter.type) !== kind2.governs) continue;
88656
88673
  instancesChecked += 1;
@@ -88659,16 +88676,39 @@ async function prepareRecipeEvolution(bundle, sourceRecipe) {
88659
88676
  id: doc2.id,
88660
88677
  current_version: contentVersion(doc2)
88661
88678
  });
88662
- for (const warning of projectKindValidationWarnings(okfVersion, kind2, validateAgainstKind(doc2, kind2))) {
88663
- evolutionBlocker(
88664
- blockers,
88665
- "RECIPE_EVOLUTION_INSTANCE_INVALID",
88666
- doc2.id,
88667
- warning.message,
88668
- warning.field
88669
- );
88679
+ const stored = validateAgainstKind(doc2, kind2);
88680
+ const projected = projectKindValidationWarnings(okfVersion, kind2, stored);
88681
+ for (const [index2, warning] of projected.entries()) {
88682
+ const field = stored[index2].field ?? "";
88683
+ const restriction = warning.code === "KIND_FIELD_TYPE" && added?.types.has(field) ? `fields.types.${field}` : (warning.code === "KIND_FIELD_VALUE" || warning.code === "KIND_FIELD_ARITY") && added?.values.has(field) ? `fields.values.${field}` : void 0;
88684
+ if (restriction === void 0) {
88685
+ evolutionBlocker(
88686
+ blockers,
88687
+ "RECIPE_EVOLUTION_INSTANCE_INVALID",
88688
+ doc2.id,
88689
+ warning.message,
88690
+ warning.field
88691
+ );
88692
+ continue;
88693
+ }
88694
+ const entry = violations.get(restriction) ?? { field, docs: /* @__PURE__ */ new Map() };
88695
+ if (!entry.docs.has(doc2.id)) entry.docs.set(doc2.id, warning.message);
88696
+ violations.set(restriction, entry);
88670
88697
  }
88671
88698
  }
88699
+ for (const [restriction, { field, docs: violating }] of violations) {
88700
+ const ids = [...violating.keys()].sort();
88701
+ const named = ids.slice(0, RESTRICTION_BLOCKER_DOC_CAP).join(", ");
88702
+ const more = ids.length > RESTRICTION_BLOCKER_DOC_CAP ? `, and ${ids.length - RESTRICTION_BLOCKER_DOC_CAP} more` : "";
88703
+ const declared = restriction.startsWith("fields.types.") ? `type '${added.types.get(field)}'` : `allowed values [${added.values.get(field).join(", ")}]`;
88704
+ evolutionBlocker(
88705
+ blockers,
88706
+ "RECIPE_EVOLUTION_RESTRICTION_VIOLATED",
88707
+ kind2.id,
88708
+ `adding ${declared} to '${field}' for '${kind2.governs}' would make ${ids.length} existing document(s) invalid: ${named}${more}; fix them first (e.g. ${ids[0]}: ${violating.get(ids[0])})`,
88709
+ restriction
88710
+ );
88711
+ }
88672
88712
  }
88673
88713
  if (addedLinkTexts.size > 0) {
88674
88714
  const proven = new Set(instanceProofs.map((proof) => proof.id));
@@ -88836,7 +88876,7 @@ async function applyRecipeEvolution(bundle, recipe2, expectedPlanToken, actor) {
88836
88876
  counts: { updated, unchanged: completed.length - updated }
88837
88877
  };
88838
88878
  }
88839
- var RECIPE_EVOLUTION_WRITE_REGISTRY, PRESERVED_ROOT_METADATA, BUNDLE_LOCAL_PLACEMENT;
88879
+ var RECIPE_EVOLUTION_WRITE_REGISTRY, PRESERVED_ROOT_METADATA, BUNDLE_LOCAL_PLACEMENT, RESTRICTION_BLOCKER_DOC_CAP;
88840
88880
  var init_recipe_evolution = __esm({
88841
88881
  "../cli/src/recipe-evolution.ts"() {
88842
88882
  "use strict";
@@ -88849,6 +88889,7 @@ var init_recipe_evolution = __esm({
88849
88889
  RECIPE_EVOLUTION_WRITE_REGISTRY = { kinds: /* @__PURE__ */ new Map(), warnings: [] };
88850
88890
  PRESERVED_ROOT_METADATA = /* @__PURE__ */ new Set(["timestamp", "actor", "generated", "verified", "superbee_updated_by"]);
88851
88891
  BUNDLE_LOCAL_PLACEMENT = /* @__PURE__ */ new Set(["order"]);
88892
+ RESTRICTION_BLOCKER_DOC_CAP = 10;
88852
88893
  }
88853
88894
  });
88854
88895
 
@@ -89036,7 +89077,9 @@ it compares definitions, permits additive declarations only, revalidates existin
89036
89077
  returns one exact apply command. Applying requires that plan's token, recomputes the preflight, and
89037
89078
  writes each changed convention with exact-version CAS. Concurrent non-target changes are detected
89038
89079
  by a postcondition check and reported with completed work. It never replaces existing values,
89039
- active View assets, or artifacts omitted from the source.
89080
+ active View assets, or artifacts omitted from the source. It may add a field type (fields.types) or
89081
+ an enum (fields.values) to a declared field only when every existing instance conforms; otherwise
89082
+ the plan names the violating documents. It never changes or removes a type or an enum.
89040
89083
 
89041
89084
  Options:
89042
89085
  --dir <path> Bundle directory (default: discovered from the cwd)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superbee",
3
- "version": "0.4.3-pre.6",
3
+ "version": "0.4.3-pre.7",
4
4
  "type": "module",
5
5
  "description": "Agent-facing Superbee CLI for reading and writing local OKF knowledge bundles: context notes, docs, cross-links, and live bundle Views.",
6
6
  "keywords": [