aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

Harden /review_prs Stage-2 sketch against `args` arriving as a JSON string

Aperta Adatta ai principianti
#670 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement P2
Lingua principale
TypeScript
Stelle
143
Fork
46
Merge medio
3g 10h
PR unite (30g)
24

Descrizione

## Problem

The `/review_prs` command (`.abca/commands/review_prs.md`) documents Stage 2 with an *illustrative* `Workflow` sketch (lines ~142–164) that the operator regenerates per invocation. That sketch iterates the PR descriptors with `args.map(...)` directly.

In practice the `Workflow` harness may deliver `args` to the script as a **JSON-encoded string** rather than a parsed array — even when the caller passes a genuine JSON array in the `Workflow` tool call. When that happens the script throws immediately:

```
Error: args.map is not a function ('args.map' is undefined)
```

before any review agent spawns. Because the skill is (correctly) a sketch that gets regenerated each run, every regeneration risks re-hitting this footgun. Observed live during the carve S1–S8 stacked-PR review train (2026-07-28): the first Workflow launch died in ~7ms with `agent_count: 0`; a one-line defensive unpack fixed it and the resumed run proceeded normally.

## Why not freeze the whole script into the skill

The sketch is intentionally adaptable — N==1 skips the Workflow, arg modes differ (explicit list vs. `review-requested:@me` vs. NL filter), and diff baselining differs for a *stack* (each PR vs its parent branch) vs. a flat batch (each vs `main`). Freezing a full script would bake away that variance and pull orchestration mechanics back into a skill that deliberately stays a thin orchestrator. So the fix is a **doc hardening**, not a canned script.

## Proposed fix (small, docs-only)

In the Stage-2 sketch, unpack defensively before iterating and add a half-sentence caveat:

```js
// Workflow may deliver `args` as a JSON string; tolerate either form.
const prs = typeof args === 'string' ? JSON.parse(args) : args
const results = await parallel(prs.map((pr) => () => agent(...)))
```

Add one line to the Notes / Stage-2 prose noting that `Workflow` args can arrive JSON-encoded, so generated scripts should normalize before `.map`.

## Scope

- Docs only: `.abca/commands/review_prs.md`.
- No code, no CDK, no agent-runtime change.
- Self-sufficiency bar for the skill is preserved: a competent agent regenerating the script from the prose will no longer trip on the string/array ambiguity.

## Acceptance criteria

- [ ] Stage-2 sketch normalizes `args` (string-or-array) before `.map`.
- [ ] A one-line caveat in the prose explains why.
- [ ] No other behavior change; the sketch remains a sketch (not a frozen script).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Apri .abca/commands/review_prs.md e leggi lo schema Stage-2 intorno alle righe 142–164, insieme alla prosa di Notes. Aggiorna lo schema e la spiegazione in modo che Workflow args vengano normalizzati, indipendentemente dal fatto che arrivino come JSON string o come array, prima di usare .map. Il lavoro è completato quando i due criteri di accettazione sono riflessi in questo file senza modificare il comportamento adattabile dello schema.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
1/5
Tempo stimato
Meno di un'ora
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
92/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.