Repository navigation
Conversation
prompt completion for imported artifact inspections read only substeps[0], omitting identifiers from later retained inventory substeps. Collect candidates from all substeps instead, preserving per-substep inventory validation so malformed payloads still yield no candidates. Fixes morluto#3220. Co-authored-by: Saim Shafique <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Greptile P2: guard the per-substep skip so a malformed inventory substep cannot hide valid identifiers from later substeps. Co-authored-by: Saim Shafique <[email protected]>
tsc --noEmit (noUncheckedIndexedAccess) flagged substeps[0] as possibly undefined at tests/boundary/mcp/promptCompletion.test.ts:329. Extract the first substep with an explicit guard instead. Co-authored-by: Saim Shafique <[email protected]>
Co-authored-by: Saim Shafique <[email protected]>
rahul05ranjan
left a comment
There was a problem hiding this comment.
Verified the drop: on the base, evidenceValues for inspect_artifact evidence read only substeps[0]?.evidence.normalized_result, so identifiers from any later retained substep never reached manifest/occurrence completion. Collecting from the whole substeps array is the right shape here — the inspection schema restricts substeps to operation: "inventory_artifact", status: "completed", so there is no other substep kind being missed, and candidates are derived from the schema-parsed data rather than a duplicated list.
The per-substep safeParse + continue is actually a small improvement beyond the reported case: previously a malformed first substep zeroed the entire evidence record, now a malformed substep is skipped while later valid ones still contribute. The second new test covers exactly that. Ordering/dedup are delegated to the outer uniqueSorted + prefix filter in complete(), which matches the sorted/deduplicated contract in docs/mcp-prompts.md, and the test expectations line up with it.
Ran npx vitest run tests/boundary/mcp/promptCompletion.test.ts on the PR head — 8/8 pass, both new multi-substep cases included.
One thing this fix surfaces but doesn't touch: parseArtifactInventoryEvidence (src/domain/artifactInventoryEvidence.ts, the inspect_artifact branch around line 64) still uses the identical substeps[0]?.evidence read, and it feeds compareArtifacts plus the android/apple application parsers. An imported multi-substep inspection passed there still silently compares only the first substep's inventory — same class of drop, with results-affecting rather than completion-only impact. I understand it's out of scope for this PR, but since multi-substep imports are a real retained shape (that's the premise of this fix), it'd be worth a follow-up issue so it doesn't get lost.
|
Closing this as superseded by main — the underlying issue is now handled directly: Appreciate the review @rahul05ranjan — thanks for verifying it on your own machine. |
Summary
Prompt completion for an imported artifact inspection only read the first inventory substep, so identifiers from later retained substeps never appeared. This collects candidates from every completed substep instead. Fixes #3220.
Problem and expected behavior
Importing an Evidence bundle with one inspection holding two inventory substeps offered only the first inventory's manifest and occurrence IDs in guided prompt completion.
docs/mcp-prompts.mdpromises every matching value, sorted and deduplicated.Change and scope
src/server/promptCompletion.ts: gather candidate identifiers from all retained substeps rather thansubsteps[0]. Malformed inventories are still skipped per-substep (safeParse+continue), so invalid payloads never yield candidates. Out of scope: coverage counting and producer output (already single-substep).Scope decision: ordinary fix within existing boundaries; not applicable.
Contract and boundary impact
Semantic owner and earliest changed stage: MCP prompt completion projection; no contract change.
Contribution scope fit and linked maintainer decision: not applicable (ordinary fix).
CLI and MCP/tool-catalog contract: none.
Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Launch or attach to a process.
Inject instrumentation or run scripts/code.
Change process memory, registers, files, or configuration.
Contact network services.
Recover protected code or work around protections.
Documentation or usability only; no target interaction.
Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
Tests added or updated:
tests/boundary/mcp/promptCompletion.test.ts— new case with a two-substep imported inspection. It fails before the fix (only the first manifest ID is offered) and passes after.Base reproduction: the new test reproduces the exact reported symptom on the base revision.
User-visible CLI/MCP output: not applicable (read-only projection over the evidence ledger).
Remaining proof gaps: no real-provider run; completion here is a local session projection.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:focused -- tests/boundary/mcp/promptCompletion.test.ts— 7/7 passnpm run test:focused -- tests/boundary/mcp/promptMcp.test.ts— 9/9 passnpm run test:focused -- tests/boundary/mcp/retainedApplicationEvidenceMcp.test.ts— 5/5 passnpm run test:focused -- tests/boundary/mcp/applicationEvidenceMcp.test.ts— 1/1 passnpm run verify:test-discovery— 1261 test files discovered exactly oncenpm run lint— 0 errorsnpx oxfmt --checkon touched files — cleannpm run typecheck(tsc --noEmit) — 0 errorsCompatibility, safety, and release
Author readiness
Human owner: @sx4im
Before merge
type(scope): outcome.