Deterministic no-code-change comment-body builder (buildNoCodeChangeCommentBody) #303

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

Summary

Create the single, deterministic, unit-testable function that produces the comment text pi-loop posts on the source issue when the implement agent declares no code is needed (the no-code-change.json short-circuit, ADR-021 §3). This is the first of three standalone modules — it is exported for the pipeline and tests, but not wired into the pipeline yet.

Background

When the implement stage ends with a no-code verdict, pi-loop must post a comment on the source issue explaining why, without closing the issue. The comment body must be composed by plain code from the schema-validated NoCodeChangeArtifact — no new LLM session anywhere on this path. The builder is provider-agnostic: the same body is used whether the issue came from Jira, GitHub, Forgejo, or GitLab, so it must not mention MRs/PRs or include any platform URL/noun.

It mirrors the local buildCommentBody already used inside src/writeback/services/runWriteback.ts (reuse the shape, don't reinvent it). ADR-021 (docs/adr/021-no-code-change-comment.md) is the design record; the frame is fixed pi-loop wording with three fields interpolated verbatim.

The consumed artifact (NoCodeChangeArtifact, already shipped with the existing no-code-change feature) carries type — one of 'database' | 'config' | 'docs' | 'other' — plus reason and workPerformed free-text strings.

Implementation Details

  • Create src/writeback/helpers/buildNoCodeChangeCommentBody.ts:

    export function buildNoCodeChangeCommentBody(
      artifact: NoCodeChangeArtifact,
    ): string
    
  • Render a fixed pi-loop frame interpolating type, reason, and workPerformed verbatim (plain string interpolation — the fields are plain strings, so there are no escaping surprises). Suggested shape (final wording free):

    pi-loop determined no code changes are needed for this issue
    (type: {type}).
    
    Reason: {reason}
    
    Work performed: {workPerformed}
    
    The issue is left open for review — please close it if this resolves it.
    
  • Export the builder from src/writeback/index.ts (the write-back barrel) so the pipeline and tests can import it.

  • Do NOT wrap, truncate, or rephrase the field values — verbatim embedding is the contract (ADR-021 §3).

  • Do not wire anything into the pipeline in this step.

Acceptance Criteria

  • src/writeback/helpers/buildNoCodeChangeCommentBody.ts exists and exports the typed function with the signature above.
  • For each artifact type (database, config, docs, other) the returned body embeds type, reason, and workPerformed byte-for-byte as given.
  • The function is deterministic — identical input yields identical output on every call.
  • The body contains no MR/PR noun (no "pull request", "MR", "merge") and no URL — provider-agnostic.
  • The builder is exported from the src/writeback/index.ts barrel.
  • Unit tests live in src/writeback/helpers/buildNoCodeChangeCommentBody.test.ts and pass.

Test Plan

  • Run the targeted suite: npx vitest run src/writeback/helpers/buildNoCodeChangeCommentBody.test.ts — cover the type matrix (one artifact per type), verbatim field embedding, determinism (call twice, compare output), and absence of MR/URL tokens.
  • npm run lint clean.
## Summary Create the single, deterministic, unit-testable function that produces the comment text pi-loop posts on the source issue when the implement agent declares no code is needed (the `no-code-change.json` short-circuit, ADR-021 §3). This is the first of three standalone modules — it is exported for the pipeline and tests, but **not** wired into the pipeline yet. ## Background When the implement stage ends with a no-code verdict, pi-loop must post a comment on the source issue explaining why, **without closing the issue**. The comment body must be composed by plain code from the schema-validated `NoCodeChangeArtifact` — no new LLM session anywhere on this path. The builder is provider-agnostic: the same body is used whether the issue came from Jira, GitHub, Forgejo, or GitLab, so it must not mention MRs/PRs or include any platform URL/noun. It mirrors the local `buildCommentBody` already used inside `src/writeback/services/runWriteback.ts` (reuse the shape, don't reinvent it). ADR-021 (`docs/adr/021-no-code-change-comment.md`) is the design record; the frame is fixed pi-loop wording with three fields interpolated verbatim. The consumed artifact (`NoCodeChangeArtifact`, already shipped with the existing no-code-change feature) carries `type` — one of `'database' | 'config' | 'docs' | 'other'` — plus `reason` and `workPerformed` free-text strings. ## Implementation Details - Create `src/writeback/helpers/buildNoCodeChangeCommentBody.ts`: ```typescript export function buildNoCodeChangeCommentBody( artifact: NoCodeChangeArtifact, ): string ``` - Render a fixed pi-loop frame interpolating `type`, `reason`, and `workPerformed` **verbatim** (plain string interpolation — the fields are plain strings, so there are no escaping surprises). Suggested shape (final wording free): ``` pi-loop determined no code changes are needed for this issue (type: {type}). Reason: {reason} Work performed: {workPerformed} The issue is left open for review — please close it if this resolves it. ``` - Export the builder from `src/writeback/index.ts` (the write-back barrel) so the pipeline and tests can import it. - Do NOT wrap, truncate, or rephrase the field values — verbatim embedding is the contract (ADR-021 §3). - Do not wire anything into the pipeline in this step. ## Acceptance Criteria - [ ] `src/writeback/helpers/buildNoCodeChangeCommentBody.ts` exists and exports the typed function with the signature above. - [ ] For each artifact type (`database`, `config`, `docs`, `other`) the returned body embeds `type`, `reason`, and `workPerformed` byte-for-byte as given. - [ ] The function is deterministic — identical input yields identical output on every call. - [ ] The body contains no MR/PR noun (no "pull request", "MR", "merge") and no URL — provider-agnostic. - [ ] The builder is exported from the `src/writeback/index.ts` barrel. - [ ] Unit tests live in `src/writeback/helpers/buildNoCodeChangeCommentBody.test.ts` and pass. ## Test Plan - Run the targeted suite: `npx vitest run src/writeback/helpers/buildNoCodeChangeCommentBody.test.ts` — cover the type matrix (one artifact per type), verbatim field embedding, determinism (call twice, compare output), and absence of MR/URL tokens. - `npm run lint` clean.
david closed this issue 2026-09-05 19:01:34 +00:00
Author
Owner

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

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-loop/pulls/313
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#303
No description provided.