Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"backlog": "ai-driven-dev/framework#913",
"written_at": "2026-10-08T20:03:30Z",
"written_by": "aidd-pm:04-spec"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
My confidence level of correctness now: 100%

# Correctness (100%)

- Le verdict porte sur le contrat V2 convenu dans [spec.md](spec.md), ses sept critères de phase et les limites de couverture explicites. [review.md](review.md) les vérifie tous après réparation, sans finding ouvert.
- Le besoin réel est satisfait: la règle et la guidance utilisateur apparaissent dans l'entrée système du vrai OpenCode V2 2.0.22, contrairement à la source modulaire et au marqueur config-only du baseline. La capture du binaire réparé confirme le résultat; les captures de changement et suppression démontrent l'absence de texte obsolète. Preuves: [verification.md](verification.md), [runtime-results.json](runtime-results.json).
- **Amended:** F1 est corrigé par prévalidation du remplacement avant suppression, sans publication intermédiaire; seuls les fichiers effectivement matérialisés deviennent actifs. F2 est corrigé par validation après stripping frontmatter, après rendu du scope et sur la contribution finale. Les tests ont reproduit les défauts avant réparation; les régressions FS/manifest et le premier write CLI refusé vérifient les garanties attendues.
- Préservation et ownership servent aussi les cas destructifs: octets externes et project memory préservés, bloc modifié refusé, retrait de la dernière contribution sans effacement de guidance, maintien des sources indépendantes lors d'uninstall. AGENTS.md n'entre jamais dans l'ownership entier du manifest.
- **Deviations:** aucune divergence ouverte au plan. Le préflight canonique conservateur peut refuser une règle unsafe qu'un build flat résolu ignorerait; `cli/README.md:221` expose ce comportement, nécessaire pour couvrir le fallback catalogue absent. Il ne fait pas charger une règle ignorée par le build.
- **Out of scope:** V1, runtime Linux/Windows, autres releases V2 non exercées, distribution flat #789, Kilo et production de project memory. Les documents ne prétendent pas les avoir validés. L'absence de transaction sur erreur I/O était explicite avant livraison; la garantie vérifiée est le refus des états unsafe avant mutation.
- Placement, DRY et limites restent cohérents: déclaration host dans tools, materialization dans framework, production knowledge dans aidd-context, aucun nouveau runtime dependency ni ratchet relâché. Bundle 744,10/750 KB, marge 0,79%; checks et suites requis verts dans [implementation-verification.md](implementation-verification.md).

# Deal breakers

- Aucun ouvert dans le contrat convenu. Aucun retour Frame ou Deliver restant.

# Suggestions (enhancements only)

- Aucune nécessaire pour ce périmètre.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Implementation verification

Verified on 2026-10-08 in the working tree. No commit, push, staging or independent review was performed by the implementation agent.

## Delivered behavior

The OpenCode profile declares publication into a signed, bounded `AGENTS.md` contribution. Its pure formatter preserves bytes outside that contribution, including project memory. Framework publication reads editable Markdown sources, validates prospective source writes/removals and existing ownership before mutation, and uses the existing realpath boundary guard. The command works without a manifest:

```sh
aidd framework rules --tool opencode --publish
aidd framework rules --tool opencode --write .opencode/rules/01-standards/1-rule.md --from /tmp/staged-rule.md
aidd framework rules --tool opencode --delete .opencode/rules/01-standards/1-rule.md
```

Install, update, restore, fallback plugin materialization, removal and clean share the publication operation. `AGENTS.md` is not registered as an owned file. Untracked rule sources remain active when installed sources are removed. The bundled config retains its schema and drops its inert rule glob; direct publication preserves existing JSON/JSONC bytes. Generator and exploration documentation now distinguish sources from active V2 guidance.

## Test-first evidence

- The formatter and publication tests initially failed because their production modules did not exist.
- The installation regression failed with `expected 'User instructions\r\n' to contain 'Installed rule text'` and `promise resolved ... instead of rejecting`. It then passed after publication and ownership preflight were connected.
- The built CLI regression exposed missing-directory handling with `ENOENT ... scandir ... .opencode/rules/`; it passed after an absent source directory was treated as an empty set.
- Planted edited, duplicate and incomplete contributions, reserved markers, incomplete frontmatter, NUL text, unbalanced fences and an external rule-directory symlink prove refusal before source or instruction mutation. Fenced marker examples remain repeatable.

