Skip to content

fix(sdk): keep incomplete scans out of completed assessments (XWING-3098) - #88

Open
pshickeydev wants to merge 6 commits into
traust-security:developmentfrom
pshickeydev:fix/XWING-3098-integrity
Open

pshickeydev wants to merge 6 commits into
traust-security:developmentfrom
pshickeydev:fix/XWING-3098-integrity

Conversation

@pshickeydev

@pshickeydev pshickeydev commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Recording lifecycle. Keep lease_generation from the original claim and send it on renewals, recording requests and completion. Event time is independent. Failed, degraded and refused assessment runs retain their worker outcome and measured usage without posting a completed assessment; Runner.Run logs degraded completions at WARN level via logCompleted. The queued SCI test follows the worker’s normalized report through native intake into triage; it does not claim raw AdapterFinding compatibility.

Stacking & Generated API: Stacked on traust-sdk#91 (fa8c8fdd36, dashboards query & reports jobs). Regenerated the Go client and artifact bindings against contracts #185 (58803ea798) and Core #527 (f5e3ab122b). No frozen storage migration.

Verification: make check-drift fmt-check vet test passed against go/Makefile pins 58803ea798 / f5e3ab122b (including TestRunnerLogsDegradedCompletionAtWarn). Live E2E (v1/traust + v1/ops, including TestE2EQueryDashboardCountsARepositorySet, TestE2ERequestReportQueuesAndReadsStatus, TestE2ERecordingPreservesReportFields, and TestE2ESCIQueuedScanFeedsTriage) passed against traust-server built from Core f5e3ab122b. SCI #397 exercises the downstream worker.

XWING-3098 · XWING-3099 feed shadowing remains gated.

Updated with AI assistance (Gemini 4 Neon).

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2026
@pshickeydev

Copy link
Copy Markdown
Member Author

/agentic_review

@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (4)

Grey Divider


Remediation recommended

1. New exports widen API without an endpoint 📜 Skill insight ⌂ Architecture
Description
ViewNameOf and DecodeReportView are new exported functions in reports.go. GetReportFileAs
already wraps DecodeReportView around the GetReportFile endpoint, but DecodeReportView is a
standalone JSON decoder that backs no endpoint and provides no extension point, yet is exposed to
consumers as a supported symbol. ViewNameOf only maps a generated type to a view name; its
intended public role is not stated in the code or PR description, so later signature changes would
break SDK users.
Code

go/v1/traust/reports.go[R19-26]

