Skip to content

Add report history view per subject/scope#1171

Open
guettli wants to merge 1 commit into
mainfrom
feature/compliance-history
Open

Add report history view per subject/scope#1171
guettli wants to merge 1 commit into
mainfrom
feature/compliance-history

Conversation

@guettli
Copy link
Copy Markdown
Contributor

@guettli guettli commented May 13, 2026

The compliance monitor previously only showed the latest test result per subject/scope. All historical data was stored in the database but had no UI to browse it. This PR exposes that history.

Note: the counts reflect raw testcase results and do not distinguish required vs. recommended vs. extra testcases for a given scope version. This is intentionally a report history, not a compliance verdict history.

Changes

New endpoint GET /{view_type}/history/{subject}/{scopeuuid}
Returns a chronological list of all past reports for a given subject and scope, newest first, showing date and per-report PASS/FAIL/ABORT counts with a link to each individual report. Capped at 500 entries (most recent); a notice is shown when truncated.

📜 report history links added in two places:

  • Detail pages (/page/detail/ and /page/detail_full/) — one link per subject/scope section
  • Report pages (/page/report/) — links back to the history list for that subject/scope

New SQL function db_get_report_history — aggregates pass/fail/abort counts per report for a given subject and scope, ordered by date descending.

Bug fix: db_upgrade_schema crashed with TypeError on a fresh database (None >= 'v4'). Fixed the guard condition to check for None first.

No schema changes required

All historical reports were already stored. This PR only adds read paths.

@guettli guettli force-pushed the feature/compliance-history branch 2 times, most recently from 82f51a7 to 004447a Compare May 13, 2026 10:10
Copy link
Copy Markdown
Contributor

@mbuechse mbuechse left a comment

Choose a reason for hiding this comment

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

The code is good, I think. I have two concerns:

  • we should add Generated-by: <insert AI model here> to the commit message
  • I'm wondering what this history is actually showing

Let me elaborate on the latter. The database does contain results (of the form pass/fail/abort) for combinations of subject, scope, testcase id. These results are used to compute whether a subject complies with some version of the scope. Depending on the version, only a strict subset of testcases can be required to pass that version.

This history view only counts the number of passed, failed, and aborted testcases for a given subject, scope, and report date, which means it doesn't distinguish between

  • testcases that are required for a certain version,
  • testcases that are merely recommended,
  • testcases that are (erroneously) present in the database but not even part of any version, and
  • testcases that are required but missing in the database (because they haven't been reported).

So what we see here is basically an overview of the reports, without any qualification of the data with respect to its import.

In summary, I would say this is NOT a compliance history, but merely a report history. Your mileage may vary as to how useful this is.

@guettli guettli force-pushed the feature/compliance-history branch from 004447a to 573ea17 Compare May 13, 2026 12:58
@guettli guettli changed the title Feature/compliance history 📜 Add report history view per subject/scope May 13, 2026
@guettli guettli force-pushed the feature/compliance-history branch from 573ea17 to 0c7f31b Compare May 13, 2026 13:00
@guettli
Copy link
Copy Markdown
Contributor Author

guettli commented May 13, 2026

@mbuechse our use-case: See historical reports, so we can differentiate between flakes and constant failures.

@mbuechse
Copy link
Copy Markdown
Contributor

@guettli I see. However, wouldn't it make more sense then to restrict the view to a specific testcase, so you can see whether the result for that given testcase oscillates? With the sums, you don't see it, because (worst case) two testcases could fail alternatingly, and then the sums stay the same, which would give the false impression of stability.

@guettli
Copy link
Copy Markdown
Contributor Author

guettli commented May 13, 2026

@mbuechse nice, that you care for our user experience. Overall I think the current view makes sense.

On top we could add a view which shows the history of one tests.

What do you think: Extend existing PR or create follow-up PR?

@mbuechse
Copy link
Copy Markdown
Contributor

nice, that you care for our user experience.

@guettli I wouldn't quite put it that way. What I care for is that we don't haphazardly extend the assortment of views to cater to very particular or ad-hoc use cases.

I would actually prefer to have a discussion and a general alignment among the community on what problems we want to solve and how best to solve them, before we start working on solving them.

@mbuechse
Copy link
Copy Markdown
Contributor

If you don't want to enter a discussion about what kinds of problems we want to solve and what views would be most suitable for a wide audience, I would propose to extend the endpoint

async def get_results(

to accept a subject and scope, so you can download and evaluate results any way you like. If a subject is given, it should also be passed on to check_role, so an account without role read_any can at least download their own results.

@guettli
Copy link
Copy Markdown
Contributor Author

guettli commented May 13, 2026

If you don't want to enter a discussion about what kinds of problems we want to solve and what views would be most suitable for a wide audience, I would propose to extend the endpoint

async def get_results(

to accept a subject and scope, so you can download and evaluate results any way you like. If a subject is given, it should also be passed on to check_role, so an account without role read_any can at least download their own results.

Wait a second. My PR is just about changing the web UI. There is a new API, but this was not the intention of he PR.

I can extend the API, but then I need to extend the docs, too.

Where is the API documented?

@mbuechse
Copy link
Copy Markdown
Contributor

See here: https://github.com/SovereignCloudStack/standards/tree/f76ee406e52908b4e7450af25a99bd8ef9ed703a/compliance-monitor#endpoints

Adds a new /page/history/{subject}/{scopeuuid} endpoint (and markdown/
fragment variants) that lists all past reports for a given subject and
scope, newest first, with per-report PASS/FAIL/ABORT counts and links
to each individual report. Capped at 500 entries with a notice when
truncated.

Also adds a "📜 report history" link to detail pages and report pages,
a history_url() helper in render_view(), and fixes a pre-existing
TypeError crash on fresh databases in db_upgrade_schema() when the
schema version is None.

Note: the counts reflect raw testcase results and do not distinguish
required vs. recommended vs. extra testcases for a given scope version.
This is intentionally a report history, not a compliance verdict history.

Generated-by: Claude Sonnet 4.6
Signed-off-by: Thomas Güttler <thomas.guettler@syself.com>

Extend GET /results to filter by subject and scope

Add optional `subject` and `scopeuuid` query parameters to GET /results.
When subject is provided, accounts can access their own results without
needing the `read_any` role. Update docs accordingly.

Signed-off-by: Thomas Güttler <thomas.guettler@syself.com>
@guettli guettli force-pushed the feature/compliance-history branch from 8d7226e to b6b9f4c Compare May 13, 2026 14:48
@guettli
Copy link
Copy Markdown
Contributor Author

guettli commented May 13, 2026

See here: https://github.com/SovereignCloudStack/standards/tree/f76ee406e52908b4e7450af25a99bd8ef9ed703a/compliance-monitor#endpoints

I adapted the PR, please tell me what needs to be improved.

@guettli guettli requested a review from mbuechse May 13, 2026 14:50
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