@reqvire-org/ads 0.3.23 → 0.3.25

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 (37) hide show
  1. package/dist/behaviors.mjs +6 -4
  2. package/dist/config.mjs +2 -1
  3. package/dist/contract-migration.mjs +1 -1
  4. package/dist/contracts.d.mts +2 -2
  5. package/dist/declarative-flow.mjs +144 -0
  6. package/dist/mcp/catalog.mjs +4 -2
  7. package/dist/mcp/mutations.mjs +4 -4
  8. package/dist/mcp/preview-widget.bundle.js +5 -5
  9. package/dist/runtime-contracts.mjs +26 -37
  10. package/dist/scenario-trace.mjs +47 -18
  11. package/dist/scenarios.mjs +1 -1
  12. package/dist/showcase/client.bundle.js +15 -15
  13. package/dist/skills/ads-break-ui/SKILL.md +2 -1
  14. package/dist/skills/ads-break-ui/references/contracts.md +50 -3
  15. package/dist/skills/ads-break-ui/references/guarded-editing.md +10 -0
  16. package/dist/skills/ads-designer/SKILL.md +2 -1
  17. package/dist/skills/ads-designer/references/contracts.md +50 -3
  18. package/dist/skills/ads-designer/references/guarded-editing.md +10 -0
  19. package/dist/skills/ads-import/SKILL.md +2 -1
  20. package/dist/skills/ads-import/references/contracts.md +50 -3
  21. package/dist/skills/ads-import/references/guarded-editing.md +10 -0
  22. package/dist/skills/ads-migrate/SKILL.md +2 -1
  23. package/dist/skills/ads-migrate/references/contracts.md +50 -3
  24. package/dist/skills/ads-migrate/references/guarded-editing.md +10 -0
  25. package/dist/skills/ads-motion/SKILL.md +2 -1
  26. package/dist/skills/ads-motion/references/contracts.md +50 -3
  27. package/dist/skills/ads-motion/references/guarded-editing.md +10 -0
  28. package/dist/source-values.mjs +3 -3
  29. package/dist/unit-contracts.mjs +23 -4
  30. package/dist/verification/browser.mjs +2 -0
  31. package/docs/ARCHITECTURE.md +5 -0
  32. package/docs/BEHAVIORS.md +8 -0
  33. package/docs/CHANGELOG.md +21 -0
  34. package/docs/CONTRACTS.md +50 -3
  35. package/docs/GUIDE.md +3 -1
  36. package/docs/MCP.md +23 -4
  37. package/package.json +1 -1
@@ -13,7 +13,7 @@ const id = z.string().regex(/^[A-Za-z0-9][\w.-]{0,99}$/);
13
13
  const checks = z.array(id).min(1).max(100);
14
14
  const field = z.string().regex(/^[A-Za-z_$][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\*))*$/).max(200);
15
15
  const paint = z.object({ api: ref, property: field, kind: z.literal("paint-reference"), bindings: z.array(id).max(20).optional() }).strict();
