Skip to content

✨ Tell agents to stage ephemeral files in /tmp - #84

Merged
djzager merged 2 commits into
konveyor:mainfrom
fabianvf:staging-rules
Aug 3, 2026
Merged

djzager merged 2 commits into
konveyor:mainfrom
fabianvf:staging-rules

Conversation

@fabianvf

@fabianvf fabianvf commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #53, refs #70.

The agent's working directory is the git worktree the harness pushes at the end of a stage, but nothing tells the agent that, so it treats the repo as scratch space. Gave it a skill that only said "write the script to a file, make it executable, run it" — it wrote to /workspace/repo/verify.sh and left /tmp empty. Same skill with this change goes to /tmp.

Rule's in the harness rather than in each SkillCard since it's about the environment, not the skill. Emitted first so a skill that does say where to write can't override it.

Also moved prompt assembly out of main into internal/prompt while I was in there. Build is a pure function over a Layers struct and the prompt env vars moved into config.LoadFromEnv with the rest, so env reads stay in one package. Can split that out if you'd rather review the behaviour change on its own.

Summary by CodeRabbit

  • New Features

    • Added layered prompt composition for agent, workflow, skill, and stage instructions.
    • Added support for loading prompt context from environment configuration.
    • Staging rules now direct ephemeral files to /tmp instead of the repository working tree.
    • Workflow guidance supports a preferred setting with fallback compatibility.
    • Added fallback guidance when no skill instructions are available.
  • Bug Fixes

    • Prompts now consistently follow the intended layer order and newline formatting.
  • Tests

    • Added coverage for prompt ordering, staging-rule precedence, empty layers, formatting, and configuration fallbacks.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f83551b-7ded-48dc-9516-fec5ec09600b

📥 Commits

Reviewing files that changed from the base of the PR and between f9ec140 and 261421c.

📒 Files selected for processing (7)
  • changes/unreleased/staging-rules.yaml
  • harness/cmd/migration-harness/main.go
  • harness/cmd/migration-harness/main_test.go
  • harness/internal/config/config.go
  • harness/internal/config/config_test.go
  • harness/internal/prompt/prompt.go
  • harness/internal/prompt/prompt_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • changes/unreleased/staging-rules.yaml
  • harness/internal/config/config.go
  • harness/cmd/migration-harness/main.go
  • harness/internal/prompt/prompt_test.go
  • harness/internal/config/config_test.go

📝 Walkthrough

Walkthrough

The migration harness now uses internal/prompt to build ordered stage prompts from environment-backed context and stage data. The prompt includes staging rules and is submitted to ACP.

Changes

Layered prompt assembly

Layer / File(s) Summary
Prompt context loading
harness/internal/config/config.go, harness/internal/config/config_test.go
Config now loads agent, workflow, and stage instruction context. Workflow loading prefers KONVEYOR_WORKFLOW_GUIDE and falls back to KONVEYOR_PLAYBOOK_INSTRUCTIONS.
Prompt layers and composition
harness/internal/prompt/prompt.go, harness/internal/prompt/prompt_test.go, changes/unreleased/staging-rules.yaml
The new package defines Layers and Build. Build emits staging rules first, omits empty layers, orders content from least to most specific, applies no-skill fallback guidance, and enforces one trailing newline.
Harness stage prompt submission
harness/cmd/migration-harness/main.go
The migration harness builds stagePrompt through prompt.Build, submits it to ACP, and removes the local prompt builder.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Config
  participant migrationHarness
  participant promptPackage
  participant ACP
  Config->>migrationHarness: provide environment-backed prompt context
  migrationHarness->>promptPackage: build stagePrompt from configured layers
  promptPackage-->>migrationHarness: return ordered stagePrompt
  migrationHarness->>ACP: submit stagePrompt
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required ✨ alias and clearly states the primary change: staging ephemeral files in /tmp.
Description check ✅ Passed The description explains the behavior change, design rationale, prompt refactor, and references the related issues; the required changelog fragment is present.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: build linters: plugin(logcheck): plugin "logcheck" not found
The command is terminated due to an error: build linters: plugin(logcheck): plugin "logcheck" not found


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment on lines +19 to +22
Write ephemeral files to /tmp, never into the repository working tree:
- scripts you need to run: write them to /tmp, make them executable there,
and run them from there
- scratch notes, plans, logs, and intermediate output

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bit that makes scripts work. Rest of the prompt is unchanged, output's byte-identical to main once you strip this block off the front.

@djzager djzager left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor — the Layers struct and pure Build function are clean. Six comments, mostly about naming coordination with #80 and a couple of prompt-text suggestions.

Comment thread harness/internal/config/config.go Outdated
Comment thread harness/internal/prompt/prompt.go
Comment thread harness/internal/config/config.go Outdated
Comment thread harness/internal/prompt/prompt.go Outdated
Comment thread harness/internal/prompt/prompt.go
Comment thread harness/internal/prompt/prompt.go Outdated
fabianvf and others added 2 commits August 3, 2026 10:57
The agent's working directory is the git worktree whose commits the harness
pushes to the user's branch at the end of a stage. Nothing tells the agent that,
so it treats the worktree as scratch space.

Given a skill that said only "write the script to a file, make it executable,
run it", claude-sonnet-5 wrote to /workspace/repo/verify.sh and left /tmp empty.
Re-running the same skill with only this change:

  before:  tool: write · /workspace/repo/verify.sh
  after:   tool: shell · cat > /tmp/verify.sh << 'EOF'

The rule goes in the harness rather than in each SkillCard because it describes
the execution environment, not any particular skill — relying on every skill
author to restate it is how it gets forgotten. It is emitted first so a skill
that does say where to write cannot read as overriding it.

Prompt assembly moves out of main into internal/prompt, alongside the other
harness packages. Build is a pure function over an explicit Layers struct; the
prompt env vars join the rest in config.LoadFromEnv, so env access stays in one
package and the composition is testable without touching the environment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
Rename the config fields to say what they are: AgentPrompt, WorkflowGuide,
StageInstructions. cfg.Instructions was ambiguous next to the model and
provider fields.

Read KONVEYOR_WORKFLOW_GUIDE, falling back to KONVEYOR_PLAYBOOK_INSTRUCTIONS.
that merge rather than depending on merge order. Drop the fallback once konveyor#80 has
landed everywhere.

Correct the staging rules: the harness commits .gitignore and
.konveyor/analysis.json itself, so "you decide what gets committed" overstated
the agent's control.

Rename the ## Migration Context header to ## Workflow Guide. The prompt package
is general purpose and shouldn't hardcode migration.

Always end the prompt with exactly one newline. Sections appended "\n\n" but
StageTask appended nothing, so the ending varied with whether a stage task was
set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>

@djzager djzager left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@djzager
djzager merged commit 9b5bcad into konveyor:main Aug 3, 2026
15 checks passed
@fabianvf
fabianvf deleted the staging-rules branch August 3, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants