8000 feat: preserve CDD service preconditions by tomrford · Pull Request #52 · tomrford/gocan · GitHub
[go: up one dir, main page]

Skip to content

feat: preserve CDD service preconditions - #52

Merged
tomrford merged 7 commits into
mainfrom
feat/cdd-preconditions
Sep 5, 2026
Merged

tomrford merged 7 commits into
mainfrom
feat/cdd-preconditions

Conversation

@tomrford
@tomrford tomrford commented Sep 4, 2026 •
Copy link
Copy Markdown
Owner

Preserve CDD execution-precondition metadata for supported DID read/write records without guessing ECU permissions. Each service bound to an operation retains its own alternative, source identity, source order, template reference, and raw instance/template rule attributes. Equivalent rules do not erase distinct source services.

Database.States retains every declared state with its group identity and document position. Sessions and SecurityLevels provide the corresponding subsets, including any locked state. Positions describe source order, not UDS subfunctions. No initial state or security privilege hierarchy is inferred.

Precondition.Err marks unknown requirements. A nil error means no explicit restriction was found on the instance or template; it does not establish ECU permission. All explicit mayBeExec and notExecInStateGroups rules remain unresolved. Raw pointers distinguish absent attributes from explicit empty values. Resolved restriction lists are not exposed while their semantics are unverified.

Unknown requirements leave valid record encoding and decoding available. Diagnostics identify the affected operation and source service and are emitted only after DID acceptance, avoiding orphan rule diagnostics for rejected layouts and duplicate DIDs. Service binding carries the resolved template into precondition handling.

Resolution of CDD state-reference indexing, omitted groups, exclusions, and template inheritance is outside this metadata-preservation scope. These forms remain explicitly unknown. Public/generic evidence is required before adding resolved requirements; synthetic tests do not establish their meaning.

Evidence:

  • Tom confirmed that the original BRUSA-file check established successful parsing only, not state-rule correctness. The final source-preservation changes have not been run against that file here. BRUSA-specific interpretations belong in the consumer.
  • The Vector CANdelaStudio 7.0 manual, section 3.11.2 describes execution permission per state. It does not establish first-state-as-locked or permission in other states when locked is selected.
  • AUTOSAR DCM R21-11, ECUC_Dcm_00614 and ECUC_Dcm_00754, defines absent security references as no check and excludes locked from configured security levels. This does not establish the mapping from CDD state lists.
  • Neither the pinned cantools parser nor the inspected public CDD parsers establishes the missing rules. Both pinned examples parse: example-diddatarefs.cdd returns 1 DID, 10 session states, 15 security states and no diagnostics; example.cdd returns no UDS DIDs and no diagnostics.

Validation at 2a8c517 (rebased onto main af7b7ec): go test -race ./..., go vet ./..., gofmt -l ., and git diff --check passed. Public Go documentation was inspected. Tests cover parse/encode/decode lifecycles, known-absent and unknown alternatives on the same operation, read/write isolation, raw rule presence, identities and source order, equal qualifiers, equivalent alternatives, and diagnostic timing after DID acceptance. Fresh independent review findings were addressed. GitHub CI passed on the rebased head, including Linux virtual CAN tests and Windows cross-compilation. Cursor Bugbot reviewed commit 2a8c517 and found no new issues; its check passed.

Scope remains DID precondition metadata. Broader service catalogs, transitions, DTC support, and automatic ECU state changes are deferred.

@tomrford
tomrford force-pushed the feat/cdd-preconditions branch 2 times, most recently from f4e4d79 to 9b773f0 Compare September 4, 2026 23:40
@tomrford
tomrford marked this pull request as ready for review September 4, 2026 23:40
@tomrford
tomrford force-pushed the feat/cdd-preconditions branch 2 times, most recently from bbf4b66 to fc1859d Compare September 5, 2026 10:21
Read the STATEGROUPS declared by a CANdela document into Database.Sessions
and Database.SecurityLevels, and resolve each DID service's mayBeExec state
indexes into Record.Sessions and Record.SecurityLevels so consumers learn
which diagnostic sessions and security levels an operation runs in without
seeing the index arithmetic. A group with no listed state, or a service with
no attribute, leaves the operation unrestricted. An index outside the
declared states is reported in Database.Diagnostics and keeps the DID.
Carry the resolved DCLSRVTMPL alongside each SERVICE instance so servicePrecondition cannot see a nil template and does not repeat the ID lookup. Mention preconditions in the README package table.
A service permitted in the locked state has no security requirement, since UDS never rejects a request for being unlocked. SecurityLevels now lists only unlocked levels and is nil when the locked state, or no security state, is permitted. Sessions remain literal. The locked state is the first state CANdela declares in the security group.
@tomrford
tomrford force-pushed the feat/cdd-preconditions branch from ce0ec42 to 2a8c517 Compare September 5, 2026 10:37
@tomrford
tomrford commented Sep 5, 2026
Copy link
Copy Markdown
Owner Author

@cursor review

@cursor cursor Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2a8c517. Configure here.

@tomrford
tomrford merged commit 1b47c45 into main Sep 5, 2026
2 checks passed
@tomrford
tomrford deleted the feat/cdd-preconditions branch September 5, 2026 10:45
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.

1 participant

0