+func ViewNameOf[T any, PT insightView[T]]() ViewName {
+	return PT(nil).insightName()
+}
+
+// DecodeReportView decodes a JSON report file body strictly as view T's contracts ViewModel
+// (such as FindingsRollupInsight). Any field outside the contract is an error, never dropped.
+func DecodeReportView[T any, PT insightView[T]](body []byte) (*T, error) {
+	name := PT(nil).insightName()
Evidence
DecodeReportView is exported and called directly only by GetReportFileAs and by tests feeding it
captured fixture bodies, with no endpoint of its own. ViewNameOf is used only in request
construction and tests. Neither is clearly an extension point or core endpoint, so the rule asks for
justification or unexported helpers.

go/v1/traust/reports.go[18-34]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ViewNameOf` and `DecodeReportView` are exported from `go/v1/traust/reports.go` but are not tied to an endpoint or an extension point. `GetReportFileAs` is the endpoint-backed API.

## Fix Focus Areas
- go/v1/traust/reports.go[18-34]
- go/v1/traust/reports_test.go[149-206]

## Recommended Fix
If `DecodeReportView` is needed only by `GetReportFileAs` and tests, rename it to `decodeReportView` and keep the exported surface to `GetReportFileAs` and `ViewNameOf`, or document in the package comment why each remaining export is endpoint-backed or an extension point. Update the tests in `reports_test.go` to exercise the decoder through `GetReportFileAs`, or add an internal test file in package `traust` for the unexported decoder.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Refusal paths of new endpoints untested 📜 Skill insight ▣ Testability
Description
The PR deletes the e2e test asserting a 422 problem with a request id when set-scoped counts are
requested without repositories, and removes the matching refusal case from the set-scoped summaries
test. The replacement TestE2EQueryDashboardCountsARepositorySet covers only the success path, so
the refusal edge of QueryDashboard is no longer exercised. The new unit tests
TestQueryDashboardPostsQueryAndDecodesRows and TestRequestReportHandlesReady200AndQueued202
cover only 200 and 202 responses, so a regression in error decoding for these endpoints would pass
the suite.
Code

go/v1/traust/e2e_test.go[L109-110]

-func TestE2ECountFindingsInRefusesWithoutRepositories(t *testing.T) {
-	resp, err := e2eClient(t).CountFindingsInWithResponse(context.Background(), &CountFindingsInParams{})
+func TestE2ERequestReportQueuesAndReadsStatus(t *testing.T) {
+	format := ReportFormatJson
+	report, err := e2eClient(t).RequestReport(context.Background(), ReportRequest{
+		Report: ViewNameOf[FindingsRollupInsight](),
+		Format: &format,
+	})
Evidence
The removed TestE2ECountFindingsInRefusesWithoutRepositories was the only refusal-edge test for a
set-scoped read, and no replacement asserts the 422 problem path for QueryDashboard. The new unit
tests for QueryDashboard and RequestReport contain only success statuses, leaving the failure
edges of changed behavior uncovered.

go/v1/traust/reports_test.go[18-82]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR removes the e2e refusal test for set-scoped reads without repositories and adds `QueryDashboard` and `RequestReport` tests that only cover success statuses. The failure edges of the changed behavior are no longer covered.

## Fix Focus Areas
- go/v1/traust/e2e_test.go[109-110]
- go/v1/traust/reports_test.go[19-82]

## Recommended Fix
Add an e2e case asserting that `QueryDashboard` without `RepositoryIds` returns a 422 `ProblemError` with a non-empty request id, mirroring the removed count test. In `reports_test.go`, add table cases using `traustest.Problem` for `POST /v1/dashboards:query` and `POST /v1/reports` (for example a 422 and a 5xx) asserting that the call returns a non-nil `ProblemError` with the expected status and no partial result.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. Report download errors lose the order context 📜 Skill insight ◔ Observability
Description
GetReportFileAs returns the error from c.GetReportFile unchanged, so a failed download reports
only the underlying HTTP or transport error with no mention of the report or order being fetched.
The orderID is in scope and would identify the affected resource, but it is not included. Callers
that log or surface this error cannot tell which report failed.
Code

go/v1/traust/reports.go[R39-41]

+	body, err := c.GetReportFile(ctx, orderID)
+	if err != nil {
+		return nil, err
Evidence
The rule requires propagated errors to be wrapped with %w and to name both the operation and the
affected resource. The new GetReportFileAs function returns err from `c.GetReportFile(ctx,
orderID) as-is, although DecodeReportView in the same file wraps its own error with %w`, so the
two boundaries are inconsistent.

go/v1/traust/reports.go[38-44]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `go/v1/traust/reports.go`, `GetReportFileAs` returns the `c.GetReportFile` error without wrapping it. The error does not name the operation or the report's order ID, which callers need to identify the failed report. Compliance rule 4713782 requires `%w` wrapping with operation and resource context at propagation boundaries.

## Fix Focus Areas
- go/v1/traust/reports.go[38-44]

## Recommended Fix
Replace `return nil, err` after `c.GetReportFile` with `return nil, fmt.Errorf("fetching the report file for order %s: %w", orderID, err)`. `fmt` is already imported, and the wrap keeps `errors.Is`/`errors.As` working for callers.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (4)
4. Malformed reports can appear valid 🐞 Bug ≡ Correctness
Description
DecodeReportView decodes only the first JSON value and does not reject null, which leaves a
zero-valued view. When GetReportFileAs receives either a null file or a valid view followed by
another JSON value, it returns a view without an error.
Code

go/v1/traust/reports.go[R28-30]

+	decoder := json.NewDecoder(bytes.NewReader(body))
+	decoder.DisallowUnknownFields()
+	if err := decoder.Decode(&view); err != nil {
Evidence
The new helper makes one decode call and immediately returns the view; its caller passes fetched
file bytes to it. The existing generated-response decoder explicitly rejects a null body,
establishing a different result for that malformed response.

go/v1/traust/reports.go[25-43]
go/v1/traust/client.go[175-187]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DecodeReportView` accepts `null` as a zero-valued view and ignores JSON after the first value.

## Fix Focus Areas
- go/v1/traust/reports.go[25-34]
- go/v1/traust/reports_test.go[113-147]

## Recommended Fix
Reject a null top-level value and require a second decode to return EOF. Add regression cases for null, concatenated JSON values, and trailing non-whitespace content.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


5. Report event time now comes from the worker clock 📜 Skill insight ≡ Correctness
Description
RecordingRun.runHeld now sets capturedAt := time.Now().UTC() after the executor returns, and
record copies that value into provenance.OccurredAt whenever the template leaves it unset.
Previously this field was bound to the core-issued order start time, so the persisted provenance
timestamp no longer originates from core. The value is stored as the record's occurred-at time and
is re-captured on each reclaimed attempt, so a skewed worker clock or a reclaimed run yields a
stored timestamp that core never issued; the PR description calls event time intentionally
independent, so this deviation should be confirmed by the author.
Code

go/v1/ops/recording.go[88]

+	capturedAt := time.Now().UTC()
Evidence
The PR diff removes the check that provenance.OccurredAt equal the server's StartedAt
(record.go) and adds a local capture clock in recording.go, so the recorded event time is now a
worker-side value. The rule requires persisted record timestamps to originate from core, and the
removed server-start binding was the core-provided value.

go/v1/ops/record.go[28-31]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The SDK now stamps `provenance.OccurredAt` with a worker-local capture time (`capturedAt := time.Now().UTC()` in `go/v1/ops/recording.go`, applied in `go/v1/ops/record.go` when the template leaves the field unset). Previously this value was the core-issued order start time, so persisted record timestamps no longer originate from core, which the compliance rule 'Use core-provided recorded timestamps' requires.

## Fix Focus Areas
- go/v1/ops/recording.go[76-112]
- go/v1/ops/record.go[17-31]
- go/v1/ops/recording_test.go[381-415]

## Recommended Fix
Either (a) obtain the event time from a core-provided value on the claim or start response and bind it as before, or (b) if the worker-captured time is intentionally kept, inject the clock (a `func() time.Time` field on `RecordingRun`, defaulting to `time.Now`) instead of calling `time.Now` directly, and document in the code comment why event time is worker-observed rather than core-issued. Update `TestRemediationTemplateRecordsThroughTheRemediationDoor` and the e2e assertion accordingly so they check the chosen source.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


6. Older session tasks fail validation ✓ Resolved

Resolving commit: 76f8d4c

Resolution reason
Documented that legacy run-bound tasks without lease_generation are intentionally rejected and must
be restaged, directed historical reads to ParseRunManifestArtifact (which needs no generation), and
added tests covering legacy rejection, manual tasks, zero generation, and historical manifest digest
retention.
Description
The new session-task schema requires lease_generation whenever run_id is a string, while
retaining schema version 1. A previously valid task with a UUID run ID and no generation now fails
ParseSessionTaskArtifact, and encoding a SessionTask with its new optional Go field unset fails
through the same validator.

7. Reclaim replay test reuses the first attempt's event time ✓ Resolved

Resolving commit: 76f8d4c

Resolution reason
The test now captures a separate, later event time (reclaimedAt) for the reclaimed attempt's refused
record and its replay, so the replay under the reclaimed generation is exercised with a different
OccurredAt than the original attempt.
Description
TestCoreClaimReclaim captures capturedAt once and passes the same value to the first attempt,
the refused attempts and the replay under the reclaimed generation. In production, runHeld sets
capturedAt := time.Now().UTC() again after the reclaimed worker re-runs the executor, so
provenance.OccurredAt changes between attempts, and the test never checks whether Core still
replays the original assessment, artifact and finding IDs in that case.


Informational

8. Repository guidance names a removed call ✓ Resolved

Resolving commit: 38e606e

Resolution reason
AGENTS.md's "Using the SDK" table and the counts guidance now name QueryDashboard and the report-job
operations (RequestReport/GetReport/GetReportFile/GetReportFileAs) instead of the removed
GetInsight, consistent with go/README.md.
Description
The removal of Client.GetInsight leaves AGENTS.md directing SDK users to call it for dashboards
and rollups. An agent following that repository guidance after this change produces code that cannot
compile, despite the README documenting the replacement operations.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #91
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
✅ Compliance rules (platform): 61 rules
✅ Skills: go-patterns
Review mode: Auto: ⚖️ Balanced: Core dependency pin affects generated artifacts and contract compatibility.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit d1af832 ⚖️ Balanced

Results up to commit 5949ba9 ⚖️ Balanced


No changes from previous review

Results up to commit 3dfcc33 🧠 Deep


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Older session tasks fail validation ✓ Resolved

Resolving commit: 76f8d4c

Resolution reason
Documented that legacy run-bound tasks without lease_generation are intentionally rejected and must
be restaged, directed historical reads to ParseRunManifestArtifact (which needs no generation), and
added tests covering legacy rejection, manual tasks, zero generation, and historical manifest digest
retention.
Description
The new session-task schema requires lease_generation whenever run_id is a string, while
retaining schema version 1. A previously valid task with a UUID run ID and no generation now fails
ParseSessionTaskArtifact, and encoding a SessionTask with its new optional Go field unset fails
through the same validator.

2. Reclaim replay test reuses the first attempt's event time ✓ Resolved

Resolving commit: 76f8d4c

Resolution reason
The test now captures a separate, later event time (reclaimedAt) for the reclaimed attempt's refused
record and its replay, so the replay under the reclaimed generation is exercised with a different
OccurredAt than the original attempt.
Description
TestCoreClaimReclaim captures capturedAt once and passes the same value to the first attempt,
the refused attempts and the replay under the reclaimed generation. In production, runHeld sets
capturedAt := time.Now().UTC() again after the reclaimed worker re-runs the executor, so
provenance.OccurredAt changes between attempts, and the test never checks whether Core still
replays the original assessment, artifact and finding IDs in that case.

Results up to commit 76f8d4c 🧠 Deep


No changes from previous review

Results up to commit 9f67faf ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (1)


Remediation recommended
1. Report event time now comes from the worker clock 📜 Skill insight ≡ Correctness
Description
RecordingRun.runHeld now sets capturedAt := time.Now().UTC() after the executor returns, and
record copies that value into provenance.OccurredAt whenever the template leaves it unset.
Previously this field was bound to the core-issued order start time, so the persisted provenance
timestamp no longer originates from core. The value is stored as the record's occurred-at time and
is re-captured on each reclaimed attempt, so a skewed worker clock or a reclaimed run yields a
stored timestamp that core never issued; the PR description calls event time intentionally
independent, so this deviation should be confirmed by the author.
Code

go/v1/ops/recording.go[88]

+	capturedAt := time.Now().UTC()
Evidence
The PR diff removes the check that provenance.OccurredAt equal the server's StartedAt
(record.go) and adds a local capture clock in recording.go, so the recorded event time is now a
worker-side value. The rule requires persisted record timestamps to originate from core, and the
removed server-start binding was the core-provided value.

go/v1/ops/record.go[28-31]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The SDK now stamps `provenance.OccurredAt` with a worker-local capture time (`capturedAt := time.Now().UTC()` in `go/v1/ops/recording.go`, applied in `go/v1/ops/record.go` when the template leaves the field unset). Previously this value was the core-issued order start time, so persisted record timestamps no longer originate from core, which the compliance rule 'Use core-provided recorded timestamps' requires.

## Fix Focus Areas
- go/v1/ops/recording.go[76-112]
- go/v1/ops/record.go[17-31]
- go/v1/ops/recording_test.go[381-415]

## Recommended Fix
Either (a) obtain the event time from a core-provided value on the claim or start response and bind it as before, or (b) if the worker-captured time is intentionally kept, inject the clock (a `func() time.Time` field on `RecordingRun`, defaulting to `time.Now`) instead of calling `time.Now` directly, and document in the code comment why event time is worker-observed rather than core-issued. Update `TestRemediationTemplateRecordsThroughTheRemediationDoor` and the e2e assertion accordingly so they check the chosen source.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Results up to commit bda29df ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (3)


Remediation recommended
1. Refusal paths of new endpoints untested 📜 Skill insight ▣ Testability
Description
The PR deletes the e2e test asserting a 422 problem with a request id when set-scoped counts are
requested without repositories, and removes the matching refusal case from the set-scoped summaries
test. The replacement TestE2EQueryDashboardCountsARepositorySet covers only the success path, so
the refusal edge of QueryDashboard is no longer exercised. The new unit tests
TestQueryDashboardPostsQueryAndDecodesRows and TestRequestReportHandlesReady200AndQueued202
cover only 200 and 202 responses, so a regression in error decoding for these endpoints would pass
the suite.
Code

go/v1/traust/e2e_test.go[L109-110]

-func TestE2ECountFindingsInRefusesWithoutRepositories(t *testing.T) {
-	resp, err := e2eClient(t).CountFindingsInWithResponse(context.Background(), &CountFindingsInParams{})
+func TestE2ERequestReportQueuesAndReadsStatus(t *testing.T) {
+	format := ReportFormatJson
+	report, err := e2eClient(t).RequestReport(context.Background(), ReportRequest{
+		Report: ViewNameOf[FindingsRollupInsight](),
+		Format: &format,
+	})
Evidence
The removed TestE2ECountFindingsInRefusesWithoutRepositories was the only refusal-edge test for a
set-scoped read, and no replacement asserts the 422 problem path for QueryDashboard. The new unit
tests for QueryDashboard and RequestReport contain only success statuses, leaving the failure
edges of changed behavior uncovered.

go/v1/traust/reports_test.go[18-82]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR removes the e2e refusal test for set-scoped reads without repositories and adds `QueryDashboard` and `RequestReport` tests that only cover success statuses. The failure edges of the changed behavior are no longer covered.

## Fix Focus Areas
- go/v1/traust/e2e_test.go[109-110]
- go/v1/traust/reports_test.go[19-82]

## Recommended Fix
Add an e2e case asserting that `QueryDashboard` without `RepositoryIds` returns a 422 `ProblemError` with a non-empty request id, mirroring the removed count test. In `reports_test.go`, add table cases using `traustest.Problem` for `POST /v1/dashboards:query` and `POST /v1/reports` (for example a 422 and a 5xx) asserting that the call returns a non-nil `ProblemError` with the expected status and no partial result.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Report download errors lose the order context 📜 Skill insight ◔ Observability
Description
GetReportFileAs returns the error from c.GetReportFile unchanged, so a failed download reports
only the underlying HTTP or transport error with no mention of the report or order being fetched.
The orderID is in scope and would identify the affected resource, but it is not included. Callers
that log or surface this error cannot tell which report failed.
Code

go/v1/traust/reports.go[R39-41]

+	body, err := c.GetReportFile(ctx, orderID)
+	if err != nil {
+		return nil, err
Evidence
The rule requires propagated errors to be wrapped with %w and to name both the operation and the
affected resource. The new GetReportFileAs function returns err from `c.GetReportFile(ctx,
orderID) as-is, although DecodeReportView in the same file wraps its own error with %w`, so the
two boundaries are inconsistent.

go/v1/traust/reports.go[38-44]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In `go/v1/traust/reports.go`, `GetReportFileAs` returns the `c.GetReportFile` error without wrapping it. The error does not name the operation or the report's order ID, which callers need to identify the failed report. Compliance rule 4713782 requires `%w` wrapping with operation and resource context at propagation boundaries.

## Fix Focus Areas
- go/v1/traust/reports.go[38-44]

## Recommended Fix
Replace `return nil, err` after `c.GetReportFile` with `return nil, fmt.Errorf("fetching the report file for order %s: %w", orderID, err)`. `fmt` is already imported, and the wrap keeps `errors.Is`/`errors.As` working for callers.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. New exports widen API without an endpoint 📜 Skill insight ⌂ Architecture
Description
ViewNameOf and DecodeReportView are new exported functions in reports.go. GetReportFileAs
already wraps DecodeReportView around the GetReportFile endpoint, but DecodeReportView is a
standalone JSON decoder that backs no endpoint and provides no extension point, yet is exposed to
consumers as a supported symbol. ViewNameOf only maps a generated type to a view name; its
intended public role is not stated in the code or PR description, so later signature changes would
break SDK users.
Code

go/v1/traust/reports.go[R19-26]

+func ViewNameOf[T any, PT insightView[T]]() ViewName {
+	return PT(nil).insightName()
+}
+
+// DecodeReportView decodes a JSON report file body strictly as view T's contracts ViewModel
+// (such as FindingsRollupInsight). Any field outside the contract is an error, never dropped.
+func DecodeReportView[T any, PT insightView[T]](body []byte) (*T, error) {
+	name := PT(nil).insightName()
Evidence
DecodeReportView is exported and called directly only by GetReportFileAs and by tests feeding it
captured fixture bodies, with no endpoint of its own. ViewNameOf is used only in request
construction and tests. Neither is clearly an extension point or core endpoint, so the rule asks for
justification or unexported helpers.

go/v1/traust/reports.go[18-34]
Skill: go-patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ViewNameOf` and `DecodeReportView` are exported from `go/v1/traust/reports.go` but are not tied to an endpoint or an extension point. `GetReportFileAs` is the endpoint-backed API.

## Fix Focus Areas
- go/v1/traust/reports.go[18-34]
- go/v1/traust/reports_test.go[149-206]

## Recommended Fix
If `DecodeReportView` is needed only by `GetReportFileAs` and tests, rename it to `decodeReportView` and keep the exported surface to `GetReportFileAs` and `ViewNameOf`, or document in the package comment why each remaining export is endpoint-backed or an extension point. Update the tests in `reports_test.go` to exercise the decoder through `GetReportFileAs`, or add an internal test file in package `traust` for the unexported decoder.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (1)
4. Malformed reports can appear valid 🐞 Bug ≡ Correctness
Description
DecodeReportView decodes only the first JSON value and does not reject null, which leaves a
zero-valued view. When GetReportFileAs receives either a null file or a valid view followed by
another JSON value, it returns a view without an error.
Code

go/v1/traust/reports.go[R28-30]

+	decoder := json.NewDecoder(bytes.NewReader(body))
+	decoder.DisallowUnknownFields()
+	if err := decoder.Decode(&view); err != nil {
Evidence
The new helper makes one decode call and immediately returns the view; its caller passes fetched
file bytes to it. The existing generated-response decoder explicitly rejects a null body,
establishing a different result for that malformed response.

go/v1/traust/reports.go[25-43]
go/v1/traust/client.go[175-187]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DecodeReportView` accepts `null` as a zero-valued view and ignores JSON after the first value.

## Fix Focus Areas
- go/v1/traust/reports.go[25-34]
- go/v1/traust/reports_test.go[113-147]

## Recommended Fix
Reject a null top-level value and require a second decode to return EOF. Add regression cases for null, concatenated JSON values, and trailing non-whitespace content.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational
5. Repository guidance names a removed call ✓ Resolved

Resolving commit: 38e606e

Resolution reason
AGENTS.md's "Using the SDK" table and the counts guidance now name QueryDashboard and the report-job
operations (RequestReport/GetReport/GetReportFile/GetReportFileAs) instead of the removed
GetInsight, consistent with go/README.md.
Description
The removal of Client.GetInsight leaves AGENTS.md directing SDK users to call it for dashboards
and rollups. An agent following that repository guidance after this change produces code that cannot
compile, despite the README documenting the replacement operations.

Results up to commit 38e606e ⚖️ Balanced


No changes from previous review

Grey Divider

Qodo Logo

@pshickeydev

Copy link
Copy Markdown
Member Author

/agentic_review

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3dfcc33

@pshickeydev

Copy link
Copy Markdown
Member Author

Follow-up to Qodo’s two findings in 76f8d4c:

  1. Legacy session tasks: The incompatibility is intentional for execution: an ordered task without a claim generation must be restaged, not assigned the generation of a later claim (contracts policy). Added Go parser/encoder regressions and SDK migration guidance. Historical run-manifest entries remain readable with their original task digest and no invented generation. For audit validation of original task bytes, use their original contract revision.
  2. Reclaim event time: TestCoreClaimReclaim now sends a later OccurredAt on the reclaimed attempt. The unchanged payload returns the original assessment, artifact and finding IDs; a changed payload on that same generation still returns 409. Core’s live SDK test passed on SQLite and fresh PostgreSQL 16 (2/2); the focused Go task and manifest tests passed as well.

AI-generated with GPT-6.2 Astra.

@pshickeydev

Copy link
Copy Markdown
Member Author

/agentic_review

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 76f8d4c

@pshickeydev
pshickeydev marked this pull request as ready for review November 23, 2026 19:43
@pshickeydev
pshickeydev force-pushed the fix/XWING-3098-integrity branch from 76f8d4c to 732a854 Compare November 23, 2026 19:43
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 23, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 76f8d4c

@smith-xyz smith-xyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generation-bound recording is well-built and live-tested; two notes: silent degraded assessment completions in runner logs, and stale pre-rebase pin SHAs in the PR body (Qodo also has not covered the rebased head). — 0 inline, 2 folded

go/v1/ops/runner.go:117 — This PR makes degraded assessment runs complete with no published audit, yet Run's else-if only logs failed/refused states, so a degraded scan that published nothing leaves no runner log line. Consider a warn for degraded completions, or at least degraded…

go/Makefile:2 — PR body cites contracts 15bded2e3e and core 9423712361, but the rebased head pins 479a9409/af197e1e. Update the description so the verification claim names the pins CI actually drift-checked.

@openshift-ci

openshift-ci Bot commented Nov 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pshickeydev
Once this PR has been reviewed and has the lgtm label, please ask for approval from smith-xyz. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pshickeydev

Copy link
Copy Markdown
Member Author

This comment was generated with AI assistance (Gemini 4 Neon).

Addressed both items in 9f67fafb64:

  1. Degraded completion logging (go/v1/ops/runner.go:117): Runner.Run now routes RunOrderStateDegraded completions through logCompleted, which emits WarnContext("ops: order completed degraded", ...) when err == nil (and ErrorContext if an error occurred). Added TestRunnerLogsDegradedCompletionAtWarn in go/v1/ops/runner_test.go.
  2. Pins and PR description (go/Makefile:2): Regenerated bindings against rebased contracts #185 (58803ea798) and kept CORE_REF at af197e1eda (Core #527's post-rebase follow-ups made no REST/OpenAPI changes, while adopting Core PR #501's /v1/insights removal across traust-sdk and SCI is separate from XWING-3098). Updated the PR description so its cited SHAs match go/Makefile exactly.

Verified: make check-drift fmt-check vet and go test ./..., all passing.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9f67faf

- Bump CONTRACTS_REF to 3ec3df824c (traust-contracts development) and CORE_REF to 7cfad02f39 (traust-core development, with PR #501)
- Support 202 Accepted JSON responses in internal/generate/calls (for POST /v1/reports)
- Normalize multi-format file downloads in internal/generate/openapi/normalize.py so GET /v1/reports/{order_id}/file returns raw []byte across markdown, html, csv, and json
- Replace removed /v1/insights helpers (insight.go) with reports.go (ViewNameOf, DecodeReportView, GetReportFileAs) and add dashboard/report unit and E2E tests
- Clone RunOrder.InputArtifactId in ops.copyOrder for lease snapshot isolation

Assisted-by: Gemini 4 Neon
@pshickeydev
pshickeydev force-pushed the fix/XWING-3098-integrity branch from 9f67faf to bda29df Compare November 24, 2026 05:01
@pshickeydev

Copy link
Copy Markdown
Member Author

This comment was generated with AI assistance (Gemini 4 Neon).

Stacked #88 on top of traust-sdk#91 (fa8c8fdd36, adopting Core PR #501's dashboards query and reports jobs) and regenerated in bda29df3a3 against exact matching pins CONTRACTS_REF=58803ea798 (contracts #185) and CORE_REF=f5e3ab122b (Core #527).

Verified: make check-drift fmt-check vet test and full live E2E (v1/traust + v1/ops) against traust-server built from f5e3ab122b, all passing.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit bda29df

…README/AGENTS docs (XWING-3098)

Assisted-by: Gemini 4 Neon
… completions, align Core#527 pin (XWING-3098)

Stacked on traust-sdk#91 (fa8c8fd, dashboards query & reports jobs):
- Keep failed/degraded/refused assessment runs out of completed assessments and log degraded completions at WARN
- Bind heartbeats, recordings, and completions to the claimed lease_generation
- Regenerate bindings against traust-contracts#185 (58803ea798) and traust-core#527 (f5e3ab122b)

Assisted-by: GPT-6.2 Astra
Assisted-by: Gemini 4 Neon
@pshickeydev
pshickeydev force-pushed the fix/XWING-3098-integrity branch from bda29df to 38e606e Compare November 24, 2026 05:51
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 38e606e

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d1af832

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