16
- const binding = z.object({ input: z.object({ api: ref, property: field }).strict(), producer: ref, valueFrom: field,
16
+ const binding = z.object({ input: z.object({ api: ref, property: field }).strict(), producer: ref, valueFrom: z.union([field,z.array(field).min(1).max(12).refine(paths=>new Set(paths).size===paths.length,"Value paths must be distinct.")]),
17
17
  variable: z.string().regex(/^--[a-z][\w-]*\$\{key\}[\w-]*$/), scope: z.object({ api: ref, selector: z.string().min(1).max(200) }).strict(), checks }).strict();
18
18
  const part = z.object({ api: ref, parent: ref, consumer: ref, checks }).strict();
19
19
  const schema = z.object({ schemaVersion: z.literal(1),
@@ -165,12 +165,31 @@ export function inspectUnitContracts(options) {
165
165
  if (entry.apiName !== entry.scope.apiName) report("The binding input and attachment scope must belong to the same public API.", `bindings.${name}`);
166
166
  }
167
167
  for (const [index, entry] of (data.declarativeParts ?? []).entries()) {
168
- if(data.declarativeParts.slice(0,index).some(prior=>prior.api.identity===entry.api.identity))report("A declarative API needs one unambiguous parent/consumer relationship.",`declarativeParts.${index}`);
168
+ if(data.declarativeParts.slice(0,index).some(prior=>prior.api.identity===entry.api.identity&&prior.parent.identity===entry.parent.identity))report("Duplicate declarative parent relationship: each API/parent pair has one consumer and check registration.",`declarativeParts.${index}`);
169
169
  entry.apiName = apiName(entry.api, `declarativeParts.${index}.api`);
170
170
  entry.parentName = apiName(entry.parent, `declarativeParts.${index}.parent`);
171
- if(!publicByIdentity.get(entry.parent.identity)?.renderable)report("Declarative parents require a real public rendering API.",`declarativeParts.${index}.parent`);
172
171
  implementation(entry.consumer, `declarativeParts.${index}.consumer`);
173
172
  }
173
+ const parts=data.declarativeParts??[];
174
+ const rootCache=new Map(),cycleCache=new Map();
175
+ function roots(reference,seen=new Set()) {
176
+ if(seen.has(reference.identity))return [];
177
+ if(rootCache.has(reference.identity))return rootCache.get(reference.identity);
178
+ const parents=parts.filter(part=>part.api.identity===reference.identity);
179
+ if(!parents.length)return publicByIdentity.get(reference.identity)?.renderable?[publicByIdentity.get(reference.identity).name]:[];
180
+ const names=[...new Set(parents.flatMap(part=>roots(part.parent,new Set([...seen,reference.identity]))))];rootCache.set(reference.identity,names);return names;
181
+ }
182
+ function cyclic(reference,seen=new Set()) {
183
+ if(seen.has(reference.identity))return true;
184
+ if(cycleCache.has(reference.identity))return cycleCache.get(reference.identity);
185
+ const found=parts.filter(part=>part.api.identity===reference.identity).some(part=>cyclic(part.parent,new Set([...seen,reference.identity])));
186
+ cycleCache.set(reference.identity,found);return found;
187
+ }
188
+ for(const [index,entry]of parts.entries()) {
189
+ entry.rootNames=roots(entry.parent);
190
+ if(cyclic(entry.parent))report("Declarative parent relationships must be acyclic.",`declarativeParts.${index}.parent`);
191
+ if(!entry.rootNames.length)report("A declarative parent must reach a real public rendering API through registered parent relationships.",`declarativeParts.${index}.parent`);
192
+ }
174
193
  let behavior;
175
194
  if (data.behavior) {
176
195
  if(Object.hasOwn(data.behavior,"schemaVersion"))report("Behavior inherits the owner contract's schemaVersion; remove the competing nested version.","behavior.schemaVersion");
@@ -179,7 +198,7 @@ export function inspectUnitContracts(options) {
179
198
  if (subject?.api && identities.has(subject.api)) return [name, { api: apiName(subject.api, `behavior.subjects.${name}.api`) ?? "" }];
180
199
  if (subject?.implementation && identities.has(subject.implementation)) {
181
200
  implementation(subject.implementation, `behavior.subjects.${name}.implementation`);
182
- return [name, { source: `./${slash(path.relative(path.dirname(file), path.resolve(options.root, subject.implementation.source)))}`, symbol: subject.implementation.symbol }];
201
+ return [name, { source: `./${slash(path.relative(path.dirname(file), path.resolve(options.root, subject.implementation.source)))}`, symbol: subject.implementation.symbol, ...(subject.role!==undefined?{role:subject.role}:{}) }];
183
202
  }
184
203
  report("Behavior subjects must use an actual public api or owner-local implementation symbol.", `behavior.subjects.${name}`);
185
204
  return [name, subject];
@@ -17,6 +17,8 @@ function auditPaintBindings({ container = document.getElementById("root"), bindi
17
17
  const resolved = view.getComputedStyle(node).getPropertyValue(name).trim();
18
18
  return !!resolved && view.CSS.supports("color", resolved);
19
19
  }
20
+ const themed = /^light-dark\(\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*\)$/.exec(value);
21
+ if (themed) return view.CSS.supports("color", value) && reference(themed[1], node, descriptor, seen) && reference(themed[2], node, descriptor, seen);
20
22
  const resource = /^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(value);
21
23
  if (resource && view.CSS.supports("fill", value)) {
22
24
  const candidates = [...document2.querySelectorAll("[id]")].filter((item) => item.id === resource[2]);
@@ -591,6 +591,11 @@ Owner-local tooling declarations use optional `<Owner>.ads.contract.ts` modules.
591
591
  ADS resolves their data and implementation symbols statically without executing
592
592
  project imports. Tokens and behavior share this contract with constrained paint
593
593
  inputs, instance binding families and declarative parent/consumer relationships.
594
+ Declarative relationships form an acyclic graph: parts may have several parents
595
+ and contain nested parts, with every chain anchored at a rendering root. Exercise
596
+ metadata records reachable use; registered browser checks establish its effects.
597
+ Binding producers declare each direct/derived paint path explicitly. Private
598
+ visual implementation subjects are distinct from headless controller subjects.
594
599
  Legacy JSON sections remain supported; duplicate policies fail. The
595
600
  [contract reference](CONTRACTS.md) specifies the authoring and analysis limits.
596
601
 
package/docs/BEHAVIORS.md CHANGED
@@ -80,6 +80,14 @@ subjects and checks. Each check names an owner-local test/spec file, stable case
80
80
  ID, registered profile and optional discovered scenario. Several guarantees may
81
81
  reference one check. Repeated execution identities use the same check ID.
82
82
 
83
+ Private subjects default to the headless controller role. For an intentionally
84
+ visual internal renderer or binding producer, declare `role: "implementation"`
85
+ alongside its `implementation` reference in the TypeScript contract (or its
86
+ `source`/`symbol` in legacy JSON). Its source ownership and normal runtime gates
87
+ still apply; registration does not make it public API. Shared `controllers/`
88
+ source remains headless regardless of subject metadata. See the
89
+ [owner contract](CONTRACTS.md#a-contract-uses-actual-implementation-references).
90
+
83
91
  Static validation establishes registration and ownership, not that the guarantee
84
92
  is true. README prose is not automatically certified. Link specific guarantees
85
93
  when describing the evidence available for a behavior.
package/docs/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.3.25
6
+
7
+ - Support source-proven shared/nested declarative parts, with acyclic parent
8
+ graphs anchored to rendering roots and bounded multi-relationship discovery.
9
+ - Trace recursive child flattening, selections, props records, mapped fixtures
10
+ and repeated review layout instances without changing render coverage.
11
+ - Prove derived theme binding maps from explicit constrained `valueFrom` paths;
12
+ retain key/map/scope checks and current browser paint audits.
13
+ - Distinguish private visual behavior subjects with explicit implementation roles
14
+ while preserving headless defaults, shared-controller gates and migration.
15
+
16
+ ## 0.3.24
17
+
18
+ - Audit derived `light-dark()` bindings when both branches are accessible
19
+ constrained color references; verify both schemes without allowing raw colors.
20
+
21
+ - Defer showcase build notifications until initial discovery completes, preventing
22
+ false missing-App-tool startup failures in candidate verification.
23
+ - Allow a bounded, explicit `mcp.mutationCheckTimeoutMs` for registered project
24
+ scripts; retain the 60-second default and report command/budget/elapsed time.
25
+
5
26
  ## 0.3.23
6
27
 
7
28
  - Preserve directory ownership when its last legacy composition/scenario entries
package/docs/CONTRACTS.md CHANGED
@@ -75,7 +75,7 @@ export default {
75
75
  { api: Series, parent: Plot, consumer: Renderer, checks: ["isolation"] },
76
76
  ],
77
77
  behavior: {
78
- subjects: { plot: { api: Plot }, renderer: { implementation: Renderer } },
78
+ subjects: { plot: { api: Plot }, renderer: { implementation: Renderer, role: "implementation" } },
79
79
  guarantees: [{
80
80
  id: "scoped-output",
81
81
  description: "Changing either instance updates only its own output.",
@@ -97,7 +97,13 @@ Symbol references resolve through normal imports, aliases and re-exports.
97
97
  Calls, getters, methods, computed metadata and environment-dependent expressions
98
98
  are rejected. Function references are opaque identities, never executed.
99
99
  Private implementation subjects may be internal module exports without becoming
100
- public barrel exports. Producers/consumers must belong to the same owner. Required
100
+ public barrel exports. Private subjects default to the existing headless controller
101
+ contract. Use `role: "controller"` explicitly for behavior-only code, or
102
+ `role: "implementation"` for a private visual renderer or binding producer whose
103
+ guarantees should be tracked without classifying it as a controller. Shared
104
+ `controllers/` source always remains headless. An implementation role retains
105
+ normal ownership, dependency, styling and development boundaries; it is not a
106
+ style exception. Producers/consumers must belong to the same owner. Required
101
107
  checks must exist, back named guarantees and use a browser profile with the
102
108
  corresponding scenario. A relationship is registration, not a passing guarantee.
103
109
 
@@ -145,6 +151,19 @@ it does not authorize arbitrary inline styling, CSSProperties APIs or bulk write
145
151
  Unsupported dynamic producers/attachment paths fail with an analysis diagnostic.
146
152
  Keep the implementation project-owned; there is no required ADS binding helper.
147
153
 
154
+ A producer with alternative/derived sources declares each entry path, for example:
155
+
156
+ ```ts
157
+ valueFrom: ["paint", "scheme.day", "scheme.night"],
158
+ ```
159
+
160
+ Register each matching `config.*.<path>` in `paintInputs`. The producer may write
161
+ one declared field, or an exact `light-dark(${entry.scheme.day}, ${entry.scheme.night})`
162
+ template over two declared fields. The normal key/map/root proof still applies.
163
+ Raw constants, undeclared fields, extra writes and unknown transforms are rejected.
164
+ The browser audit checks actual accessible color references in both branches;
165
+ a local SVG URL or `none` is not a CSS color inside `light-dark()`.
166
+
148
167
  Families cannot overlap shared tokens, owner-token namespaces, private runtime
149
168
  prefixes or other bindings. A broad family such as `--color-${key}` grants no
150
169
  shared-token exception. Use a distinct private family where collision freedom
@@ -152,6 +171,13 @@ cannot be established. Registered paint consumers list their allowed binding IDs
152
171
  borrowing a peer's family or private token remains invalid. Bindings are scoped
153
172
  to their actual root; portals outside it need deliberate project integration.
154
173
 
174
+ A registered binding producer may combine two accessible color references as
175
+ `light-dark(var(--light-token), var(--dark-token))`. The App paint audit checks
176
+ both branches and their observed effect in the active color scheme. Raw colors,
177
+ unknown/private tokens and SVG URLs inside this color function remain invalid.
178
+ This derived binding form does not widen public paint-input types; use constrained
179
+ references for each theme input and verify both color schemes in browser checks.
180
+
155
181
  The App audit checks current mounted instances, accessible values, local SVG
156
182
  resources and computed paint-property responses. Visibility and complete rendered
157
183
  output still need assertions in the registered browser checks. It rejects missing/duplicate IDs and reports unobserved written values separately. It is bounded to 100 families, 20 instances per family, 100 keys
@@ -177,9 +203,30 @@ export const scenario = {
177
203
  };
178
204
  ```
179
205
 
180
- The real part must reach its registered consumer through a rendered parent.
206
+ A part may register several distinct parents; each API/parent pair has one
207
+ consumer/check declaration. A parent may itself be a registered declarative part.
208
+ The graph must be acyclic and every parent chain must reach a public rendering
209
+ root. Duplicate pairs, cycles and detached part graphs fail.
210
+
211
+ For example, `Entry` can belong to `FirstView` and `SecondView`, while `Detail`
212
+ belongs to `Entry`. The scenario covers the rendering roots and exercises both
213
+ `Entry` and `Detail`. A nested `Detail` outside its registered parent does not count.
214
+
215
+ The real part must reach its registered consumer through a rendering parent.
181
216
  ADS resolves source identity comparisons (`child.type === Series`, including a
182
217
  traceable comparison helper) and reads of that same child’s props traced from the consumer’s children input.
218
+ Traceable paths include local recursive fragment flattening, `find`/`filter`,
219
+ callback aliases and props carried through local records. Reusing a review layout
220
+ inside another instance of itself is ordinary component composition, not a
221
+ recursive helper call. Source sites/work limits still bound analysis.
222
+
223
+ `exercises` establishes reachable behavioral use, including a conditional state
224
+ and mapped literal fixture data; it does not promise unconditional initial DOM.
225
+ Always-false branches, unused adapters, empty/unknown fixture maps and broken
226
+ parent chains grant no credit. `covers` retains its rendering contract. Required
227
+ browser checks cover a rendering root and exercise the relevant parent/child
228
+ chain, then verify adding/removing/updating the part changes actual output.
229
+
183
230
  A comparison against a decoy object gives no evidence. An import, unrelated parent, unused
184
231
  child or metadata claim gives no consumption credit. Unknown render branches are
185
232
  conservative. Browser checks must verify that adding/removing/changing the part
package/docs/GUIDE.md CHANGED
@@ -403,7 +403,9 @@ input/configuration or execution errors.
403
403
 
404
404
  Guarded MCP editing is opt-in. Its mandatory checks and optional project
405
405
  `mcp.mutationChecks` scripts run in a temporary project copy with installed
406
- dependencies. See the [editing contract](MCP.md#guarded-editing) for unit ownership,
406
+ dependencies. Project scripts default to 60 seconds each; use the explicit
407
+ `mcp.mutationCheckTimeoutMs` budget (100–300000 ms) for measured slower builds.
408
+ Behavior profiles have a separate whole-run budget. See the [editing contract](MCP.md#guarded-editing) for unit ownership,
407
409
  Git patches, bounded reads and preview review. Keep normal build gates enabled
408
410
  for edits made by other tools.
409
411
 
package/docs/MCP.md CHANGED
@@ -547,7 +547,7 @@ rules, including warnings. By default it also runs available `lint:project`
547
547
  additional list through project-owned configuration:
548
548
 
549
549
  ```json
550
- { "mcp": { "mutationChecks": ["lint", "typecheck", "build:mcp-previews"] } }
550
+ { "mcp": { "mutationChecks": ["lint", "typecheck", "build:mcp-previews"], "mutationCheckTimeoutMs": 120000 } }
551
551
  ```
552
552
 
553
553
  Every listed script must exist. An empty list still runs mandatory ADS and Oxlint
@@ -557,8 +557,11 @@ sandbox. An explicit `configuration` patch can change project commands, register
557
557
  rules and reviewed exceptions; validation runs the proposed configuration and
558
558
  scripts. Mandatory core and generated Oxlint checks still run on every write.
559
559
  Configuration changes cannot bundle unrelated component edits. Checks that
560
- rewrite source are rejected. Each command has a 60-second limit; the diagnostic
561
- explorer allows up to 15 minutes for the complete request.
560
+ rewrite source are rejected. Each registered project script defaults to a
561
+ 60-second limit. `mcp.mutationCheckTimeoutMs` sets its explicit budget
562
+ (100–300000 ms); it does not change mandatory gates or behavior-profile budgets.
563
+ Timeout diagnostics identify the command, configured budget and elapsed time.
564
+ The diagnostic explorer allows up to 15 minutes for the complete request.
562
565
 
563
566
  Ordinary source and asset files owned by the selected unit are editable. Generated
564
567
  outputs, dependency directories, Git metadata and symlink/hardlink targets are
@@ -1074,7 +1077,9 @@ Tool updates do not overwrite existing project-owned scenarios or renderers.
1074
1077
 
1075
1078
  `ads_units` includes `contractFile` for a single `<Owner>.ads.contract.ts`.
1076
1079
  `ads_catalog` identifies declarative APIs and their parent/consumer/check links,
1077
- and registered constrained paint-input paths. Read the relevant source range;
1080
+ and registered constrained paint-input paths. Declarative summaries include
1081
+ `consumerCount` and up to four `consumers`, with their rendering roots; read the
1082
+ contract source for additional relationships. Read the relevant source range;
1078
1083
  these summaries establish registration, not completed verification. Detailed
1079
1084
  results remain bounded and paged.
1080
1085
 
@@ -1084,3 +1089,17 @@ then use the existing diff and guarded dry-run/apply workflow. It does not write
1084
1089
  live source, loosen policy or add a second contract-editing protocol. See
1085
1090
  [CONTRACTS.md](CONTRACTS.md) for the static schema, compatibility and browser audits.
1086
1091
  The same guide is available at `ads://guides/contracts`.
1092
+
1093
+ A registered binding producer may combine two accessible color references as
1094
+ `light-dark(var(--light-token), var(--dark-token))`. The App paint audit checks
1095
+ both branches and their observed effect in the active color scheme. Raw colors,
1096
+ unknown/private tokens and SVG URLs inside this color function remain invalid.
1097
+ This derived binding form does not widen public paint-input types; use constrained
1098
+ references for each theme input and verify both color schemes in browser checks.
1099
+
1100
+ Binding `valueFrom` accepts one path or an explicit array of registered entry
1101
+ paths for alternative/theme paints. Parts can have multiple distinct parents and
1102
+ registered nested parents, anchored at rendering roots. `exercises` records
1103
+ reachable use; registered browser checks establish the effects. Private visual
1104
+ behavior subjects use explicit `role: "implementation"`; headless defaults and
1105
+ shared-controller gates remain enabled. See [CONTRACTS.md](CONTRACTS.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/ads",
3
- "version": "0.3.23",
3
+ "version": "0.3.25",
4
4
  "type": "module",
5
5
  "description": "A design system your agent can see and shape. Your components. Your look. Your code.",
6
6
  "repository": {