Skip to content

Commit ae7fa51

Browse files
committed
fix(lint): name the fifth closure limb in the docs, the six rules in the changeset, and pin the door's 422
Claude-Session: https://claude.ai/code/session_01Utp6CZYtWqXwEewuPdKQAJ Co-authored-by: Claude <noreply@anthropic.com>
1 parent b37c73d commit ae7fa51

3 files changed

Lines changed: 104 additions & 1 deletion

File tree

‎.changeset/30005-cross-closure-dataset-filter-keys.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ fix(lint)!: under a package closure, a dashboard widget `filter` or report `runt
66

77
Clause-②: no (narrowing) — the runtime publish door, for a write that names its package, refuses a dashboard widget `filter` key or a report `runtimeFilter` key on a dataset outside the package's closure when the dataset's object has no such field, a body it accepted before. Nothing is widened: `narrowObjectsToPackageClosure` keeps its signature and its four-limb answer, and no export is added to any package entry.
88
Metadata-protocol: narrowed
9-
Skills-docs: none in `skills/**`, which teaches neither rule nor the closure. `content/docs/deployment/validating-metadata.mdx` names the closure's four limbs and does not yet say that a dashboard or report write also carries the base objects of the datasets it binds; that page is outside this change and is reported to the owning seat. The rules' `os explain` entries are unchanged and still describe the verdict.
9+
Skills-docs: updated here — `content/docs/deployment/validating-metadata.mdx` (the fourth-door paragraph) now names the fifth closure limb for dashboard and report writes; `skills/**` teaches neither the rules nor the closure.
1010

1111
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed or renamed: DashboardWidgetSchema.filter and ReportSchema.runtimeFilter keep their shape and meaning, and a dataset outside the closure now gets the verdict a dataset inside it already got. A refused key never served the board or the report (every reader saw an empty tile or a Dataset query failed panel), so there is no rewrite that keeps what the author meant; the author names a real field, and the refusal says which. -->
1212

1313
**BREAKING** accept-set narrowing at the runtime publish door for `dashboard` and `report` writes (the per-item publish and the package draft publish; Studio, REST and MCP authors), for a write whose package is known. `os validate`, `os build` and `os lint` are unchanged: they never narrow to a closure.
1414

1515
- **Before.** The publish gate narrows the live `objects` to the written package's closure (the package, its declared dependencies, platform objects, rows with no package) but carries every dataset. A runtime package's dashboard on `showcase_task_metrics`, a dataset the showcase package ships over `showcase_task`, therefore found the dataset but not its object, and `widget-filter-field-unknown` and `report-filter-field-unknown` skipped the filter as "object not in this snapshot". `filter: { no_such_field: 'x' }` published `200`, and every reader saw an empty tile or an error panel.
1616
- **Now.** A dashboard or report write also carries the base object of each dataset it binds (`widgets[].dataset`; a report's `dataset` and each joined block's `dataset`), which is the object the dataset query resolves the filter against at run time. The same key is refused `422 INVALID_METADATA` at `dashboards[0].widgets[0].filter.no_such_field` (or `reports[0].runtimeFilter.no_such_field`), the verdict the same key already got on a dataset inside the closure or with no closure in force.
17+
- **Which rules now judge such a dataset.** Every rule that resolves a dashboard's or report's filter against the dataset's object, all six already judging datasets inside the closure: `widget-filter-field-unknown`, `widget-filter-field-not-included`, `dashboard-filter-field-unknown`, `dashboard-filter-field-not-included`, `dashboard-filter-field-unprovisioned` and `report-filter-field-unknown`.
18+
- **A dimension name as a widget filter key.** On a dataset outside the closure, a widget `filter` key that names a dimension of the dataset but no field of its object is now refused with `widget-filter-field-unknown`, as it already was on a dataset inside the closure. The dataset query binds such a key; the correction of that verdict, for both cases, is tracked in #30006.
1719
- **Accepted, as before.** Every key the object has, a registry-injected system column, a dotted relationship path, every `$` operator. A dotted key whose hop lands on an object the snapshot still does not carry is not judged.
1820
- **Not changed.** Only dashboard and report writes carry the extra objects. A flow trigger, a list view or a dataset base object outside the closure is still refused as before (`flow-trigger-unknown-object`, `list-view-object-outside-closure`, `object-reference-unknown`), and a list view's `chart.dataset` brings no object in.
1921

‎content/docs/deployment/validating-metadata.mdx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,12 @@ findings the item **added** (#4463). Its package dimension narrows that context
737737
the written item's **package closure** — the written package, its declared
738738
dependencies, and unconditionally both platform/system objects and rows carrying
739739
no package provenance (#9612); a provenance it cannot read narrows nothing at all.
740+
A dashboard or report write also keeps the base object of each dataset it binds
741+
(a widget's `dataset`; a report's `dataset` and each joined block's), because the
742+
datasets are never narrowed and the dataset query resolves a filter against that
743+
object whichever package ships it: a filter key the object lacks is refused there
744+
just as it is on a dataset inside the closure (#30005). No other write type keeps
745+
it, so a flow or a list view never reaches an outside object through a dataset.
740746
That changes what a rule can **resolve**, never which rules run, and nothing at
741747
this door walks `packages[]`. Two rules are told the closure is in force. A flow
742748
whose trigger object is outside it is refused with `flow-trigger-unknown-object`

‎packages/metadata-protocol/src/protocol.dashboard-dataset-publish-gate.test.ts‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,101 @@ describe('#29900 — a report `runtimeFilter` key resolves at the publish door',
487487
});
488488
});
489489

490+
// ─────────────────────────────────────────────────────────────────────────────
491+
// #30005 — another package's dataset, under the written package's closure
492+
// ─────────────────────────────────────────────────────────────────────────────
493+
//
494+
// The filer's reproduction at the door: a runtime package (`app.runtime`, which
495+
// declares no dependency on the showcase) saves a dashboard on
496+
// `showcase_task_metrics`, a dataset the showcase package ships over its own
497+
// `showcase_task`. The write names its package, so the gate narrows `objects`
498+
// to that package's closure; `datasets` stays whole. Before the fix the dataset
499+
// resolved, its object did not, and the misspelled key saved `200`.
500+
501+
const RUNTIME_PKG = 'app.runtime';
502+
503+
/** The harness, with a showcase-stamped object and dataset and an installed runtime package. */
504+
function makeClosureProtocol() {
505+
const { engine, rows } = makeStubEngine();
506+
const realListItems = engine.registry.listItems;
507+
engine.registry.listItems = (type: string) => {
508+
if (type === 'object') {
509+
return [
510+
...realListItems('object'),
511+
{
512+
name: 'showcase_task',
513+
_packageId: 'com.example.showcase',
514+
fields: [
515+
{ name: 'name', type: 'text' },
516+
{ name: 'status', type: 'text' },
517+
],
518+
},
519+
];
520+
}
521+
if (type === 'dataset') {
522+
return [
523+
...realListItems('dataset'),
524+
{
525+
name: 'showcase_task_metrics',
526+
object: 'showcase_task',
527+
_packageId: 'com.example.showcase',
528+
dimensions: [{ name: 'status', field: 'status' }],
529+
measures: [{ name: 'task_count', aggregate: 'count' }],
530+
},
531+
];
532+
}
533+
return realListItems(type);
534+
};
535+
// The written package is installed and declares no dependencies, so its
536+
// closure is itself plus platform and unpackaged rows.
537+
(engine.registry as any).getPackage = (id: string) =>
538+
id === RUNTIME_PKG ? { manifest: { id: RUNTIME_PKG } } : undefined;
539+
const protocol: any = new ObjectStackProtocolImplementation(engine, () => new Map(), 'env_test');
540+
return { protocol, rows };
541+
}
542+
543+
const crossPackageBoard = (filter: Record<string, unknown>) => ({
544+
name: 'runtime_ops_board',
545+
label: 'Runtime Ops',
546+
widgets: [
547+
{ id: 'tasks', type: 'metric', title: 'Tasks', dataset: 'showcase_task_metrics', values: ['task_count'], filter },
548+
],
549+
});
550+
551+
describe('#30005 — a filter key on another package\'s dataset, under the written package\'s closure', () => {
552+
let warn: ReturnType<typeof vi.spyOn>;
553+
beforeEach(() => {
554+
warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
555+
delete process.env.OS_ALLOW_UNLINTED_METADATA_WRITES;
556+
});
557+
afterEach(() => {
558+
warn.mockRestore();
559+
delete process.env.OS_ALLOW_UNLINTED_METADATA_WRITES;
560+
});
561+
562+
it('the filer\'s repro: the save is REFUSED 422 INVALID_METADATA at the widget path, and nothing is stored', async () => {
563+
const { protocol, rows } = makeClosureProtocol();
564+
const err = await protocol
565+
.saveMetaItem({ type: 'dashboard', name: 'runtime_ops_board', item: crossPackageBoard({ no_such_field: 'x' }), packageId: RUNTIME_PKG })
566+
.then(() => null, (e: any) => e);
567+
expect({ status: err?.status, code: err?.code }).toEqual({ status: 422, code: 'INVALID_METADATA' });
568+
expect(err.issues.map((i: any) => [i.rule, i.path])).toContainEqual([
569+
'widget-filter-field-unknown',
570+
'dashboards[0].widgets[0].filter.no_such_field',
571+
]);
572+
expect(dashboardRows(rows).filter((r) => r.state === 'active')).toEqual([]);
573+
});
574+
575+
it('CONTROL — a key the dataset\'s object has saves under the same closure', async () => {
576+
const { protocol, rows } = makeClosureProtocol();
577+
const saved = await protocol.saveMetaItem({
578+
type: 'dashboard', name: 'runtime_ops_board', item: crossPackageBoard({ status: 'done' }), packageId: RUNTIME_PKG,
579+
});
580+
expect(saved.success, JSON.stringify(saved?.issues ?? saved)).toBe(true);
581+
expect(dashboardRows(rows).map((r) => r.state)).toContain('active');
582+
});
583+
});
584+
490585
// ─────────────────────────────────────────────────────────────────────────────
491586
// #16225 — the stub answers the table it was asked about, and only that one
492587
// ─────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)