## Final checks

- `pnpm --dir cli lint`: exit 0, 1018 files checked. One existing warning in unchanged `uninstall-use-case.ts` about its unused private filesystem member remains.
- `pnpm --dir cli typecheck`: exit 0.
- `node scripts/check-cli-type-honesty.mjs`: no widening or compiler-silencing directive.
- `pnpm --dir cli knip`: exit 0.
- `pnpm --dir cli test:arch`: 27 files, 142 tests passed. No ratchet or baseline was relaxed.
- `pnpm --dir cli test`: 538 files passed, 6870 tests passed; one existing conditional Kilo runtime test skipped because `KILO_RUNTIME_SMOKE` was not enabled. OpenCode's required real-host proof was run separately by the parent.
- `node scripts/check-tests-leave-git-alone.js -- node --test 'scripts/__tests__/**/*.test.js'`: 554 passed, zero failed/skipped.
- Root architecture, context imports, reference form, referenced paths, documentation duplication, Markdown links, argument hints and changed JSON validation: exit 0. `git diff --check`: clean.
- `pnpm --dir cli build`: `OK: within budget`, measured 744.10 KB against 750 KB. Isolated HEAD measured 733.98 KB. The recorded increase is 10.12 KB, with 0.79% headroom and no new runtime dependency.

The first full CLI sweep identified expected help/config snapshot drift and obsolete config assertions, plus a current-version runtime-helper backfill regression. All were repaired; targeted checks and the final full sweep passed. Golden changes are limited to the rules command help and the OpenCode config digest.

## Runtime and limits

The parent's [runtime verification](verification.md) and retained `runtime-results.json` record five actual OpenCode V2 2.0.22 journeys against local inference: baseline, publication, direct staged generation, source update and last-source deletion. Exact active rule text and user guidance reached model input; the instructions-only marker stayed absent. Runtime coverage is macOS arm64 only. V1, native per-rule glob filtering and flat archive rule distribution remain outside this delivery.

Individual filesystem writes use the existing port; this operation preflights unsafe state, but does not introduce a transaction or rollback for subsequent filesystem I/O failure. Independent Check remains the parent's responsibility.

## Repairs after independent Check

The checker requested F1 and F2 repairs. Both were reproduced with new tests before changing production code.

- F1: a real filesystem and persisted manifest test with an unavailable catalogue showed two prior plugin files disappearing after an unsafe replacement was rejected. The same unsafe canonical input was accepted with a resolved catalogue. Replacement now preflights the complete old-to-prospective source transition before deletion or manifest mutation, deletes without intermediate publication, and then publishes from actually materialized files. Three integration cases prove unchanged old rule/agent/config/instruction/manifest bytes on refusal, and prove a safe canonical rule skipped by a resolved build never becomes active. The source preflight is conservative: unsafe canonical rule inputs can be rejected even when a resolved build would skip them. This limitation is stated in the CLI reference.
- F2: two formatter cases, a prospective publication case and a built CLI case initially accepted markers exposed by stripping YAML frontmatter. Validation now scans the parsed body and rendered scope instructions, and revalidates the complete composed contribution before any write. The first staged write refuses the exact checker witness with unchanged sources and user guidance. Existing genuinely fenced body examples still pass and remain idempotent. Ordinary rendered bytes and command procedure are unchanged.

The repaired targeted suite passed 26 tests. The final full CLI sweep passed 6870 tests across 538 files, with the same existing conditional Kilo skip; architecture passed 142 tests and scripts passed 554. Lint, typecheck, knip, type honesty, root guards and the 744.10 KB build passed. One initial lint sweep encountered a temporary hook-test probe created concurrently by the scripts suite; rerunning after that suite cleaned up passed with only the unchanged private-member warning. No independent assessment was performed by the repair agent. The candidate is ready for the same checker's re-Check.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# OpenCode instruction contract verification

Checked on 2026-10-08 before planning or implementation. These are documentation findings, not runtime verification.

