Skip to content

Commit 806dd06

Browse files
committed
test(lint): pin each tie-dropping type arm on its own
Each tied pair now lists the definition the arm would refuse last, which is the one the fold keeps, so every arm that read it instead of dropping the tie goes red. Adds the widget field-type map and the kanban option map, and says in the RLS rule and above the helpers how a tie is read. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg3UmwhpAtL969c7YG
1 parent a7e0819 commit 806dd06

3 files changed

Lines changed: 45 additions & 8 deletions

File tree

‎packages/lint/src/object-graph.test.ts‎

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { walkFilterFieldKeys, type FilterFieldKey } from './filter-walk.js';
2323
import { DATASET_FIELD_UNKNOWN, validateDatasetReferences } from './validate-dataset-references.js';
2424
import { MEASURE_AGGREGATE_FIELD_TYPE_REFUSED, validateDatasetMeasureAggregates } from './validate-dataset-measure-aggregates.js';
2525
import { FIELD_NO_CONSUMERS, validateFieldConsumers } from './validate-field-consumers.js';
26-
import { LIST_VIEW_FIELD_UNKNOWN, validateListViewFieldRefs } from './validate-list-view-field-refs.js';
26+
import { LIST_VIEW_FIELD_UNKNOWN, LIST_VIEW_KANBAN_LANE_UNKNOWN, validateListViewFieldRefs } from './validate-list-view-field-refs.js';
2727
import { MAPPING_TARGET_FIELD_UNKNOWN, validateMappingTargetFields } from './validate-mapping-target-fields.js';
2828
import { OBJECT_FIELD_REF_UNKNOWN, validateObjectFieldRefs } from './validate-object-field-refs.js';
2929
import { PAGE_FIELD_UNKNOWN, validatePageFieldBindings } from './validate-page-field-bindings.js';
@@ -33,7 +33,7 @@ import { REPORT_FILTER_FIELD_UNKNOWN, validateReportRuntimeFilters } from './val
3333
import { RLS_PREDICATE_UNKNOWN_FIELD, validateRlsPredicateEnforceability } from './validate-rls-predicate-enforceability.js';
3434
import { SHARING_RULE_UNLOWERABLE_CONDITION, validateSharingRuleEnforceability } from './validate-sharing-rule-enforceability.js';
3535
import { THANK_YOU_RECORD_FIELD, validateThankYouRecordFields } from './validate-thank-you-record-fields.js';
36-
import { WIDGET_FILTER_FIELD_UNKNOWN, validateWidgetBindings } from './validate-widget-bindings.js';
36+
import { MEASURE_AGGREGATE_INCOHERENT, WIDGET_FILTER_FIELD_UNKNOWN, validateWidgetBindings } from './validate-widget-bindings.js';
3737
// [#16340] Read back the registry's OWN definition table to assert the graph
3838
// derives its injected types rather than carrying a second copy of them.
3939
import { injectedSystemColumnDefs } from '@objectstack/spec/data';
@@ -737,22 +737,52 @@ describe('[#30383] the field-path rules read the objects as served', () => {
737737
{ manifest: { id: 'mod2', objectExtensions: [{ extend: 'xs_deal', fields: b }] } },
738738
],
739739
});
740+
// The fold keeps the LAST writer at a tied priority, so each pair below
741+
// lists the definition a type arm would refuse last: an arm that read the
742+
// kept definition instead of dropping the tie goes red.
740743
const numberOrText = (extra: Rec) => ({ ...tie({ score: { type: 'number' } }, { score: { type: 'text' } }), ...extra });
741-
const dateOrText = (extra: Rec) => ({ ...tie({ closed_on: { type: 'date' } }, { closed_on: { type: 'text' } }), ...extra });
744+
const textOrDate = (extra: Rec) => ({ ...tie({ closed_on: { type: 'text' } }, { closed_on: { type: 'date' } }), ...extra });
745+
const numberOrPercent = (extra: Rec) => ({ ...tie({ score: { type: 'number' } }, { score: { type: 'percent' } }), ...extra });
746+
const stage = (values: string[]) => ({ stage: { type: 'select', options: values.map((value) => ({ value, label: value })) } });
747+
const abOrAc = (extra: Rec) => ({ ...tie(stage(['a', 'b']), stage(['a', 'c'])), ...extra });
742748

743749
it('is still a served name for the existence rules', () => {
744750
expect(ids(validateDatasetReferences, numberOrText({ datasets: [{ ...dataset('score'), include: [] }] }))).toEqual([]);
745751
expect(ids(validateDatasetReferences, numberOrText({ datasets: [{ ...dataset('zq_absent'), include: [] }] }))).toEqual([DATASET_FIELD_UNKNOWN]);
746752
});
747753

748-
it('is not judged on its type by the type arms', () => {
754+
it('is not judged on its type by measure aggregates', () => {
749755
const sum = { datasets: [{ name: 'deals', object: 'xs_deal', measures: [{ name: 's', aggregate: 'sum', field: 'score' }] }] };
750756
expect(ids(validateDatasetMeasureAggregates, numberOrText(sum))).toEqual([]);
751757
expect(ids(validateDatasetMeasureAggregates, { ...tie({ score: { type: 'text' } }, {}), ...sum }))
752758
.toEqual([MEASURE_AGGREGATE_FIELD_TYPE_REFUSED]);
753-
expect(ids(validatePresetComparands, dateOrText(widget({ closed_on: 'last_30_days' })))).toEqual([]);
759+
});
760+
761+
it('is not judged on its type by preset comparands', () => {
762+
const preset = widget({ closed_on: 'last_30_days' });
763+
expect(ids(validatePresetComparands, textOrDate(preset))).toEqual([]);
764+
expect(ids(validatePresetComparands, { ...tie({ closed_on: { type: 'date' } }, {}), ...preset })).toEqual([FILTER_PRESET_COMPARAND]);
765+
});
766+
767+
it('is not judged on its type by sharing-rule criteria', () => {
754768
const rule = { sharingRules: [{ name: 'sr', object: 'xs_deal', condition: 'record.closed_on == record.name', sharedWith: { type: 'role', value: 'r' }, accessLevel: 'read' }] };
755-
expect(ids(validateSharingRuleEnforceability, dateOrText(rule))).toEqual([]);
769+
expect(ids(validateSharingRuleEnforceability, textOrDate(rule))).toEqual([]);
770+
expect(ids(validateSharingRuleEnforceability, { ...tie({ closed_on: { type: 'date' } }, {}), ...rule }))
771+
.toEqual([SHARING_RULE_UNLOWERABLE_CONDITION]);
772+
});
773+
774+
it('is not judged on its type by the widget field-type map', () => {
775+
const sum = { datasets: [{ name: 'deals', object: 'xs_deal', measures: [{ name: 's', aggregate: 'sum', field: 'score' }] }] };
776+
expect(ids(validateWidgetBindings, numberOrPercent(sum))).toEqual([]);
777+
expect(ids(validateWidgetBindings, { ...tie({ score: { type: 'percent' } }, {}), ...sum })).toEqual([MEASURE_AGGREGATE_INCOHERENT]);
778+
});
779+
780+
it('lends no options to a kanban lane check', () => {
781+
const lanes = {
782+
views: [{ name: 'v', object: 'xs_deal', list: { type: 'kanban', columns: ['name'], kanban: { groupByField: 'stage', columns: ['name'], lanes: ['b'] } } }],
783+
};
784+
expect(ids(validateListViewFieldRefs, abOrAc(lanes))).toEqual([]);
785+
expect(ids(validateListViewFieldRefs, { ...tie(stage(['a', 'c']), {}), ...lanes })).toEqual([LIST_VIEW_KANBAN_LANE_UNKNOWN]);
756786
});
757787

758788
it('is admitted on a thank-you panel only when every tied definition is engine-generated', () => {

‎packages/lint/src/object-graph.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,11 @@ export function listNames(names: Iterable<string>): string {
793793
return arr.length > 0 ? arr.join(', ') : '(none)';
794794
}
795795

796-
// [#30383] Kept out of the fold's section on purpose: `validate-security-posture.test.ts`
797-
// tables every receiver read in that section, and these two read only the fold's output.
796+
// [#30383] Kept below the fold's section on purpose: `foldCode()` in
797+
// `validate-security-posture.test.ts` appends this file's text from
798+
// `export interface VisibleObjectExtension` to `/** What a path resolved to` to
799+
// the posture rule's code and holds every receiver read there to its tables;
800+
// these two read only the fold's output.
798801

799802
/**
800803
* [#30383] The served objects with every `tied` field taken out: what a rule

‎packages/lint/src/validate-rls-predicate-enforceability.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,10 @@ export function validateRlsPredicateEnforceability(
19131913
// re-derived here. [#30383] It indexes the objects as SERVED: the registry
19141914
// folds every `objectExtensions` field in before the RLS compiler sees the
19151915
// object, so a predicate naming a field a sibling package adds resolves.
1916+
// A field two packages write at the same deciding priority (`objectsAsServed`'s
1917+
// `tied`) is kept as the fold keeps it, the last writer: its list-holding and
1918+
// cross-class questions are answered on that definition, although which one
1919+
// the registry serves is its registration order.
19161920
const graph: ObjectGraph = indexServedObjectGraph(cfg);
19171921
// [#25234] The declared membership keys every predicate below is judged
19181922
// against: bound as lists, traced to their targets — see `## Membership keys`.

0 commit comments

Comments
 (0)