diff --git a/.changeset/35006-scenarios-acknowledged-rollup-charged.md b/.changeset/35006-scenarios-acknowledged-rollup-charged.md new file mode 100644 index 00000000000..05f9590e4bd --- /dev/null +++ b/.changeset/35006-scenarios-acknowledged-rollup-charged.md @@ -0,0 +1,10 @@ +--- +'@objectstack/scenarios': patch +--- + +docs(scenarios): an acknowledged roll-up finding on a child the card withholds is still charged + +Clause-②: no +Metadata-protocol: none + +The scenario runner's README now states how the scorer treats a `security-rollup-source-unreadable` finding the build acknowledged with `rollupSourceUnreadableReason`: it is charged as a failed Build check exactly like an unacknowledged one, whenever the card withholds the roll-up's child (or the child field it reads) from that persona. A written reason does not change what the persona sees, so a total the card withholds has to be masked, not explained. The scorer's behaviour does not change; a test now runs the real rule on acknowledged permission sets and pins that the runner reads the rule's suffixed `info` message on both of its readings (the child object and the child field) and charges every one. diff --git a/packages/qa/scenarios/README.md b/packages/qa/scenarios/README.md index 25ef5af16c4..11ceaccf3e4 100644 --- a/packages/qa/scenarios/README.md +++ b/packages/qa/scenarios/README.md @@ -682,7 +682,10 @@ npx @objectstack/scenarios help # the comma it may not see. Each charge is a failed Build check (in total, never in passed; `rollup-source-unreadable::` in the record's evidence) and a Build finding naming the persona, the roll-up and the withheld child, so such a build is never `pass` and is never installed as a verified build. A finding on a set no persona holds, on a child the card - lets the persona read, or the rule's `info` row-scope arm is not charged. The remedy is the rule's own: mask the + lets the persona read, or the rule's `info` row-scope arm is not charged. A finding the build acknowledged + (`rollupSourceUnreadableReason` on the set's entry for the roll-up, which turns the rule's finding to `info` and + suffixes its message with the reason) is still charged, in the same check: a written reason does not change what + the persona sees, and a total the card withholds is masked, never explained. The remedy is the rule's own: mask the parent summary on the set (`fields["."]: { readable: false }`). Ask mode authors nothing and is never charged. - **Persona contract**: the build is asked for one permission set per persona, named `_`. The runner diff --git a/packages/qa/scenarios/test/runner/orchestrate.test.ts b/packages/qa/scenarios/test/runner/orchestrate.test.ts index 6ae7e8fe339..42642032f20 100644 --- a/packages/qa/scenarios/test/runner/orchestrate.test.ts +++ b/packages/qa/scenarios/test/runner/orchestrate.test.ts @@ -1491,6 +1491,81 @@ describe('runCard — a standing security-rollup-source-unreadable on a child th }); }); +describe('rollupSourceCharges — an acknowledged roll-up over a child the card withholds is still charged (#35006, ruled on #33818)', () => { + const scenario = namespacedScenario(load(resolve(HERE, '../../../../../docs/qa/scenarios/project_with_tasks.json'))); + const p = (name: string) => `demoproject_${name}`; + const REASON = 'the total is meant to be visible'; + + /** + * project_with_tasks again: the card withholds `task` from client_viewer and + * `task.estimate_hours` from the contractor. Each set reads a roll-up over + * what the card withholds from it; `acknowledged` gives each roll-up column + * `rollupSourceUnreadableReason` on that set, which turns the rule's finding + * into its `info` arm with a suffixed message. Both readings of the runner + * meet that suffix: the object gate (client_viewer) and the field gate (the + * contractor). + */ + const artifact = (acknowledged: boolean) => { + const ack = (column: string) => (acknowledged ? { [column]: { rollupSourceUnreadableReason: REASON } } : {}); + return { + manifest: { id: 'com.example.demoproject', namespace: 'demoproject' }, + objects: [ + { + name: p('project'), + fields: { + name: { type: 'text' }, + task_count: { type: 'summary', summaryOperations: { object: p('task'), function: 'count' } }, + total_estimate: { type: 'summary', summaryOperations: { object: p('task'), function: 'sum', field: 'estimate_hours' } }, + }, + }, + { + name: p('task'), + fields: { title: { type: 'text' }, estimate_hours: { type: 'number' }, project: { type: 'lookup', reference: p('project') } }, + }, + ], + permissions: [ + { + name: p('contractor'), + objects: { [p('project')]: { allowRead: true }, [p('task')]: { allowRead: true } }, + fields: { + [`${p('task')}.estimate_hours`]: { readable: false }, + [`${p('project')}.task_count`]: { readable: false }, + ...ack(`${p('project')}.total_estimate`), + }, + }, + { + name: p('client_viewer'), + objects: { [p('project')]: { allowRead: true } }, + fields: { ...ack(`${p('project')}.task_count`), ...ack(`${p('project')}.total_estimate`) }, + }, + ], + }; + }; + + it('the rule reports the acknowledged findings at info with the suffixed message, and the runner reads and charges every one as it does unacknowledged', () => { + const built = artifact(true); + // The real rule, on the acknowledged sets: same rule id, the info arm, the reason's path, the suffix. + const standing = validateRollupSourceVisibility({ objects: built.objects, permissions: built.permissions }); + expect(standing.map((f) => [f.rule, f.severity, f.path])).toEqual([ + ['security-rollup-source-unreadable', 'info', `permissions[0].fields["${p('project')}.total_estimate"].rollupSourceUnreadableReason`], + ['security-rollup-source-unreadable', 'info', `permissions[1].fields["${p('project')}.task_count"].rollupSourceUnreadableReason`], + ['security-rollup-source-unreadable', 'info', `permissions[1].fields["${p('project')}.total_estimate"].rollupSourceUnreadableReason`], + ]); + for (const f of standing) expect(f.message).toMatch(/\. Acknowledged on the set: "the total is meant to be visible"$/); + + // The runner reads the suffixed message (it never throws) and charges each: a written reason does not change what the persona sees. + const charges = rollupSourceCharges(scenario, built); + expect(charges.map((c) => [c.persona, c.rollup, c.withheld, c.finding.path])).toEqual([ + ['contractor', p('project.total_estimate'), { field: p('task.estimate_hours') }, `permissions[0].fields["${p('project')}.total_estimate"].rollupSourceUnreadableReason`], + ['client_viewer', p('project.task_count'), { object: p('task') }, `permissions[1].fields["${p('project')}.task_count"].rollupSourceUnreadableReason`], + ['client_viewer', p('project.total_estimate'), { object: p('task') }, `permissions[1].fields["${p('project')}.total_estimate"].rollupSourceUnreadableReason`], + ]); + // Control: the same build without the reasons is charged for exactly the same roll-ups. + const strip = (cs: typeof charges) => cs.map((c) => [c.persona, c.rollup, c.child, c.withheld]); + expect(strip(charges)).toEqual(strip(rollupSourceCharges(scenario, artifact(false)))); + }); +}); + // ── The model each turn was served ────────────────────────────────────────── /**