@geonosis/policy 2.9.0 → 2.11.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @geonosis/policy
2
2
 
3
+ ## 2.11.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 0f99e26: The kit names no consumer. Docs, doc comments and messages describe the repos a pattern was measured in by their stack (a Medusa storefront, a Workers + D1 app, a Mercur v1 marketplace). Example configs are named the same way: `examples/medusa-storefront.*.json`, `examples/workers-app.*.json`. No behaviour changes.
8
+
9
+ ## 2.10.0
10
+
3
11
  ## 2.9.0
4
12
 
5
13
  ## 2.8.0
package/README.md CHANGED
@@ -73,7 +73,7 @@ and drown the one signal anybody is looking for.
73
73
  | `@geonosis/policy/permissions` | `definePolicies` / `hasPermission` / `resolvePermissions` / `checkPermissions` / `createPolicyCatalog` / `expandPolicies`. |
74
74
  | `@geonosis/policy/medusa` · `/drizzle` | Two stores behind the same ports. Neither imports the store it adapts. |
75
75
 
76
- ## Migrating dielime's rules engine, in five lines
76
+ ## Migrating a Medusa storefront's rules engine, in five lines
77
77
 
78
78
  1. `lib/rules.ts` → `definePolicy({ tiers: POLICY_TIERS, kinds: …, scopeKeys: … })`; the twelve
79
79
  `PolicyConstraint` members become twelve `{ kind, schema }`, and `KNOWN_SCOPE_KEYS` +
@@ -114,7 +114,7 @@ spelled in, and none of them is one repo's word for one repo's thing. A repo add
114
114
  A bound declared **inside a function** is left alone — it is a step in an algorithm, not a
115
115
  repo-wide decision — and the anchor that does that is column zero.
116
116
 
117
- ## during.day, corrected
117
+ ## a Workers + D1 app, corrected
118
118
 
119
119
  The earlier version of this section read: *"Its thresholds are lint-enforced constants … They are
120
120
  not [policy]. `grep -E '_LIMIT|_THRESHOLD|MAX_|_CAP'` across all 34 [`constants.ts` files] returns
@@ -148,8 +148,8 @@ worth precisely as much as its journal is fed, which today is not at all.
148
148
 
149
149
  **D-027 status: one consumer with pull.** C3 of `docs/challenge-2026-08-30.md` ranked this behind
150
150
  `@geonosis/integrations` for that reason and it was right to; this package ships inside 1.0.0 with
151
- dielime's kernel as its only live consumer and musa's lattice as a second fixture, not a second
152
- consumer. It is DONE when dielime depends on the published version and has deleted its `lib/`.
151
+ a Medusa storefront's kernel as its only live consumer and musa's lattice as a second fixture, not a second
152
+ consumer. It is DONE when a Medusa storefront depends on the published version and has deleted its `lib/`.
153
153
 
154
154
  ## What it deliberately does NOT do
155
155
 
@@ -172,7 +172,7 @@ import { definePolicy } from '@geonosis/policy' // ESM, module: Node16 or E
172
172
  const { definePolicy } = require('@geonosis/policy') // CommonJS
