Skip to content

[feature] /idd-edit runtime enforcement — proper proposal after 3-iteration bash failure (R1/R2/R3 on #153) #154

@kiki830621

Description

@kiki830621

Problem

Source: surfaced during /idd-verify --pr 153 R3 cluster verify (per IC_R011 — proper-design follow-up after 3-iteration implementation failure).

/idd-editbounded-section-replace (--replace mode) + audit-block-append (--append/--prepend-note) per #150 action-scoped modify discipline (rules/append-vs-modify.md)。 #150 v2.73.0 ship 時宣告 BREAKING runtime enforcement,但實際 bash 落地經過 3 iterations 都失敗:

R1 (commit d643fc6) — 加 Step 1/2/4 enforcement bash

R2 Codex independent revision 捕捉(post-master):

  • B3-NEW-1 CRITICAL: --scope value (space form) parser sets SCOPE_FLAG="next" literal
  • B3-NEW-2 CATASTROPHIC: --body space form → BODY_INPUT="" → silent comment overwrite
  • B3-NEW-3 LOGIC: section replacement awk end_re ignores SECTION_LEVEL,orphans subsections
  • B3-NEW-4 DOC: old usage example without --scope

R3 (commit 5c62b38) — parser rewrite + section level + docs

R3 full 6-AI ensemble verify 捕捉(Logic + DA + Codex triple-confirmed):

  • C1 CRITICAL INFINITE LOOP: trailing space-form flag → shift 2 silently fails on $#=1while [[ $# -gt 0 ]] spins forever
  • C2 CRITICAL flag-value-eat: --scope --body "x" → SCOPE_FLAG="--body" + BODY_INPUT="" (next-token capture without look-ahead)
  • C3 CRITICAL multi-line awk-v BREAK: BSD awk rejects newlines in -v value → awk: newline in string → section-replace DEAD-ON-ARRIVAL for realistic markdown content
  • H1 HIGH --body-file=/missing/path silently produces empty BODY_INPUT → silent comment overwrite
  • F4 MEDIUM (from R2,still standing) errata flow regression on user-authored comments — /idd-comment --type=errata auto-call /idd-edit --prepend-note triggers verbatim-preserve guard refuse if target非 OWNER

Type

feature — proper runtime enforcement implementation (3-iteration failure → needs standalone proposal)

Expected

/idd-edit runtime enforcement landed with:

  1. Parser pattern:positional shift while [[ $# -gt 0 ]]; case "$1" in ... shift / shift 2 ;; esac with explicit missing-value guards:
    --scope) [ -z "${2:-}" ] && abort "--scope requires value"
             [[ "$2" == --* ]] && abort "--scope value cannot start with --"
             SCOPE_FLAG="$2"; shift 2 ;;
    (same guards for all 7 space-form flags: --scope / --section / --reason / --body / --body-file / --repo / --cwd)
  2. Multi-line body handling:write BODY_INPUT to temp file → awk reads via getline new_content < body_file per line(不要用 -v 傳多行)
  3. --body-file readability pre-check:[ -r "${1#--body-file=}" ] || abort "body-file not readable: ..."
  4. Errata flow integration:/idd-comment --type=errata auto-call /idd-edit --prepend-note 偵測 non-OWNER target → auto-pass --override-user-content --reason="errata clarification per IDD discipline"(or refuse with helpful "use --override-user-content" message)
  5. Doc consistency:argument-hint / frontmatter / batch-mode / usage examples all show updated syntax
  6. Test fixtures:cover all R1/R2/R3 edge cases(--scope=value / --scope value / --scope last arg / --scope --body next-flag / --body-file missing / multi-line body / single-line body / section with ### subs / section with no closing heading)

Actual

3 bash-incremental attempts(R1/R2/R3)each introduced new bugs。 Implementation needs proper standalone proposal,not incremental patches。

Why this is a follow-up not a R4 fix

  • R4 bash patch path likely introduces R4 bugs(R1/R2/R3 evidence pattern)
  • Multi-line awk handling needs rewrite(getline pattern),不是 patch
  • Errata flow integration touches /idd-comment SKILL.md not just /idd-edit — cross-skill coordination
  • Acceptance criteria need explicit test fixtures(R1/R2/R3 attempts all missed adversarial patterns via narrow happy-path smoke tests)

Splitting /idd-edit runtime enforcement as its own proposal lets it ship cleanly without blocking #137 + #150 substance(B1 awk fix + B2 BSD head fix + M5 wording + L3 retroactive labels — all solid)。 Spec discipline + AI/user invocation pattern guidance ship today;runtime gate ships post-design。

Sister Concerns

Open Questions

  1. Bash 是否是正確 layer? 3 iterations 都失敗暗示 bash 不是 right tool。 alternative: Rust CLI plugin / Python helper / native flag parsing infrastructure shared across IDD skills
  2. /idd-edit 用 case statement vs argparse-style helper? 7 個 SKILL.md 都需要 flag parsing(idd-comment / idd-issue / etc)— 抽 shared utility?
  3. Multi-line body handling pattern for awk replace:temp-file getline 是 Codex 建議,但需 verify pattern works on macOS BSD awk + gawk + mawk + can handle binary content / unicode
  4. Errata flow integration:/idd-comment 自動 pass --override-user-content 是否違反 IC_R007 spirit(user authored intent vs AI override)? Spec carve-out vs runtime auto-detect?

Routing

  • Complexity:Plan tier(2 SKILL.md changes + multi-line body design + test fixtures + cross-skill /idd-comment integration)— 不是 Spectra(no new published spec contract,extends existing [META] Codify append-vs-modify discipline as plugin-level principle #150 spec implementation)
  • Path:depends on user — direct /idd-implement after diagnose,或 /idd-plan 跑 EnterPlanMode design review first

Residue

本 issue 涵蓋「/idd-edit runtime enforcement bash impl」。 不涵蓋:

  • 廣義 IDD skill flag parsing infrastructure 抽 shared helper(屬另一 follow-up,跨 7+ SKILL.md scope)
  • Rust / Python CLI plugin layer 替代 bash 評估(屬 long-term architecture decision)
  • /idd-comment errata flow 重設計(本 issue 只整合,不重設計)

Current Status

Phase: implemented
Last updated: 2026-05-25 by /idd-update (via /idd-implement — 14 tasks GREEN + PR #159 open)

Key Decisions

Scope Changes

  • (none — diagnosis matches issue body's self-suggested scope)

Blocking

  • (none — ready for /idd-plan EnterPlanMode)

Sister concerns filed

Commits

  • (none yet — diagnose phase)

Next

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions