Skip to content

Commit cbf245c

Browse files
authored
🧪 Add network-local reduction parity fixtures (#1734)
Adds two schema-validation fixtures that pin sphinx-needs' behaviour for a network-context `local` schema using `unevaluatedProperties`, to serve as the parity oracle for the ubcode port. - **`network_local_unevaluated_reduced_ok`** — a linked spec with no extra fields, reduced to just `{type: spec}`, validates cleanly. Confirms `_validate_need_local` applies `reduce_need` inside the network path exactly as for top-level local validation. - **`network_local_unevaluated_reduced_error`** — the linked spec sets an extra `asil` field the schema does not reference; reduction keeps actively-set extra fields, so `unevaluatedProperties: false` still fails. Confirms reduction does not mask real violations. No behaviour change — fixtures + snapshots only.
1 parent 7aeb1b5 commit cbf245c

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

‎tests/schema/__snapshots__/test_schema.ambr‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5090,6 +5090,48 @@
50905090
}),
50915091
})
50925092
# ---
5093+
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error]
5094+
'''
5095+
ERROR: Need 'SPEC_1' has schema violations:
5096+
Severity: violation
5097+
Need path: IMPL_1 > links > SPEC_1
5098+
Schema path: [0] > validate > network > links > items > local > unevaluatedProperties
5099+
Schema message: Unevaluated properties are not allowed ('asil' was unexpected) [sn_schema_violation.network_local_fail]
5100+
5101+
'''
5102+
# ---
5103+
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_error].1
5104+
dict({
5105+
'validated_needs_count': 2,
5106+
'validation_warnings': dict({
5107+
'IMPL_1': list([
5108+
dict({
5109+
'children': list([
5110+
]),
5111+
'details': dict({
5112+
'need_path': 'IMPL_1 > links > SPEC_1',
5113+
'schema_path': '[0] > validate > network > links > items > local > unevaluatedProperties',
5114+
'severity': 'violation',
5115+
'validation_msg': "Unevaluated properties are not allowed ('asil' was unexpected)",
5116+
}),
5117+
'log_lvl': 'error',
5118+
'subtype': 'network_local_fail',
5119+
'type': 'sn_schema_violation',
5120+
}),
5121+
]),
5122+
}),
5123+
})
5124+
# ---
5125+
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok]
5126+
''
5127+
# ---
5128+
# name: test_schemas[schema/fixtures/network-network_local_unevaluated_reduced_ok].1
5129+
dict({
5130+
'validated_needs_count': 2,
5131+
'validation_warnings': dict({
5132+
}),
5133+
})
5134+
# ---
50935135
# name: test_schemas[schema/fixtures/network-no_error_empty_links]
50945136
'''
50955137
ERROR: Need 'IMPL_SAFE' has schema violations:

‎tests/schema/fixtures/network.yml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,76 @@ max_network_levels:
627627
type:
628628
const: spec
629629

630+
network_local_unevaluated_reduced_ok:
631+
# The network-local schema uses ``unevaluatedProperties``, whose semantics are only
632+
# meaningful after ``reduce_need()`` strips the fields the schema does not reference.
633+
# SN applies that same reduction inside the network path (``_validate_need_local``)
634+
# as for top-level local validation, so the linked spec — reduced to just
635+
# ``{type: spec}`` — validates cleanly and ``items`` passes with no warning.
636+
conf: |
637+
extensions = ["sphinx_needs"]
638+
needs_from_toml = "ubproject.toml"
639+
needs_schema_definitions_from_json = "schemas.json"
640+
ubproject: |
641+
[needs.fields.asil]
642+
nullable = true
643+
rst: |
644+
.. spec:: title
645+
:id: SPEC_1
646+
647+
.. impl:: title
648+
:id: IMPL_1
649+
:links: SPEC_1
650+
schemas:
651+
$defs: []
652+
schemas:
653+
- select:
654+
properties:
655+
type: {const: "impl"}
656+
validate:
657+
network:
658+
links:
659+
items:
660+
local:
661+
properties:
662+
type: {const: spec}
663+
unevaluatedProperties: false
664+
665+
network_local_unevaluated_reduced_error:
666+
# Same as ``network_local_unevaluated_reduced_ok`` but the linked spec sets an extra
667+
# field (``asil``) that the network-local schema does not reference. ``reduce_need()``
668+
# keeps actively-set extra fields, so ``unevaluatedProperties: false`` still fails on
669+
# it — confirming reduction matches the top-level path without masking real violations.
670+
conf: |
671+
extensions = ["sphinx_needs"]
672+
needs_from_toml = "ubproject.toml"
673+
needs_schema_definitions_from_json = "schemas.json"
674+
ubproject: |
675+
[needs.fields.asil]
676+
nullable = true
677+
rst: |
678+
.. spec:: title
679+
:id: SPEC_1
680+
:asil: QM
681+
682+
.. impl:: title
683+
:id: IMPL_1
684+
:links: SPEC_1
685+
schemas:
686+
$defs: []
687+
schemas:
688+
- select:
689+
properties:
690+
type: {const: "impl"}
691+
validate:
692+
network:
693+
links:
694+
items:
695+
local:
696+
properties:
697+
type: {const: spec}
698+
unevaluatedProperties: false
699+
630700
link_name_contains:
631701
conf: |
632702
extensions = ["sphinx_needs"]

0 commit comments

Comments
 (0)