Skip to content
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

Add mock documentation #7

Merged
merged 15 commits into from
Nov 7, 2023
299 changes: 278 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,286 @@
# prototype-ci-reading
# Proposed Quality Workflow (QW) user guide - release 1

Quick prototype for processing PR and issue data in github actions
The Quality Workflow tool (QW) aims to help reduce the friction in creating and maintaining traceability matrices (later release could target hazards and risks).

## Ensuring that we can access these parts in CI
# Background and use-case

Issues
Within medical device software there are several design and development stages that should be tracked, versioned and a traceability matrix is a standard way of presenting this information. The Quality Management System used in WEISS is document based, which requires substantial manual effort in tracking linkages, updating of versions and ensuring that all approvals are current.

- [x] Title
- [x] First comment
- [x] PR number
- [x] Assignee(s)
- If we're using names, they're not required on github so could end up being blank
- We could just use github logins and have part of the config that you have to map gh logins
to names as you want them on the report information
- [x] Label
The QW allows users to track the different changes in design and development requirements, outputs, verification and validations. These different stages are linked together using github or gitlab as part of the normal development process. QW also will ensure that versioning of items are updated if their contents have changed, and notify when manual verification should be rerun due to changes in requirements or outputs.
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved

PRs
# Setup

- [x] Title
- [x] First comment
- [x] Assignee(s)
- [x] Users who's final reviews were APPROVED
- [x] Label
- [x] [Linked Issues](https://github.com/cli/cli/discussions/7097#discussioncomment-5229031)
## Installation

## Prototyping of QW tool
The `qw` tool requires python 3.9 or greater, if your project is in python then we suggest adding it to the developer requirements. Otherwise you may want to create a virtual environment for your python, one option is the [venv](https://docs.python.org/3.9/library/venv.html) module.

Messing around with python in [src](src)
For Unix:

```shell
python -m venv env --prompt qw # create virtual environment directory called `venv`
source venv/bin/activate # use the virtual environment
pip install git+https://github.com/UCL-ARC/qw.git#egg=qw # install qw
echo "venv" >> .gitignore. # ensure git ignores the `venv` directory
```

## Configuration using Github

### Initial setup and adding to repository

The `qw` tool creates a `.qw` directory that allows versions of each design and development stage to be tracked at release time. We suggest adding this directory to your version control, so that there is a shared baseline at each release. In the first step it also creates a set of github actions and templates to ensure the tool can work correctly. To allow the `qw` to interact with github you will need to create a fine-grained personal access token. The final step of configuration then updates your github repository with rules , and add templates for each stage of the quality workflow (and another template if there is an issue or pull request that doesn't relate to the quality management documentation).
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved

#### Initialise `qw`

At the top level of your git repository, run the intialisation step for github

```shell
qw init --repo github.com:username/reponame --service github
```

> INFO: A ".qw" directory has been created
> INFO: Github actions for qw have been added to your ".github" directory
> INFO: Templates added to your ".github" directory: "User need", "Design input", "Design output", "Pull request"
> INFO: Please commit the files after you have finished your setup
> INFO: Rulesets and branch protection added for branches matching "main" to "stefpiatek/dummy-medical-software"

If you have a different development flow than pull requests into main/master then edit the `qw` ruleset for the repository, adding extra branches to the ruleset (e.g. `develop`)

<!--
- [name=Stef] or do we just define what workflow they have to use? Could also give a comma separated list of branch names in the --git-service option?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Excellent question! I would think that we would define the workflow and provide a document that explains it to the developers and the regulators. We can pull out their favourite branch names from the configuration file if that really helps. Whether changing the workflow is possible or sensible is a question for later. It might well be that the .qw directory is quite happy being split and merged and so it could be quite flexible.

-->

You can omit `--service github` if the repo is at `github.com` (as in
this case) and you can omit `--repo <url>` if you have the desired
repository configured as the git remote named `upstream`.

#### Setup Personal Access Token

- Follow the [github instructions](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) we suggest the following configuration options:

| field | value, user defined values defined by `${...}` |
| ----------------- | ----------------------------------------------------------- |
| Token name | `qw-${repository_name}` |
| Expiration | `custom...` then choose 364 days from today |
| Description | `QW tool for ${repository_name}` |
| Repository access | `Only select repositories` -> Select the project repository |
| Permissions | Only add repository permissions, see next table |

| repository permissions | value |
| ---------------------- | -------------- |
| Actions | Read and write |
| Contents | Read-only |
| Issues | Read and write |
| Metadata | Read-only |
| Pull Requests | Read and write |

Then click the `Generate token` button and copy the token (you can't get its value again if you close the page).

- Add the personal access token to your machine's keychain (uses [keyring](https://pypi.org/project/keyring/))

```shell
qw login
```

<!--
- [name=Stef] For this I guess we should implement it in keyring using: service=`qw:github.com` username=`owner/repo`?
- [name=Stef] Should try and get a windows user early on to test that keyring works as expected
Copy link
Collaborator

Choose a reason for hiding this comment

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

I could try it on Desktop@Home (or whatever it's called) if you like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah not a bad shout, not a masive rush but would be good to know early

-->

> Please copy the personal access token and hit enter:

After you've done this, the system will check the personal access token. If you've configured for the remote URL <https://github.com/stefpiatek/dummy-medical-software> you would see:

> INFO: Can access "stefpiatek/dummy-medical-software"

### Setup for a new user, on an existing project that uses QW

The local and github repository have already been configured to work with `qw`, you'll just need to [add the personal access token](#setup-personal-access-token)

### Customising configuration

QW initialises with a `System` component for design inputs (used for generating a unique identifier, short code value is `X`).
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
You can add extra components to the configuration using qw:

```shell
qw config add-service --name="Drug dosage" --short-code=D
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
```

> INFO: Added "Drug dosage (D)" to local components, please commit this file
> INFO: Added tag "qw-component-d" to github

## Configuration using Gitlab

Intentionally left blank at the moment for brevity. Will aim for being able to implement this.

# Using QW with github

QW uses existing issues and pull requests to track the different design and development stages along with managing risks and their mitigations.

## Creating QW items

stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
### User needs

- In your github repository, Add a new issue, selecting the User needs template
![](https://hackmd.io/_uploads/Syo1w1oy6.png)
- Fill out the required fields and any other information if it exists
![](https://hackmd.io/_uploads/rJG7_1okT.png)
- Hit `Submit new issue` and the issue will be rendered like this: ![](https://hackmd.io/_uploads/BktGcJo1p.png)
- The first comment of this issue will be used by `qw` for tracking, but you can edit anything manually after the `Other information` header and this will not interfere with the tool

### Design inputs

tim-band marked this conversation as resolved.
Show resolved Hide resolved
- In your github repository, Add a new issue, selecting the User needs template
![](https://hackmd.io/_uploads/Syo1w1oy6.png)
- Fill out the required fields and any other information that may be useful
![](https://hackmd.io/_uploads/B1X07JVZ6.png)
- The options for requirements type are:
- Functional
- System inputs and outputs
- Application programming interface
- Alarms and warnings
- Security
- User interface
- Data definition and database
- Installation and acceptance
- Operation methods and maintenance
- Networking
- User maintenance
- Regulatory
- Hit `Submit new issue` and theissue will be rendered like this:
![](https://hackmd.io/_uploads/H1-xiDBWT.png)
- Note that the `design-component-d` has been added as "Drug dosage" was added as a component type with a short code of `D`.
- The first comment of this issue will be used by `qw` for tracking, but you can edit anything manually after the `Other information` header and this will not interfere with the tool
- The parent issue will have been updated with this issue number
![](https://hackmd.io/_uploads/S1OvqDrW6.png)

### Design outputs and design verification

- Create a pull request from github and follow the instructions on the template
![](https://hackmd.io/_uploads/BkYpd7ikp.png)
- If the `qw-ignore` tag is added, then this PR does is not related to the medical device aspect of the software
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
- In this example, the pull request contains the design outputs and design verification. These can be added separately, where the design verification would also be linked to the design input.
![](https://hackmd.io/_uploads/ryp39Xj1a.png)
- QW will check that the chain of design items are able to be processed and fully signed off,
when this is successful the github action will pass
![](https://hackmd.io/_uploads/H1Ix67i16.png)
- QW requires a pull request that is labelled as a `design-validation` or `design-verification` to have at least one automated test that targets a specific `design-output`, `design-input` or `user-need`
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
- Tests are tracked manually in `.qw/test_mapping.csv` where multiple issues are separated by `;`, in the following structure
test name | issue(s) targetted
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
-- | --
InputVerifierTests::testWeightIsNegative | 40
InputVerifierTests::testConversionOfWeightUnits | 4;23
acceptance_test_user_entry.docx | 2
- The development team may want to write a script that allows them to get the names of all tests run and ensure that automated tests listed in the csv still exist, bonus points if you make this an automated test that fails if a test doesn't exist
- Adding the manual verification test scripts to version control is ideal, but you may also list the name
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
- the QW CI task will fail if:
- No parent issue is given for a PR
- A test doesn't exist which is mapped to the parent issue
- The structure of the `test_mapping.csv` has been altered, or `;` has not been used to separate targeted issues
- A test name is duplicated in `test_mapping.csv`

### Design validation

- QW does not require design validation documentation to be added to the repository,
but you may add the test script.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably need a way to define generated documents generically, rather than specify this on a case-by-case basis. I'm thinking you can generate a basic set of docs that follows SmartTarget or QNICE's example; these are stored in the Templates directory (and could be word templates or some sort of markdown thing). You can perhaps put plain old Word documents in there if you like (if we have a reasonable way of inserting a version number into it). There would be another Partials directory where all the bits go, for example a list of Hazards that gets pulled into other documents.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure if we're talking across eachother. This was ment to be the proof of validation work, e.g. validation of a user need, so a test script. rather than generating documentation

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm more talking about the first clause in that statement. Shouldn't we be aiming to produce validation documentation? Not sure. What are we envisioning for validation documentation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In my mind the validation document would be how they validated it, what the outcome was, and it being signed off. I think we'd just need to have a way to point to the name of the validation document (which would be added in cognidox) using the verification and validation csv. But I think if that doesn't sound right then let's have a chat today

Ideally this would be in a plain text format. We suggest creating a
`validation` directory and storing the validation information there
- As with [Design outputs and design verification](#design-outputs-and-design-verification), update the `.qw/test_mapping.csv` with the test script(s) that fulfill the user need.
- Create a pull request from github and follow the instructions on the template
![](https://hackmd.io/_uploads/BkYpd7ikp.png)
- A validation links to a user need, so link this type of issue in the PR
- Assign the pull request to the team member who will authorise the validation.
Once they have validated it and signed any required paperwork,
they should approve the PR.

### Non-QW items

- If you'd like to create an issue that doesn't relate to the medical device then use the `Non QW item` issue template.
This tags the issue with `qw-ignore` so that QW does not parse the issue.
![](https://hackmd.io/_uploads/SkWcEzQgp.png)
- If you'd like to create a pull request that doesn't relate to the medical device then tag the pull request with `qw-ignore`.

## Closing QW items when they are not resolved by a PR

- There may be times where an QW-tracked issue is required to be closed not by a PR.
- You may close the issue as either `completed` or `not planned` ![](https://hackmd.io/_uploads/Sy22Bi9x6.png)
- Then please add the `qw` tag that matches the reason. The options for tags are:`qw-close-duplicate`, `qw-close-wont-fix`, `qw-close-duplicate`, , `qw-close-cannot-replicate`, `qw-close-not-a-defect`
- [name=Stef] Alternatively we could have a manual closure reason in the issue template, and then that is required to be filled with free text as a reason?
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved

## Versioning of QW items

The `qw freeze` function is used to save the current state of the qw items in github, and to ensure that the versions of items are updated if their information has changed.
This should be run regularly, which will update or add to the `.qw` directory.
These changes should be committed and added to the main development branch by a pull request as a [Non QW item](#non-qw-items).
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about qw freeze makes its own PR?

Copy link
Collaborator Author

@stefpiatek stefpiatek Oct 12, 2023

Choose a reason for hiding this comment

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

oopf, what if there are staged changes when you run it? Feels like we could enter in a world of pain

Copy link
Collaborator

Choose a reason for hiding this comment

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

Absolutely, run qw freeze only on a clean repository, slap the results into a PR with no extra stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my only concern here is what if they're not on main, or main isn't updated. I guess we could check for these but feels like there's a large surface area for pain that we're taking on


```shell
qw freeze
```

An example incrementing a tag upon update:

> Running WQ freeze
> Found 47 QW items
>
> INFO: Design Input https://github.com/stefpiatek/dummy-medical-software/issues/6 has been updated since last saved
>
> Previous data:
>
> - Description : Warfarin dosage should be calculated using based on patient age, gender and weight
> - Parent User need: https://github.com/stefpiatek/dummy-medical-software/issues/5
>
> Current Data:
>
> - Description : Warfarin dosage in mg/kg should be calculated using based on patient age, gender and weight
> - Parent User need: https://github.com/stefpiatek/dummy-medical-software/issues/5
>
> Would you like to increment the version? (y/n): <prompt response from user - y>
> INFO: Updated tag to "qw-v2"
> INFO: There are 2 design outputs that link to this Design Input, please ensure one of them has the "qw-v2" tag if it resolves the updated information
>
> - https://github.com/stefpiatek/dummy-medical-software/pull/7
> - https://github.com/stefpiatek/dummy-medical-software/pull/12
> ...
> INFO: :heavy_check_mark: 12 new QW items added to state
> INFO: :heavy_check_mark: 47 QW items checked
> INFO: Please commit the changes in the ".qw" directory

Example response when the change is trivial and does not warrant a change in the version of the QW item:

> ...
> Would you like to increment the version? (y/n): <prompt response from user - n>
> INFO: Tag kept at "qw-v1", data for the Design Input has been updated to the current state
> ...

### Creating a documentation release
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved

When you're ready to update the documentation in your Quality Management System (QMS), you can use the QW tool's `release` command.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me that qw release should take templates and frozen items to produce one document per template. Must be frozen items, right?

Running this will:

- Ensure that all issues and pull requests have been marked with `qw-ignore` or one of the `qw-` item tags, raising an error (and stopping) to ensure all items are tagged
- Ensure that all QW items have versions
- Ensure the entire chain `design validation -> design verification -> design output -> design input -> user need` is consistent with QW rules, starting from the furthest stage of QW items. So if there is no `design validation`, then the chain will start from `design verification`. If there was only a `user need` and `design input`s, then only these would be validated
- Create word documents based on the QW template for export
- [name=Stef] Optionally? Create an html page that shows a burndown graph for each of the QW item types, showing the number completed and outstanding over time. Would this be useful?
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that this is critical, but may be a nice to have for someone taking a quality lead role to see how well the system is being used

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, management documents are planned. Not exactly sure what will be in them yet.


```shell
qw release qms_docs
```

> Creating a release for QW
> Creating "qms_docs" directory if it doesn't already exist, and overwriting any previously exported files
> INFO: :heavy_check_mark: 47 QW items checked
> INFO: :heavy_check_mark: Documents have been written to the "qms_docs" directory

# FAQ and common issues

- Can I import an existing project into QW
- There's nothing stopping this, though each issue and pull request would need to match the required format, and be tagged appropriately by the time you'd like to run a release. This may be a reasonable amount of work and we expect issues may need to be created.
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
-

# Open questions

- Which document parts are the most useful for export, and would we want the user to be able to edit the template (update styles and placeholder text?)
- Would the burndown chart be useful to get an overview for development?
Copy link
Contributor

Choose a reason for hiding this comment

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

From my initial thoughts, the most useful bits would be to export and link tables to include in the software development plan, software requirement analysis, software detailed design, and software unit implementation and verification bits to comply with IEC 62304. The doc names may vary on the template you're using - those are based on Magda's interpretation of WEISS QMS I think and QNICE as an example. Other possibly useful templates at https://openregulatory.com/templates/

I think editing the templates will be needed as there will be other bits of content to update based on what the project is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, templates should be copied in to the repo so that the devs can edit them as required.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes! Managers love this stuff! Here is the rate we are burning down our risks, our Design Inputs and our Problem Reports!
We should absolutely store the state of the system at each qw freeze (or even more frequently) so that we can build these charts. May not be top priority of course.

- Gate who can authorise a PR, or can anyone?
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be project specific, and part of the process docs will define how releases are controlled. For example on SRR, we've stated that releases of software and docs need to be approved by Magda. So I think control of PR sign-off would be useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just considering this further, are we saying that every PR would need to be approved by madga in this project?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And does this mean that you have the author, a normal approver plus Magda making 3 people?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We absolutely need a list of people who are authorized and trained to do this. This list of people needs to be controlled by qw, so the open question is really more like "how do we control the list of authorized PR approvers, CR approvers and the like?"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we're gating PRs then it'd all be using github rules and codeowners files. Though I'm less sure QW should control this, and its more up to the users to make sure they comply with their own development process?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an excellent idea. We should absolutely lean into github's natural way of doing things where they exist. Escpecially as gitlab does it too.
In this case our configuration should be split into many csv files (or similar) rather than one giant .json

- Should we include a change request at this stage, or keep it with the risk management side of things
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say that a change request is to do with when the system is deployed and part of ongoing risk management so wouldn't be needed in a MVP. The interaction of risk management with design and testing would be very useful in a future iteration!

Copy link
Collaborator Author

@stefpiatek stefpiatek Oct 12, 2023

Choose a reason for hiding this comment

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

I also noticed tha James has been tracking bugs and then the PRs that are closed, that weren't related to a specific user need, but not sure if that's required. Though does set up the case for ongoing surveillance post release

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to clarify, if a change was needed on an existing qw item, post freeze, would the change requester just modify the existing qw item from within github?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep they'd change it in github, and then on the next freeze command it'd prompt to say that it had changed and ask if its a negligable change (so keep it and dont increment the version) or the change requires a new version to be created

tim-band marked this conversation as resolved.
Show resolved Hide resolved
- closed not by a PR - would be useful to get a steer on what is required or most useful
stefpiatek marked this conversation as resolved.
Show resolved Hide resolved
tim-band marked this conversation as resolved.
Show resolved Hide resolved