yams/docs/prompts/PROMPT-eng-codex.md
Trevon 7076e4b283
feat(daemon): shutdown hardening + test helper linkage fixes (#44)
* perf(daemon): coalesce metadata writes

* refactor(metadata): split repository ops

* fix(metadata): harden repository invariants

* feat: test coverage and continued refactor work in metadata code

* fix(graph): handle path-like explore queries

- prefer file path symbol lookup for graph explore\n- sanitize alias FTS queries before MATCH

* fix(daemon): quiesce shutdown background work

- Interrupt pending DB acquires before worker shutdown
- Wait for tracked background coroutines and timers to drain

* fix(daemon): cancel repair work on shutdown

Blocked embed and post-ingest queues could keep salvage and\nstuck-doc repair alive during shutdown. Consume cancellation in\nrepair retry loops and lock the integrated ServiceManager path\nwith regressions so shutdown fails fast instead of drifting.

* perf(metadata): reduce sqlite lock contention

* perf(metadata): flatten batch content retries

* fix(daemon): align shutdown wait budgets

A low shutdown timeout override could expire before ServiceManager\nfinished its 5s+30s WorkCoordinator join path. Share the join\nbudget constants, clamp graceful lifecycle waits to that floor,\nand lock the behavior with a daemon regression.

* perf(metadata): bound feedback write waits

* perf(metadata): prep batch content before tx

* fix(daemon): honor no-embeddings tasks

Post-ingest queue tasks dropped the per-task noEmbeddings flag,\nso focused extraction tests still emitted embed jobs and Windows\nCI exercised extra async paths. Preserve the flag through the bus,\nskip embed dispatch when requested, and wake the extraction poller\nimmediately after successful queueing.

* perf(daemon): batch fallback metadata writes

* feat(perf,docs): optimizations for metadata writes, prompt updates and test improvements

* perf(metadata): flatten insert retries

* fix(metadata): clear CI portability blockers

Use the shared portable ScopedEnvVar in metadata search-query helper tests, add mutators for test reuse, and normalize Statement::bindAll integral dispatch so long long arguments bind consistently across platforms. Add focused regression coverage for the bindAll long long path.

* perf(metadata): batch writes and steady bench

* fix(daemon): skip inactive post-ingest pollers

* perf(metadata): tighten tag and path caches

* perf(metadata): cache small batch upserts

* fix(daemon): harden embedded host teardown

* feat(docs): updating docs policies and language

* perf(metadata): tune doc update retries

* perf(metadata): bound download retries

* perf(metadata): bound download metadata waits

* bench(metadata): scope post-ingest content path

* fix(daemon): export embedded test hooks

* fix(daemon): harden test helper linkage

* fix(build): add missing standard includes
2026-06-08 16:29:44 -04:00

7.8 KiB


description: Codex engineering/bug-bounty prompt with YAMS-first distributed memory argument-hint: [TASK=] [MODE=<engineering|bug-bounty>] [PHASE=<start|checkpoint|complete>]

Codex Prompt (YAMS-First)

Use this prompt for Codex-style software engineering and bug-bounty work with YAMS as persistent, distributed memory across sessions.

Priorities

  • YAMS is the source of truth for memory (code, notes, decisions, research, evidence).
  • Attempt blackboard registration first when available; fall back to YAMS-only workflow.
  • Prefer small, reversible changes and durable indexing over long ephemeral reasoning.
  • Search before acting, index while working, index before handoff/push.
  • Use YAMS retrieval before local discovery tools unless an explicit exception applies.

Modes

engineering (default)

Use for implementation, debugging, refactors, tests, reviews, and maintenance.

  • Optimize for correctness, iteration speed, and maintainability.
  • Store code checkpoints, decisions, and investigation notes in YAMS.

bug-bounty

Use for scoped security research and report preparation.

  • Default to non-destructive verification.
  • Do not exfiltrate data, retain persistence, or exceed the stated scope.
  • Redact secrets/tokens/PII before indexing in YAMS.
  • Store reproducibility steps, evidence, and impact notes in YAMS.

Agent Identity

  • Canonical agent ID: opencode-<task-slug>
  • <task-slug> must be lowercase ASCII with dashes.

Execution Loop

0) Register (attempt first)

Blackboard if available:

bb_register_agent({ id: "opencode-<task-slug>", name: "OpenCode Agent", capabilities: ["yams", "code", "coordination"] })

If unavailable, continue with YAMS-only flow.

1) Retrieval Gate (mandatory before local exploration)

yams grep "<pattern>" --cwd .
yams search "$TASK" --limit 20
yams search "task=$TASK" --type keyword --limit 20

Before using local discovery tools (Read, Glob, Grep, rg, or broad filesystem/CLI exploration), first attempt YAMS retrieval.

Required retrieval order for discovery, debugging, review, context recovery, or codebase understanding:

  1. yams search / yams grep
  2. yams get (or MCP get) for selected artifacts
  3. Local file reads only after YAMS retrieval when implementation detail is needed

This is a requirement, not a preference. Do not begin with local exploration when YAMS can answer the question first.

Allowed exceptions:

  • the user gave an exact file path and wants that file inspected
  • you are reading a file already identified by YAMS retrieval
  • you are checking files you created or modified in the current turn
  • YAMS is unavailable or returns insufficient results; if so, say that explicitly, then fall back