## V1
- [Rules](https://opencode.ai/docs/rules/#custom-instructions): project guidance is loaded from AGENTS.md; additional paths and globs in configuration.instructions contribute instruction content alongside it. CLAUDE.md is a compatibility fallback.
- [Configuration format](https://opencode.ai/docs/config/#format): JSON and JSONC are supported, including comments and trailing commas.
- The rules guide documents no automatic scan of .opencode/rules/. A modular file placed there needs explicit configuration wiring under the V1 contract.

## V2
- [Configuration](https://opencode.ai/v2/docs/config#instructions): instructions is accepted but its entries are not loaded; use AGENTS.md for active instructions.
- [Instruction configuration](https://opencode.ai/v2/docs/instructions#configuration): files, glob patterns and URLs in instructions are not resolved.
- [Instruction scope](https://opencode.ai/v2/docs/instructions#scope): V2 recognizes AGENTS.md only and has no CLAUDE.md fallback. Ambient and nested instruction discovery have their own documented scope and ordering.
- The [migration guide](https://opencode.ai/v2/docs/migrate-v1/) still lists instructions among fields requiring no migration. This conflicts with the explicit limitation in both dedicated guides. Do not infer active instruction loading from schema acceptance or that migration summary; require a runtime witness for any shipped claim.

## Impact on #913
The issue's September 24 contract assumes that configuration-backed modular rules reach OpenCode's instructions. Current official documentation supports that design for V1, but explicitly rejects its effectiveness in V2.

Choose one contract before implementation:
1. Retain the V1 design and explicitly disclose the V2 limitation.
2. Extend the outcome to V1 and V2, revisiting the issue's decision that AGENTS.md is not the destination for modular rules. Agree preservation and ownership before projecting a V2 adaptation.

Decision recorded after verification: target V2 only. Publish active rule text through its documented AGENTS.md surface, preserving user content. The original config-backed design is superseded for this delivery; do not extend V1 claims.

The local opencode binary reported 1.14.20. This establishes only the installed version; it does not validate either instruction contract.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
status: done
---

# Instruction: Safe OpenCode V2 rule publication
## Architecture projection
```txt
cli/src/contexts/tools/domain/profiles/opencode/ create rule-block host formatter; modify profile contract
cli/src/contexts/tools/domain/capabilities/ modify rule capability only if a generic host declaration is needed
cli/src/contexts/framework/application/ create shared publication operation; modify rule write/restore/remove entry points
cli/src/presentation/commands/framework.ts modify existing rules command to expose direct publication
cli/src/runtime/wiring/framework.ts modify composition wiring
cli/tests/ create mirrored formatter/publication tests; extend lifecycle and command coverage
cli/ARCHITECTURE.md clarify rule publication versus project-memory production
cli/package.json update measured bundle ceiling under existing growth policy
cli/scripts/check-bundle-size.mjs record measured size and feature cost in the existing registry
```
Create only the smallest helper and dependency entry point needed; preserve context directions and the four-use-case orchestration rule. No deletion is planned.

## User Journey
```mermaid
flowchart TD
Rules[Modular rule sources] --> Preflight[Validate existing contribution and requested source changes]
Preflight --> Publish[Publish rule text in AGENTS.md]
Publish --> Host[OpenCode V2 receives active rules]
Preflight -->|Unsafe existing contribution| Refuse[Actionable error before mutation]
```

## Test Scope
```mermaid
journey
section Setup
Prepare modular rules and user guidance => isolated project ready: 5: system
section Happy path
Publish rules => active text in AGENTS.md: 5: cli
Repeat publication => byte-identical output: 5: cli
section Edge case - changed source
Edit or delete a rule => obsolete active text replaced or removed: 1: cli
section Edge case - user edit
Edit owned block => publication fails without file mutations: 1: cli
section Edge case - cleanup
Remove installed sources => only intact owned text removed: 1: cli
```

## Tasks to do
1. Write failing behavior tests before production changes. Cover preserved user bytes and memory block, LF/CRLF, deterministic order, rule scope prose, duplicate/incomplete markers, edited-block refusal, code-fence examples and idempotence.
2. Implement the host formatter and one framework operation. Validate all sources and existing ownership before writes. Do not add AGENTS.md to the manifest's owned-file list.
3. Expose direct publication through the existing rule command without a manifest requirement. Generator callers must be able to preflight prospective rules before writing them; provide a safe input route through the same operation if necessary.
4. Integrate preflight/publication into the relevant existing install/update/sync/removal/clean paths that can change OpenCode rule sources. Empty rule sets must not create an unrelated AGENTS.md. Preserve any unrelated tools and user-scope behavior.
5. Cover refusal before source mutation, source and last-source deletion, and lifecycle cleanup. Document actual limitations rather than hiding unsupported flows.
6. Measure the final bundle and document its growth using the existing budget policy, with at most about 2% headroom. Keep every other gate and dependency cap unchanged.

## Test acceptance criteria
| Task | Acceptance criteria |
| --- | --- |
| 1–2 | Invalid contributions fail; safe publication preserves bytes outside the owned block and is deterministic and idempotent. |
| 3–4 | Direct generation and CLI lifecycle paths use the same publication contract; stale content is removed; AGENTS.md is never owned as a whole. |
| 5 | Focused regressions and architecture checks pass; planted unsafe input proves that the guards reject it. |
| 6 | The built bundle passes its documented ceiling, with at most about 2% measured headroom and no other guard relaxed. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
status: done
---

# Instruction: Generator contract and OpenCode V2 runtime evidence
## Architecture projection
```txt
plugins/aidd-context/skills/05-rule-generate/ modify detection, generation, safety and validation contract
plugins/aidd-context/skills/11-explore/references/ai-mapping.md modify contradictory OpenCode rule claim
cli/README.md document direct publication and V2 limitations
cli/assets/configs/opencode/opencode.json remove an inert managed instruction glob if now obsolete; preserve other settings
scripts/__tests__/ extend generator contract guard if behavior assertions are needed
cli/tests/e2e/ add built-CLI publication journeys using isolated projects
aidd_docs/tasks/2026_10/2026_10_08_opencode-rule-discovery/ add verification report and retained capture evidence references
```
No deletion is planned. Reuse existing documentation instead of adding competing rule contracts.

## User Journey
```mermaid
flowchart TD
Detect[Detect OpenCode project] --> Generate[Generate modular rule through safe publication]
Generate --> Start[Start isolated OpenCode V2]
Start --> Capture[Capture model request locally]
Capture --> Verify[Assert rule text and preserved user guidance are present]
```

## Test Scope
```mermaid
journey
section Setup
Prepare isolated V2 profile and fake model => no paid inference: 5: system
section Happy path
Generate a rule => built CLI safely publishes it: 5: cli
Start V2 => captured model context contains exact rule text: 5: cli
section Edge case - inert configuration
Reference a separate marker only through instructions => captured context excludes it: 1: cli
section Edge case - rerun and removal
Rerun then delete source and republish => no duplication and no obsolete active text: 1: cli
```

## Tasks to do
1. Reconcile the existing generator and exploration instructions around the verified V2 contract. Detect .opencode/, opencode.json and opencode.jsonc. Write modular sources and publish active text through phase 1's shared safe operation; never claim links or config entries activate V2 rules.
2. Make the direct-generation operation preflight safety before changing either its source or AGENTS.md. Explain a missing CLI or unsafe block precisely, with no partial-write fallback.
3. Build the CLI and reproduce generation, rerun, update and stale-rule deletion in throwaway projects. Run the real V2 2.0.22 binary against a local model capture server with isolated profile directories; preserve the user's installed binary and credentials.
4. Assert exact rule text and preserved user guidance in model input, with a config.instructions-only marker as a negative witness. Record commands, version, platform, observed output and any untested platforms honestly.
5. Run required completion checks and return the candidate for an independent checker. No self-review, commit or push.

## Test acceptance criteria
| Task | Acceptance criteria |
| --- | --- |
| 1–2 | Generator and exploration agree; safe direct generation works from each detection signal and refuses unsafe state before mutation. |
| 3–4 | Built CLI and real V2 journey prove active content consumption; output files alone are not accepted as runtime proof. |
| 5 | Required checks pass; remaining limitations are explicit; independent review receives the source, contract, plan and evidence. |
Loading
Loading