Skip to content

Upgrade to Sphinx-Needs 8.x and classify new schema/link features#7

Merged
danwos merged 2 commits into
mainfrom
feat/sphinx-needs-8x-classification
May 4, 2026
Merged

Upgrade to Sphinx-Needs 8.x and classify new schema/link features#7
danwos merged 2 commits into
mainfrom
feat/sphinx-needs-8x-classification

Conversation

@patdhlk
Copy link
Copy Markdown
Collaborator

@patdhlk patdhlk commented Apr 20, 2026

Summary

  • Upgrade sphinx-needs to 8.x (>=8.0.0,<9) and migrate ubproject.toml off the deprecated SN 6.x config forms (extra_options list → [needs.fields.*], [[needs.extra_links]][needs.links.*], [needs.global_options.style][needs.fields.style]).
  • Extend the safety classification with the new SN 8.x capabilities: JSON-Schema-based schema validation, typed fields, typed link schemas, conditional links (NeedLink/parse_conditions), and link-condition export via needs_json_include_link_conditions.
  • Extend the ubc classification with the new CLI features relevant to ISO 26262 tool qualification: ubc schema validate, ubc diff git, ubc agent-skill.

Toolchain changes

File Change
pyproject.toml sphinx-needs[plotting]>=8.0.0,<9, sphinx[test]>=8.2.3,<10
uv.lock Resolved SN 8.0.0, jsonschema-rs, minijinja
ubproject.toml 14 [needs.fields.*], 13 [needs.links.*]; safety-enums on ti / si / td / tcl
tools/sphinx-needs/main.rst TOOL_SN version → 8.0.0

New classification items (13)

Features (tools/sphinx-needs + tools/ubc)

  • FE_SN_SCHEMA_VALIDATION — declarative needs_schema_definitions (local + network rules, violation severity).
  • FE_SN_TYPED_FIELDS — typed [needs.fields.*] with JSON-Schema constraints.
  • FE_SN_TYPED_LINK_SCHEMA — cardinality (minItems / maxItems) on [needs.links.*].
  • FE_SN_LINK_CONDITIONS — SN 8.0 NeedLink / parse_conditions.
  • FE_SN_JSON_LINK_CONDITIONS — SN 8.0 needs_json_include_link_conditions.
  • FE_UBC_SCHEMA_VALIDATEubc schema validate CI gate.
  • FE_UBC_DIFF_GITubc diff git change-impact analysis.
  • FE_UBC_AGENT_SKILLubc agent-skill ontology export for LLM tooling.

Each new feature carries 3–6 nested faults covering the safety-relevant failure modes (silent skip, wrong severity, missing coverage, drift, etc.).

Restrictions avoiding the new faults

  • RE_SN_USE_SCHEMA (legacy needs_constraints is disallowed)
  • RE_SN_SCHEMA_VIOLATION (severity = \"violation\" for safety invariants)
  • RE_SN_TYPE_FIELDS (explicit schema.type on every field)
  • RE_SN_LINK_CARDINALITY (schema.minItems on raises/avoids/checks/errors/responsible)
  • RE_SN_JSON_LINK_COND (keep needs_json_include_link_conditions at default True)

Updated examples of FE_SPHINX_NEEDS_CUSTOMIZABLE_OPTIONS / _LINKS to the TOML form and marked FE_SPHINX_NEEDS_DYNAMIC_CONSTRAINTS as legacy with a cross-reference.

Verification

  • uv sync installs sphinx-needs==8.0.0.
  • sphinx-build -W -a -E -b html succeeds clean (0 warnings).
  • Exported needs.json contains 284 needs (was 271); spot-check confirmed all 13 new IDs are present.

Test plan

  • Reviewer pulls branch, runs uv sync && sphinx-build -W -a -E -b html . _build/html locally and confirms a clean build.
  • Spot-check the new features / faults / restrictions render correctly in _build/html/tools/sphinx-needs/features.html, .../restrictions.html, _build/html/tools/ubc/features.html.
  • Confirm the needflow / needtable on analysis/index and tools/sphinx-needs/main still render.
  • Confirm the migrated link / field tables in ubproject.toml still drive the visible meta-data in existing needs (e.g. style predicates still color-code types).

Follow-ups (not in this PR)

  • Author an actual schemas.json with ISO 26262 safety rules and wire it via schema_definitions_from_json.
  • Add [scripts] entries for ubc schema validate / ubc build needs / ubc agent-skill.
  • Classify more of the recent ubCode (VS Code extension) features under TOOL_UBCODE, which is currently a stub.

Toolchain:
- Bump sphinx-needs to >=8.0.0,<9 (was >=6.1.0); pin sphinx <10.
- Migrate ubproject.toml from deprecated list/array forms to SN 7+ dict form:
    * extra_options = [...]       → [needs.fields.<name>] with schema.type
    * [[needs.extra_links]]       → [needs.links.<name>]
    * [needs.global_options.style] → [needs.fields.style]
- Declare safety-relevant enums (ti/si/td/tcl) on needs.fields.
- Bump TOOL_SN version to 8.0.0.

Classification (tools/sphinx-needs):
- New features with faults:
    FE_SN_SCHEMA_VALIDATION, FE_SN_TYPED_FIELDS, FE_SN_TYPED_LINK_SCHEMA,
    FE_SN_LINK_CONDITIONS, FE_SN_JSON_LINK_CONDITIONS
- Mark FE_SPHINX_NEEDS_DYNAMIC_CONSTRAINTS (needs_constraints) as legacy
  and update the code examples of FE_SPHINX_NEEDS_CUSTOMIZABLE_OPTIONS /
  _LINKS to the current TOML form.
- New restrictions avoiding the new faults:
    RE_SN_USE_SCHEMA, RE_SN_SCHEMA_VIOLATION, RE_SN_TYPE_FIELDS,
    RE_SN_LINK_CARDINALITY, RE_SN_JSON_LINK_COND

Classification (tools/ubc):
- FE_UBC_SCHEMA_VALIDATE, FE_UBC_DIFF_GIT, FE_UBC_AGENT_SKILL with faults.

Verified via sphinx-build -W -a -E (clean build, 284 needs total).
@patdhlk patdhlk changed the title ✨ Upgrade to Sphinx-Needs 8.x and classify new schema/link features Upgrade to Sphinx-Needs 8.x and classify new schema/link features Apr 20, 2026
Align remaining UI labels (pie charts, tables, dropdowns, prose) with
the renamed `fault` directive so the rendered docs no longer mix
"Errors" and `fault` terms. ISO 26262 "Tool Error Detection" and
Sphinx build-warning/error references are preserved.
@patdhlk patdhlk requested review from danwos and zic-innotec April 20, 2026 16:41
@danwos danwos merged commit 42f4151 into main May 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants