no-code-change-comment.json marker artifact module #304

Closed
opened 2026-09-05 18:35:02 +00:00 by david · 1 comment
Owner

Summary

Add the schema-validated no-code-change-comment.json marker artifact recording that the explanatory comment was successfully posted on the issue — written only after a successful post, checked before every post attempt (at-most-once, ADR-021 §6).

Background

The no-code-change comment path needs a durable, crash-safe record that the comment was posted. This mirrors the existing idempotency pattern from ADR-018 (mr-result.json) and the existing no-code-change artifact module (src/artifacts/services/noCodeChangeArtifact.ts + src/artifacts/helpers/validateNoCodeChange.ts): the marker is the single source of truth for "already commented" — absent → post, present → skip.

Absence of the file is the normal pre-post state and must read as undefined, not an error. A malformed file (e.g. a truncated write) is a real defect and must throw (ArtifactValidationError, same contract as readNoCodeChangeSignal). This module is standalone — no pipeline wiring in this step.

Implementation Details

  • Create src/artifacts/helpers/validateNoCodeChangeComment.ts, mirroring validateNoCodeChange.ts:

    export interface NoCodeChangeCommentArtifact {
      /** Issue key the comment was posted on (e.g. `ABC-123`). */
      issueKey: string;
      /** ISO-8601 timestamp of the successful post. */
      postedAt: string;
    }
    export function validateNoCodeChangeCommentArtifact(
      value: unknown,
    ): NoCodeChangeCommentValidation;
    

    Same validation-result shape as the existing validator: rejects missing/empty/whitespace issueKey, missing/empty/non-string postedAt, and non-object input.

  • Create src/artifacts/services/noCodeChangeCommentArtifact.ts, mirroring noCodeChangeArtifact.ts:

    • NO_CODE_CHANGE_COMMENT_FILENAME = 'no-code-change-comment.json'
    • noCodeChangeCommentPath(runDir): string
    • writeNoCodeChangeCommentSignal(runDir, artifact) — validate first, then write.
    • readNoCodeChangeCommentSignal(runDir) — returns undefined when the file is absent; throws ArtifactValidationError when content is malformed.
  • Export the filename constant, service functions, validator, and types from src/artifacts/index.ts.

Acceptance Criteria

  • validateNoCodeChangeCommentArtifact accepts { issueKey: 'ABC-123', postedAt: '<ISO-8601>' } and rejects missing/empty issueKey, missing/empty postedAt, and non-object input.
  • Write/read round-trip in a temp run dir returns the identical artifact.
  • Reading from a run dir without the file returns undefined.
  • Reading a malformed file throws ArtifactValidationError.
  • NO_CODE_CHANGE_COMMENT_FILENAME === 'no-code-change-comment.json' and noCodeChangeCommentPath places the file under the run dir.
  • All new symbols exported from src/artifacts/index.ts; unit tests in src/artifacts/helpers/validateNoCodeChangeComment.test.ts and src/artifacts/services/noCodeChangeCommentArtifact.test.ts pass.

Test Plan

  • Targeted unit tests per above (temp run-dir fixtures): npx vitest run src/artifacts/helpers/validateNoCodeChangeComment.test.ts src/artifacts/services/noCodeChangeCommentArtifact.test.ts
  • npm run lint clean.
## Summary Add the schema-validated `no-code-change-comment.json` marker artifact recording that the explanatory comment was successfully posted on the issue — written only after a successful post, checked before every post attempt (at-most-once, ADR-021 §6). ## Background The no-code-change comment path needs a durable, crash-safe record that the comment was posted. This mirrors the existing idempotency pattern from ADR-018 (`mr-result.json`) and the existing no-code-change artifact module (`src/artifacts/services/noCodeChangeArtifact.ts` + `src/artifacts/helpers/validateNoCodeChange.ts`): the marker is the **single source of truth** for "already commented" — absent → post, present → skip. Absence of the file is the normal pre-post state and must read as `undefined`, not an error. A malformed file (e.g. a truncated write) is a real defect and must throw (`ArtifactValidationError`, same contract as `readNoCodeChangeSignal`). This module is standalone — no pipeline wiring in this step. ## Implementation Details - Create `src/artifacts/helpers/validateNoCodeChangeComment.ts`, mirroring `validateNoCodeChange.ts`: ```typescript export interface NoCodeChangeCommentArtifact { /** Issue key the comment was posted on (e.g. `ABC-123`). */ issueKey: string; /** ISO-8601 timestamp of the successful post. */ postedAt: string; } export function validateNoCodeChangeCommentArtifact( value: unknown, ): NoCodeChangeCommentValidation; ``` Same validation-result shape as the existing validator: rejects missing/empty/whitespace `issueKey`, missing/empty/non-string `postedAt`, and non-object input. - Create `src/artifacts/services/noCodeChangeCommentArtifact.ts`, mirroring `noCodeChangeArtifact.ts`: - `NO_CODE_CHANGE_COMMENT_FILENAME = 'no-code-change-comment.json'` - `noCodeChangeCommentPath(runDir): string` - `writeNoCodeChangeCommentSignal(runDir, artifact)` — validate first, then write. - `readNoCodeChangeCommentSignal(runDir)` — returns `undefined` when the file is absent; throws `ArtifactValidationError` when content is malformed. - Export the filename constant, service functions, validator, and types from `src/artifacts/index.ts`. ## Acceptance Criteria - [ ] `validateNoCodeChangeCommentArtifact` accepts `{ issueKey: 'ABC-123', postedAt: '<ISO-8601>' }` and rejects missing/empty `issueKey`, missing/empty `postedAt`, and non-object input. - [ ] Write/read round-trip in a temp run dir returns the identical artifact. - [ ] Reading from a run dir without the file returns `undefined`. - [ ] Reading a malformed file throws `ArtifactValidationError`. - [ ] `NO_CODE_CHANGE_COMMENT_FILENAME === 'no-code-change-comment.json'` and `noCodeChangeCommentPath` places the file under the run dir. - [ ] All new symbols exported from `src/artifacts/index.ts`; unit tests in `src/artifacts/helpers/validateNoCodeChangeComment.test.ts` and `src/artifacts/services/noCodeChangeCommentArtifact.test.ts` pass. ## Test Plan - Targeted unit tests per above (temp run-dir fixtures): `npx vitest run src/artifacts/helpers/validateNoCodeChangeComment.test.ts src/artifacts/services/noCodeChangeCommentArtifact.test.ts` - `npm run lint` clean.
david closed this issue 2026-09-05 19:10:20 +00:00
Author
Owner

pi-loop opened and merged a pull request for this issue: #314

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-loop/pulls/314
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-loop#304
No description provided.