173
173
  ```
174
174
 
175
- An ESM-only package is a wall for such a backend, and no amount of parity gets over it: dielime
175
+ An ESM-only package is a wall for such a backend, and no amount of parity gets over it: a Medusa storefront
176
176
  measured `@geonosis/testbed` at 15/15 identical and still could not adopt it, because a static
177
177
  import is TS1479 and `await import()` cannot serve the synchronous `describe()` registration its 107
178
178
  suites are built on.
@@ -1,4 +1,4 @@
1
- import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-DzC5zTZ8.cjs';
1
+ import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.cjs';
2
2
 
3
3
  /**
4
4
  * A drizzle table, behind the ports the kernel reads.
@@ -1,4 +1,4 @@
1
- import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-DzC5zTZ8.js';
1
+ import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.js';
2
2
 
3
3
  /**
4
4
  * A drizzle table, behind the ports the kernel reads.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as PolicyRuleRow, b as PolicyAdapter, c as PolicyKindSpec, d as PolicyRule, e as PolicyTierSpec, f as Policy, P as PolicyQuery, g as PolicyData, h as PolicyDecision, i as PolicyScope, U as UnusableRule, J as JournalObservationEntry, j as PolicyJournal, k as PolicyConfigReader, l as PolicyRuleReader, m as PolicyReading } from './types-DzC5zTZ8.cjs';
2
- export { A as Awaitable, n as POLICY_FALLBACK, o as POLICY_INVALID_VALUE, p as PolicyJournalEntry, S as SchemaLike } from './types-DzC5zTZ8.cjs';
1
+ import { a as PolicyRuleRow, b as PolicyAdapter, c as PolicyKindSpec, d as PolicyRule, e as PolicyTierSpec, f as Policy, P as PolicyQuery, g as PolicyData, h as PolicyDecision, i as PolicyScope, U as UnusableRule, J as JournalObservationEntry, j as PolicyJournal, k as PolicyConfigReader, l as PolicyRuleReader, m as PolicyReading } from './types-C-Q3r-In.cjs';
2
+ export { A as Awaitable, n as POLICY_FALLBACK, o as POLICY_INVALID_VALUE, p as PolicyJournalEntry, S as SchemaLike } from './types-C-Q3r-In.cjs';
3
3
 
4
4
  /**
5
5
  * One suite every storage adapter passes.
@@ -42,7 +42,7 @@ type PolicyInput = {
42
42
  /**
43
43
  * May the overriding tier beat a rule that does not say either way?
44
44
  *
45
- * dielime says yes (`rule.overridable !== false`), musa says no (`&& winner.overridable`).
45
+ * A Medusa storefront says yes (`rule.overridable !== false`), musa says no (`&& winner.overridable`).
46
46
  * Neither is wrong for the other's business, so it is declared rather than assumed.
47
47
  */
48
48
  overridableByDefault?: boolean;
@@ -80,8 +80,8 @@ declare const assertScopeOrder: (policy: {
80
80
  * it suppressed.
81
81
  *
82
82
  * Nothing in this file names a tier, a kind or a scope key. Two consumers wrote this lattice
83
- * independently and disagreed on all three (dielime's strongest tier is `regulatory`, musa's is
84
- * `physics`), which is why every one of them is data.
83
+ * independently and disagreed on all three (a Medusa storefront's strongest tier is `regulatory`,
84
+ * musa's is `physics`), which is why every one of them is data.
85
85
  */
86
86
  /**
87
87
  * The weight of a scope key, derived from where it was declared.
@@ -231,9 +231,9 @@ declare const demote: (playbook: Playbook, id: string, reason: string) => Playbo
231
231
  /**
232
232
  * Active learnings that imply a constraint, as rules at the tier the policy calls advisory.
233
233
  *
234
- * dielime writes `tier: 'learned'` into this function. Here the tier is read off the lattice,
235
- * because a policy that declares none has nowhere safe to put a suggestion — and quietly choosing
236
- * one would hand a suggestion the authority of an SOP.
234
+ * A Medusa storefront writes `tier: 'learned'` into this function. Here the tier is read off the
235
+ * lattice, because a policy that declares none has nowhere safe to put a suggestion — and quietly
236
+ * choosing one would hand a suggestion the authority of an SOP.
237
237
  */
238
238
  declare const playbookRules: (policy: Policy, playbook: Playbook) => PolicyRule[];
239
239
  /** The playbook as agent-readable guidance — a delta on top of a built prompt, never a replacement. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as PolicyRuleRow, b as PolicyAdapter, c as PolicyKindSpec, d as PolicyRule, e as PolicyTierSpec, f as Policy, P as PolicyQuery, g as PolicyData, h as PolicyDecision, i as PolicyScope, U as UnusableRule, J as JournalObservationEntry, j as PolicyJournal, k as PolicyConfigReader, l as PolicyRuleReader, m as PolicyReading } from './types-DzC5zTZ8.js';
2
- export { A as Awaitable, n as POLICY_FALLBACK, o as POLICY_INVALID_VALUE, p as PolicyJournalEntry, S as SchemaLike } from './types-DzC5zTZ8.js';
1
+ import { a as PolicyRuleRow, b as PolicyAdapter, c as PolicyKindSpec, d as PolicyRule, e as PolicyTierSpec, f as Policy, P as PolicyQuery, g as PolicyData, h as PolicyDecision, i as PolicyScope, U as UnusableRule, J as JournalObservationEntry, j as PolicyJournal, k as PolicyConfigReader, l as PolicyRuleReader, m as PolicyReading } from './types-C-Q3r-In.js';
2
+ export { A as Awaitable, n as POLICY_FALLBACK, o as POLICY_INVALID_VALUE, p as PolicyJournalEntry, S as SchemaLike } from './types-C-Q3r-In.js';
3
3
 
4
4
  /**
5
5
  * One suite every storage adapter passes.
@@ -42,7 +42,7 @@ type PolicyInput = {
42
42
  /**
43
43
  * May the overriding tier beat a rule that does not say either way?
44
44
  *
45
- * dielime says yes (`rule.overridable !== false`), musa says no (`&& winner.overridable`).
45
+ * A Medusa storefront says yes (`rule.overridable !== false`), musa says no (`&& winner.overridable`).
46
46
  * Neither is wrong for the other's business, so it is declared rather than assumed.
47
47
  */
48
48
  overridableByDefault?: boolean;
@@ -80,8 +80,8 @@ declare const assertScopeOrder: (policy: {
80
80
  * it suppressed.
81
81
  *
82
82
  * Nothing in this file names a tier, a kind or a scope key. Two consumers wrote this lattice
83
- * independently and disagreed on all three (dielime's strongest tier is `regulatory`, musa's is
84
- * `physics`), which is why every one of them is data.
83
+ * independently and disagreed on all three (a Medusa storefront's strongest tier is `regulatory`,
84
+ * musa's is `physics`), which is why every one of them is data.
85
85
  */
86
86
  /**
87
87
  * The weight of a scope key, derived from where it was declared.
@@ -231,9 +231,9 @@ declare const demote: (playbook: Playbook, id: string, reason: string) => Playbo
231
231
  /**
232
232
  * Active learnings that imply a constraint, as rules at the tier the policy calls advisory.
233
233
  *
234
- * dielime writes `tier: 'learned'` into this function. Here the tier is read off the lattice,
235
- * because a policy that declares none has nowhere safe to put a suggestion — and quietly choosing
236
- * one would hand a suggestion the authority of an SOP.
234
+ * A Medusa storefront writes `tier: 'learned'` into this function. Here the tier is read off the
235
+ * lattice, because a policy that declares none has nowhere safe to put a suggestion — and quietly
236
+ * choosing one would hand a suggestion the authority of an SOP.
237
237
  */
238
238
  declare const playbookRules: (policy: Policy, playbook: Playbook) => PolicyRule[];
239
239
  /** The playbook as agent-readable guidance — a delta on top of a built prompt, never a replacement. */
@@ -1,5 +1,5 @@
1
1
  import { PermissionAction } from '../permissions/index.cjs';
2
- import { A as Awaitable, P as PolicyQuery, d as PolicyRule, p as PolicyJournalEntry, a as PolicyRuleRow, b as PolicyAdapter } from '../types-DzC5zTZ8.cjs';
2
+ import { A as Awaitable, P as PolicyQuery, d as PolicyRule, p as PolicyJournalEntry, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.cjs';
3
3
 
4
4
  /**
5
5
  * The Medusa store, behind the ports the kernel reads.
@@ -1,5 +1,5 @@
1
1
  import { PermissionAction } from '../permissions/index.js';
2
- import { A as Awaitable, P as PolicyQuery, d as PolicyRule, p as PolicyJournalEntry, a as PolicyRuleRow, b as PolicyAdapter } from '../types-DzC5zTZ8.js';
2
+ import { A as Awaitable, P as PolicyQuery, d as PolicyRule, p as PolicyJournalEntry, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.js';
3
3
 
4
4
  /**
5
5
  * The Medusa store, behind the ports the kernel reads.
@@ -2,11 +2,11 @@
2
2
  * A permission lattice — Medusa 2.19.0's `definePolicies` / `hasPermission` / `resolvePermissions`
3
3
  * with the container lifted out.
4
4
  *
5
- * dielime did not reinvent permissions and was right not to: it adopted the native module and put a
6
- * typed registry in front of it. What that registry could not be given was a way to ANSWER the
7
- * question without a booted container — so the same 22 named policies are unit-testable in node and
8
- * the check they feed is not. Everything here is pure: the grants are data the caller fetched, and
9
- * the answer is a value.
5
+ * A Medusa storefront did not reinvent permissions and was right not to: it adopted the native
6
+ * module and put a typed registry in front of it. What that registry could not be given was a way
7
+ * to ANSWER the question without a booted container — so the same 22 named policies are
8
+ * unit-testable in node and the check they feed is not. Everything here is pure: the grants are
9
+ * data the caller fetched, and the answer is a value.
10
10
  *
11
11
  * Every semantic is pinned from the shipped implementation. No test file ships in either tarball.
12
12
  */
@@ -37,8 +37,8 @@ declare const permissionKey: (resource: string, operation: string) => string;
37
37
  *
38
38
  * Exported because a repo has to be able to check its own vocabulary against it: an operation
39
39
  * spelled `certificate:create` normalises to `certificate_create`, so a repo that authors its rows
40
- * directly (as dielime does) and ALSO declares them through here would end up with two spellings of
41
- * one permission and no error anywhere.
40
+ * directly (as a Medusa storefront does) and ALSO declares them through here would end up with two
41
+ * spellings of one permission and no error anywhere.
42
42
  */
43
43
  declare const normalizePolicyKey: (key: string) => string;
44
44
  type DefinePoliciesOptions = {
@@ -2,11 +2,11 @@
2
2
  * A permission lattice — Medusa 2.19.0's `definePolicies` / `hasPermission` / `resolvePermissions`
3
3
  * with the container lifted out.
4
4
  *
5
- * dielime did not reinvent permissions and was right not to: it adopted the native module and put a
6
- * typed registry in front of it. What that registry could not be given was a way to ANSWER the
7
- * question without a booted container — so the same 22 named policies are unit-testable in node and
8
- * the check they feed is not. Everything here is pure: the grants are data the caller fetched, and
9
- * the answer is a value.
5
+ * A Medusa storefront did not reinvent permissions and was right not to: it adopted the native
6
+ * module and put a typed registry in front of it. What that registry could not be given was a way
7
+ * to ANSWER the question without a booted container — so the same 22 named policies are
8
+ * unit-testable in node and the check they feed is not. Everything here is pure: the grants are
9
+ * data the caller fetched, and the answer is a value.
10
10
  *
11
11
  * Every semantic is pinned from the shipped implementation. No test file ships in either tarball.
12
12
  */
@@ -37,8 +37,8 @@ declare const permissionKey: (resource: string, operation: string) => string;
37
37
  *
38
38
  * Exported because a repo has to be able to check its own vocabulary against it: an operation
39
39
  * spelled `certificate:create` normalises to `certificate_create`, so a repo that authors its rows
40
- * directly (as dielime does) and ALSO declares them through here would end up with two spellings of
41
- * one permission and no error anywhere.
40
+ * directly (as a Medusa storefront does) and ALSO declares them through here would end up with two
41
+ * spellings of one permission and no error anywhere.
42
42
  */
43
43
  declare const normalizePolicyKey: (key: string) => string;
44
44
  type DefinePoliciesOptions = {
@@ -3,8 +3,8 @@ type Awaitable<T> = Promise<T> | T;
3
3
  /**
4
4
  * A schema, recognised by what it does rather than by what it is an instance of.
5
5
  *
6
- * dielime imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
7
- * resolves to the copy `@medusajs/deps` ships, while its own devDependency and during.day's catalog
6
+ * A Medusa storefront imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
7
+ * resolves to the copy `@medusajs/deps` ships, while its own devDependency and a Workers + D1 app's catalog
8
8
  * are two further copies of the same major. `value instanceof z.ZodType` compares against a class
9
9
  * object, so a schema from another copy is not an instance of ours: such a guard passes every test
10
10
  * written against the kit's own zod and refuses every schema a consumer hands it.
@@ -3,8 +3,8 @@ type Awaitable<T> = Promise<T> | T;
3
3
  /**
4
4
  * A schema, recognised by what it does rather than by what it is an instance of.
5
5
  *
6
- * dielime imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
7
- * resolves to the copy `@medusajs/deps` ships, while its own devDependency and during.day's catalog
6
+ * A Medusa storefront imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
7
+ * resolves to the copy `@medusajs/deps` ships, while its own devDependency and a Workers + D1 app's catalog
8
8
  * are two further copies of the same major. `value instanceof z.ZodType` compares against a class
9
9
  * object, so a schema from another copy is not an instance of ours: such a guard passes every test
10
10
  * written against the kit's own zod and refuses every schema a consumer hands it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geonosis/policy",
3
- "version": "2.9.0",
3
+ "version": "2.11.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "description": "A threshold is a value plus the authority that set it, the subject it reaches and the reason it exists. The precedence lattice, the rule → config → constant read with its fallback journalled once per boot, the learning loop, the generated policy prose, and a permission lattice with the runtime lifted out.",
6
6
  "keywords": [
@@ -85,7 +85,7 @@
85
85
  "access": "public"
86
86
  },
87
87
  "scripts": {
88
- "build": "tsup",
88
+ "build": "tsx ../../tooling/build-step.ts tsup",
89
89
  "typecheck": "tsc --noEmit",
90
90
  "lint": "oxlint --config ../../.oxlintrc.json .",
91
91
  "test:unit": "vitest run --project unit --root ../.. --passWithNoTests \"$PWD\"",