For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Upload supported PDF/PPTX/DOCX/HTML/image results shown by selected historical conversation turns even when their generating tools did not register formal artifact attachments.
Architecture: Extend conversationRowsRangeV4 with the projection revision so the share service can query selected turn headers through conversationFileChangesV4 at one revision/epoch. Materialize explicit artifact rows and supported file-change candidates through one async local source, deduplicate by canonical realpath with explicit rows winning, synthesize transient artifact rows, then reuse the existing public projection and prepare/upload/confirm pipeline.
Tech Stack: TypeScript, Zod, Vitest, Node async file APIs, ZCode V4 conversation protocol, existing conversation-share service and HTTP client.
b7c52e49a2.pnpm typecheck and pnpm lint before completion.Files:
packages/shared/src/zcode-protocol-v4/transport.tsapps/zcode-cli/packages/bootstrap/src/zcode-protocol-v4/conversation-topic-publisher.tsapps/zcode-cli/packages/bootstrap/tests/conversation-topic-publisher.test.tsV4ConversationRowsRangeResult in affected tests.Interfaces:
V4ConversationRowsRangeResult.atRevision: number.Consumes: current ConversationSnapshot.revision from ConversationTopicPublisher.
[ ] Step 1: Write the failing protocol/publisher test
Assert that publisher.getRowsRange(...) returns both atLogEpoch and the current snapshot atRevision, and that a structural event changes the returned revision.
Run: pnpm vitest run apps/zcode-cli/packages/bootstrap/tests/conversation-topic-publisher.test.ts
Expected: FAIL because atRevision is absent.
Add this required field to the strict result schema:
atRevision: z.number().int().nonnegative(),
Return snapshot.revision from getRowsRange. Update typed fixtures mechanically; do not make the field optional.
Run: pnpm vitest run apps/zcode-cli/packages/bootstrap/tests/conversation-topic-publisher.test.ts
Expected: PASS.
Files:
packages/services/src/conversation-share/conversationShareArtifactSource.tspackages/services/test/conversationShareArtifactSource.test.tsInterfaces:
ConversationShareMaterializedArtifact { bytes: Uint8Array; canonicalPath: string }.Changes: ConversationShareArtifactSource.read(input) returns the materialized object instead of bare bytes.
[ ] Step 1: Write the failing canonical-path test
Assert that reading a workspace file returns its bytes and canonical realpath, while outside paths and outward symlinks still fail closed.
Run: pnpm vitest run packages/services/test/conversationShareArtifactSource.test.ts
Expected: FAIL because read currently returns only Uint8Array.
Keep the current async realpath -> open -> stat -> bounded read sequence and change only the successful return shape:
return { bytes: new Uint8Array(buffer.subarray(0, bytesRead)), canonicalPath: artifactRealPath };
Run: pnpm vitest run packages/services/test/conversationShareArtifactSource.test.ts
Expected: PASS.
Files:
packages/services/src/conversation-share/conversationShareService.tspackages/services/test/conversationShareService.test.tsInterfaces:
conversationRowsRangeV4, conversationFileChangesV4, ConversationShareArtifactSource.read.Produces: the unchanged IConversationShareService.publishTextConversation API and unchanged HTTP DTOs.
[ ] Step 1: Write failing service tests for SHARE08-SHARE11
Add focused tests proving:
selected PDF + PPTX fileChanges -> prepare(count=2) -> two uploads -> confirm
unselected turn or unsupported source file -> no artifact IO/upload
formal artifact + fileChanges same canonicalPath -> one upload, formal metadata wins
reverted fileChanges -> no discovered artifact
rows pagination watermark mismatch or stale fileChanges query -> fail before preparation
Use a fake source that returns real bytes plus canonical paths; assert on request bodies and orchestration order, not only mock call counts.
Run: pnpm vitest run packages/services/test/conversationShareService.test.ts
Expected: FAIL because the service neither calls conversationFileChangesV4 nor creates transient artifact rows.
Refactor loadAllRows to return:
{ rows: ConversationRow[]; revision: number; logEpoch: string }
Require every page to have identical atRevision and atLogEpoch; otherwise throw invalid_conversation before any preparation request.
After selection, for each selected terminal turnHeader whose fileChanges.files > 0, call:
conversationFileChangesV4({
workspacePath,
workspaceIdentity,
sessionId,
target: { rowId: header.rowId, entityId: header.entityId! },
baseRevision: watermark.revision,
baseLogEpoch: watermark.logEpoch,
});
Require the stable entityId needed by the V4 target. Map stale revision/epoch failures to invalid_conversation; propagate other structured service failures.
Normalize the item extension and match it against capabilities.allowed_artifacts. Materialize explicit rows first, then selected active file-change candidates. For discovered candidates derive MIME/type from the matched capability, compute current size and SHA-256, and build deterministic transient ArtifactRow values associated with the selected header.
Deduplicate by canonicalPath; explicit rows win. Unsupported extensions, unselected turns, and state: "reverted" create no transient row. Enforce count/byte limits after the merged set is known.
Insert each transient artifact after the source turn's existing selected rows, call buildConversationSharePublicProjection, and upload the already materialized bytes in deterministic row order. Do not reread files after preparation. Preserve confirmed-preparation short-circuit semantics without uploading.
Run:
pnpm vitest run packages/services/test/conversationShareService.test.ts packages/services/test/conversationShareArtifactSource.test.ts
Expected: PASS.
Files:
docs/testing/conversation-session-e2e-coverage-matrix.md statuses for SHARE08-SHARE11 after tests pass.Review all task files only.
[ ] Step 1: Run affected package tests
Run protocol/publisher, service, source, public-projection, and HTTP-client focused tests.
Run:
pnpm typecheck
pnpm lint
Expected: exit 0; existing warnings may remain but no new errors.
Verify no assistant/Bash text parsing, no workspace scan, no sync file IO, no token/file-content logs, no remote/mobile behavior change, and no unrelated dirty files are staged.
[ ] Step 4: Commit
git add <only task files>
git commit -m "fix(conversation-share): upload historical result files"