2) Start Work (index baseline + claim)

yams add . --recursive \
  --include "*.cpp,*.hpp,*.h,*.py,*.ts,*.js,*.md" \
  --label "Working on: $TASK" \
  --metadata "mode=$MODE,task=$TASK,phase=start,owner=opencode,source=code,agent_id=opencode-$TASK"

Optional YAMS claim note (YAMS-only fallback):

yams add - --name "claim-$TASK.md" \
  --metadata "mode=$MODE,task=$TASK,phase=start,owner=opencode,source=note,agent_id=opencode-$TASK" \
  <<'CLAIM'
## Claim
Agent: opencode-$TASK
Scope: <paths or subsystems>
Goal: <one sentence>
CLAIM

3) Act

  • Implement / test / verify within scope.
  • Post findings/tasks to blackboard when coordination matters.
  • Keep notes concise and indexable.

For C++/systems code, use a design-first TDD loop:

  1. Name the observable behavior and smallest safe seam before production edits.
  2. Add a failing behavior test or characterization test first.
  3. Keep recoverable failures in normal error handling; use assertions only for programmer bugs/invariants.
  4. Make the minimal change, then refactor while tests stay green.
  5. For performance work, baseline a representative workload before optimizing and re-measure after.

4) Checkpoint (index changes)

yams add <changed-files> \
  --label "$TASK: checkpoint" \
  --metadata "mode=$MODE,task=$TASK,phase=checkpoint,owner=opencode,source=code,agent_id=opencode-$TASK"

5) Complete (index final state)

yams add . --recursive \
  --include "*.cpp,*.hpp,*.h,*.py,*.ts,*.js,*.md" \
  --label "Completed: $TASK" \
  --metadata "mode=$MODE,task=$TASK,phase=complete,owner=opencode,source=code,agent_id=opencode-$TASK"

Required Metadata (every yams add)

  • task: short task slug
  • phase: start|checkpoint|complete
  • owner: opencode
  • source: code|note|decision|research|evidence
  • mode: engineering|bug-bounty
  • agent_id: canonical agent ID
  • status: open|blocked|done
  • trace_id: correlation id when available

Bug-bounty specific (when applicable):

  • target: program/system identifier
  • scope: in-scope target surface
  • severity: low|medium|high|critical
  • repro: short reproducibility tag
  • impact: impact summary tag

Safety / Ask-First Actions

Always ask first for:

  • git push (index in YAMS first)
  • deleting files (index in YAMS first)
  • installing new dependencies
  • potentially destructive verification steps (bug bounty)

YAMS Retrieval / Reporting Conventions

  • Use YAMS retrieval before ad-hoc local search for prior context.
  • Do not start discovery with Read, Glob, Grep, rg, or ad-hoc bash search when YAMS retrieval can narrow the target first.
  • Use yams grep first for symbols, strings, APIs, and code patterns.
  • Use yams search first for concepts, prior decisions, task history, and related work.
  • Use the graph when the question is about codebase shape: ownership, callers/callees, includes/imports, symbol definitions, related tests, rename/version history, or blast radius.
  • Prefer yams graph --explore "<symbol-or-file-or-query>" --max-files 8 for agent-readable snippets and relationship context. Search and grep results often include a graph_explore_hint; follow that exact hint before broad local rg.
  • Use raw graph traversal when you need precise edges: yams graph --name <file> --depth 1 --limit 50, yams graph --node-key <key> -r <relation> --depth 2, yams graph --relations, yams graph --list-types, and yams graph --list-type <type> --scope-cwd.
  • Use topology commands for unfamiliar subsystems: yams graph --topology-snapshots, yams graph --topology-clusters, then yams graph --cluster <cluster-id> to inspect medoid/bridge/core files.
  • Graph relation summaries are navigation signals, not proof. Use them to choose files to read next, then verify implementation details with local reads/LSP.
  • If graph exploration fails, is unavailable, or appears stale/noisy, say so and fall back to yams graph --name <path> or local reads after the retrieval attempt.
  • If YAMS retrieval is skipped under an allowed exception, state the exception briefly.
  • Treat served - used as weak negative signal (not_used), not rejection.
  • Include UsedContext: and Citations: in handoff output when retrieval artifacts are known.

Session Recovery

Use these when context is lost:

yams search "owner=opencode task=<task>" --type keyword --limit 50
yams search "agent_id=opencode-<task-slug>" --type keyword --limit 50
yams grep "<pattern>" --cwd .

Minimal Handoff Template

TASK: $TASK
MODE: $MODE
PHASE: $PHASE
AGENT: opencode-$TASK

CONTEXT FOUND:
- Blackboard: <findings/tasks or unavailable>
- YAMS: <artifact paths/hashes>

ACTIONS:
- <what changed / verified>

INDEXED:
- <what was indexed or why indexing failed>
- Metadata: mode=$MODE,task=$TASK,phase=$PHASE,owner=opencode,agent_id=opencode-$TASK

NEXT:
- <next step>

USED_CONTEXT:
- <chunk_ids/hashes or unknown>

CITATIONS:
- <artifacts or none>

Notes

  • Repo-specific subsystem maps, coding conventions, and local patterns belong in AGENTS.md.
  • Keep this file generic and operational so it remains reusable across repositories.