-
Notifications
You must be signed in to change notification settings - Fork 36
draft: feat(backend/sdoc_source_code): Support merge by MID #2549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
haxtibal
wants to merge
1
commit into
strictdoc-project:main
Choose a base branch
from
haxtibal:tdmg/source_node_mid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
...tures/source_code_traceability/_source_nodes/30_merge_with_sdoc_by_default_uid/test.itest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # | ||
| # This test verifies that a source nodes is merged with a static SDoc node if | ||
| # - the source nodes is not marked up with a UID field (i.e., default UID is effective), and | ||
| # - static SDoc node was explicitly given the default UID. | ||
| # | ||
| # @relation(SDOC-SRS-141, scope=file) | ||
| # | ||
|
|
||
| RUN: %strictdoc --debug export %S --output-dir %T | filecheck %s | ||
|
|
||
| CHECK: Published: Hello world doc | ||
|
|
||
| RUN: %check_exists --file "%T/html/_source_files/src/example.c.html" | ||
|
|
||
| RUN: %cat %T/html/%THIS_TEST_FOLDER/source_node_base.html | filecheck %s --check-prefix CHECK-HTML | ||
| CHECK-HTML: Requirements from Source Nodes | ||
| CHECK-HTML: SRC-NODES-BASE/src/example.c/example_1 | ||
| CHECK-HTML: TITLE from sdoc | ||
| CHECK-HTML: class="requirement__link-parent" href="../30_merge_with_sdoc_by_default_uid/parent.html#REQ-1" | ||
| CHECK-HTML: src/example.c, <i>lines: 3-14</i>, function example_1() | ||
| CHECK-HTML-NOT: FOO text from sdoc | ||
| CHECK-HTML: FOO text from example.c | ||
| CHECK-HTML-NOT: BAR text from sdoc | ||
| CHECK-HTML: BAR text from example.c | ||
|
|
||
| RUN: %cat %T/html/_source_files/src/example.c.html | filecheck %s --check-prefix CHECK-SOURCE-FILE | ||
| CHECK-SOURCE-FILE: SRC-NODES-BASE/src/example.c/example_1 | ||
|
|
||
| RUN: %cat %T/html/source_coverage.html | filecheck %s --check-prefix CHECK-SOURCE-COVERAGE | ||
| CHECK-SOURCE-COVERAGE: 100.0 |
24 changes: 0 additions & 24 deletions
24
...tion/features/source_code_traceability/_source_nodes/30_merge_with_static_node/test.itest
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
...ion/features/source_code_traceability/_source_nodes/31_merge_with_sdoc_by_uid/parent.sdoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [DOCUMENT] | ||
| TITLE: Hello world doc | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-1 | ||
| TITLE: Requirement Title | ||
| STATEMENT: Requirement Statement | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-2 | ||
| TITLE: Requirement Title #2 | ||
| STATEMENT: Requirement Statement #2 | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-3 | ||
| TITLE: Requirement Title #3 | ||
| STATEMENT: Requirement Statement #3 |
72 changes: 72 additions & 0 deletions
72
...es/source_code_traceability/_source_nodes/31_merge_with_sdoc_by_uid/source_node_base.sdoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| [DOCUMENT] | ||
| MID: c2d4542d5f1741c88dfcb4f68ad7dcbd | ||
| TITLE: Requirements from Source Nodes | ||
| UID: SRC-NODES-BASE | ||
|
|
||
| [GRAMMAR] | ||
| ELEMENTS: | ||
| - TAG: SECTION | ||
| PROPERTIES: | ||
| IS_COMPOSITE: True | ||
| FIELDS: | ||
| - TITLE: UID | ||
| TYPE: String | ||
| REQUIRED: False | ||
| - TITLE: TITLE | ||
| TYPE: String | ||
| REQUIRED: True | ||
| - TAG: REQUIREMENT | ||
| PROPERTIES: | ||
| VIEW_STYLE: Narrative | ||
| FIELDS: | ||
| - TITLE: UID | ||
| TYPE: String | ||
| REQUIRED: False | ||
| - TITLE: MID | ||
| TYPE: String | ||
| REQUIRED: False | ||
| - TITLE: TITLE | ||
| TYPE: String | ||
| REQUIRED: False | ||
| - TITLE: FOO | ||
| TYPE: String | ||
| REQUIRED: False | ||
| - TITLE: BAR | ||
| TYPE: String | ||
| REQUIRED: False | ||
| RELATIONS: | ||
| - TYPE: Parent | ||
| - TYPE: File | ||
|
|
||
| [[SECTION]] | ||
| TITLE: Merge example.c into static nodes | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-SOURCE-1 | ||
| TITLE: TITLE1 from sdoc | ||
| FOO: FOO1 text from sdoc | ||
| BAR: BAR1 text from sdoc | ||
| RELATIONS: | ||
| - TYPE: Parent | ||
| VALUE: REQ-1 | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-SOURCE-2 | ||
| MID: 80cd685d-0e18-44b8-9842-c1863a2eb9ec | ||
| TITLE: TITLE2 from sdoc | ||
| FOO: FOO2 text from sdoc | ||
| BAR: BAR2 text from sdoc | ||
| RELATIONS: | ||
| - TYPE: Parent | ||
| VALUE: REQ-2 | ||
|
|
||
| [REQUIREMENT] | ||
| UID: REQ-SOURCE-3 | ||
| TITLE: TITLE3 from sdoc | ||
| FOO: FOO3 text from sdoc | ||
| BAR: BAR3 text from sdoc | ||
| RELATIONS: | ||
| - TYPE: Parent | ||
| VALUE: REQ-3 | ||
|
|
||
| [[/SECTION]] |
48 changes: 48 additions & 0 deletions
48
...n/features/source_code_traceability/_source_nodes/31_merge_with_sdoc_by_uid/src/example.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #include <stdio.h> | ||
|
|
||
| /** | ||
| * Some text. | ||
| * | ||
| * @relation(REQ-1, scope=function) | ||
| * | ||
| * UID: REQ-SOURCE-1 | ||
| * | ||
| * FOO: FOO1 text from example.c | ||
| * | ||
| * BAR: BAR1 text from example.c | ||
| */ | ||
| void example_1(void) { | ||
| print("hello world\n"); | ||
| } | ||
|
|
||
| /** | ||
| * Some text. | ||
| * | ||
| * @relation(REQ-2, scope=function) | ||
| * | ||
| * UID: REQ-SOURCE-2 | ||
| * | ||
| * FOO: FOO2 text from example.c | ||
| * | ||
| * BAR: BAR2 text from example.c | ||
| */ | ||
| void example_2(void) { | ||
| print("hello world\n"); | ||
| } | ||
|
|
||
| /** | ||
| * Some text. | ||
| * | ||
| * @relation(REQ-3, scope=function) | ||
| * | ||
| * UID: REQ-SOURCE-3 | ||
| * | ||
| * MID: 1973a567-a109-491d-b7f0-6bb22eafa6ab | ||
| * | ||
| * FOO: FOO3 text from example.c | ||
| * | ||
| * BAR: BAR3 text from example.c | ||
| */ | ||
| void example_3(void) { | ||
| print("hello world\n"); | ||
| } |
14 changes: 14 additions & 0 deletions
14
.../features/source_code_traceability/_source_nodes/31_merge_with_sdoc_by_uid/strictdoc.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [project] | ||
|
|
||
| features = [ | ||
| "REQUIREMENT_TO_SOURCE_TRACEABILITY", | ||
| "SOURCE_FILE_LANGUAGE_PARSERS", | ||
| ] | ||
|
|
||
| source_nodes = [ | ||
| { "src/" = { uid = "SRC-NODES-BASE", node_type = "REQUIREMENT" } } | ||
| ] | ||
|
|
||
| exclude_source_paths = [ | ||
| "test.itest" | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've cleaned up up a bit now. Here is my remaining problem. I try to allow and handle this case
meaning a MID from source code would overwrite the earlier auto-assigned MID. However, auto-assigned MID has been entered to graph and search index early (at least, maybe also to other places?) and I would need to update them. I know how to update the graph, but couldn't figure out how to consistently update the search index.
What do you think, would it be easy enough to do these updates, or should I simply not allow that edge case (exit with error)?
EDIT: For myself, I tend to not allow it. That edge case is not needed for the Linux showcase. I don't like the idea of having to modify already established graph connections while we're still in traceability construction phase. Rather, it should be possible to conceptually separate things into a "compile" and "link" phase as you already suggested. Source node parsing and merging would be part of the compile phase. At it's end we would know all nodes with some "I would like to link to..." information, but nothing is actually linked yet. And only the final link stage will add links to the graph DB and create the search index.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to think about your comment but something that is not clear to me even before and in general is how we want to auto-generate the UUID for both source code and sidecar when both or either of SDoc node's or source file's MID/UUID do not exist yet. Is my understanding correct that we will not have the human-readable UID at all in the Linux context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On other words, it is some sort of a chicken-and-egg problem. How are we imaging the workflow of auto-generating MID/UUID between source code and sidecars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can look at ELISA's trace_events.c annotations and their idgen.py script.
Source code starts of like
Then one shall call
idgen.py generate trace_events.cto calculatesha256sum("linux" + "trace_events.c" + instance + code), where instance is the text afterSPDX-Text:in the comment, and code is the full C-function definition without comment.The script acknowledges the problem you have mentioned
I see a few options:
SPDX-Req-ID: UUID-TICKET-123, andMID: UUID-TICKET-123in related sdoc. When StrictDoc sees such a preliminary UID, it will replace it with a proper calculated hash valueSPDX-Req-ID: [TODO: automatically generate it], andMID: tracing.c/__ftrace_event_enable_disablein related sdoc. Let StrictDoc merge by conventional MID and replace conventional UID with proper calculated hash valueI have no clear favorite right now from that options. Maybe we should ask Gabriele?
Yes, that's also my understanding. The pilot work nowhere mentions a UID. If we wanted one, it's up to us to propose it.