Skip to content

Scope Copilot session artifacts to the current job - #78804

Merged
lpcox merged 11 commits into
mainfrom
copilot/do-not-copy-copilot-session-history
Nov 18, 2026
Merged

lpcox merged 11 commits into
mainfrom
copilot/do-not-copy-copilot-session-history

Conversation

@lpcox

@lpcox lpcox commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

An empty AWF session directory could trigger collection of the runner user’s entire Copilot history, exhausting disk and feeding unrelated sessions into artifact parsing.

  • Collection: Remove the $HOME/.copilot/session-state fallback; collect only AWF-managed job state.
  • Empty state: Warn and exit successfully without copying when job state is missing, empty, or contains no redactable files.
  • Regression coverage: Exercise those cases alongside populated historical sessions; preserve nested job-file collection and redactable-file filtering.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@lpcox lpcox changed the title [WIP] Fix issue with copying runner user's entire Copilot session history Scope Copilot session artifacts to the current job Nov 17, 2026
@lpcox
lpcox marked this pull request as ready for review November 17, 2026 19:08
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 19:08
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output. Detected threat types: prompt injection.

Review the workflow run logs for details.

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #78804 · copilot · gpt56 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.7K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by Ponytail Reviewer for #78804 · codex · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-17T19:11:51Z
review_event: COMMENT
top_themes:
  - durable session capture still falls back to runner HOME
files_reviewed:
  - actions/setup/sh/copy_copilot_session_state.sh
  - pkg/workflow/copilot_session_copy_test.go
  - actions/setup/js/durable_session.cjs
comment_count: 1
History

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.5K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found one correctness gap: the shell copy step no longer falls back to HOME, but durable session capture still does, so historical Copilot sessions may remain in scope for durable workflows. Please align both capture paths. No tests were run per static-review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.5K
Comment /review to run again


AWF_SESSION_STATE_DIR="${GH_AW_COPILOT_SESSION_STATE_DIR:-/tmp/gh-aw/sandbox/agent/session-state}"
LEGACY_SESSION_STATE_DIR="${GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR:-$HOME/.copilot/session-state}"
SESSION_STATE_DIR="${GH_AW_COPILOT_SESSION_STATE_DIR:-/tmp/gh-aw/sandbox/agent/session-state}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This removes the HOME fallback only from this shell copy step, but durable_session.cjs still independently falls back to $HOME/.copilot/session-state, so unrelated historical sessions can still be captured during durable capture; please update that path or otherwise make both capture mechanisms use the same AWF-managed source.

💡 Keep durable session capture scoped consistently

captureCopilotSessions still builds a candidate list containing path.join(home, ".copilot/session-state") and recursively copies the first non-empty candidate. As a result, this change does not fully enforce the stated isolation boundary for workflows using durable capture. Remove the HOME candidate (and add regression coverage) or explicitly gate it to a compatible, job-owned directory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Durable capture now uses the baseline session UUID and copies only that session from AWF state or COPILOT_HOME; it does not recursively copy HOME history. The direct-mode exact-session path is covered by regression tests (aa87696).

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-bd443b2c-de35-46ea-999a-8b34feb8532e","parents":[],"payload":{"id":"ldg-3524973d-0557-4a19-9945-eb39df9d1bb6","operation":"append","value":{"finding_count":0,"head_sha":"c86a7f4074e90602d22a40226a10f9abc65d8982","outcome":"aligned"}},"sha":"sha256:e390ebeabdd1cb6a4566c5b034eb72034ab1520b6e6a4545b2f330b41e69b6bd","timestamp":"2026-11-17T19:15:51.554Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-b93aef18-bef3-4a36-a2f4-1b283badf48e","parents":[],"payload":{"id":"ldg-77d1364c-43de-462a-a908-c3a357782e55","operation":"append","value":{"finding_count":1,"head_sha":"c86a7f4074e90602d22a40226a10f9abc65d8982","outcome":"findings"}},"sha":"sha256:4d0b468ce5693c4dba8ba7c90cdfde474ef5ab2d867864ca67c106352e64331d","timestamp":"2026-11-17T19:16:40.930Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /tdd (test coverage and hygiene) and /diagnosing-bugs (root cause vs symptom). The fix addresses the root cause by removing the $HOME fallback rather than guarding it. Targeted tests (go test ./pkg/workflow -run TestCopilotSession) pass and shellcheck is clean. One small cleanup is suggested inline.

📋 Key Themes & Highlights

Key Themes

  • Dead test override: GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR is still set by the test helper but no longer read by the script.
  • Adjacent fallback (outside this diff): actions/setup/js/durable_session.cjs (captureCopilotSessions, line 38) still falls back to ~/.copilot/session-state, the same runner-HOME history pattern this PR removes. Its test (durable_session.test.cjs, line 138) codifies that behavior, so it looks deliberate. Worth a follow-up issue rather than a blocker here.

Positive Highlights

  • ✅ Root-cause fix: the HOME fallback is removed, not just guarded.
  • ✅ Regression tests cover empty, missing, and non-redactable AWF directories while populated legacy sessions exist, and assert no legacy reference and no logs directory.
  • ✅ Nested job-file collection and redactable-file filtering are preserved and tested.
  • ✅ The unusable-directory warning is asserted, so the behavior is observable.

@copilot please address the review comment above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

overrides := map[string]string{
"GH_AW_COPILOT_SESSION_STATE_DIR": awfDir,
"GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR": legacyDir,
"GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR": filepath.Join(homeDir, ".copilot", "session-state"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR is now dead: copy_copilot_session_state.sh no longer reads it, so this override has no effect. Keeping it implies the legacy path is still configurable and makes the test look like it covers an env-driven fallback.

💡 Suggested change

Delete the GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR entry from overrides. Keep HOME set to homeDir so a reintroduced $HOME fallback is still caught.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removed the unused GH_AW_COPILOT_LEGACY_SESSION_STATE_DIR override and kept HOME isolated in the test helper. Commit 7ed2edc9.

@lpcox

lpcox commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address all review feedback

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The session-state copy logic drops valid direct-mode artifacts, causing resumed durable CLI jobs to fail with ENOENT when events.jsonl is missing.

1 open issue
What changed in this PR

Scopes gh-aw’s Copilot session-log collection to AWF-managed job state, preventing unrelated runner history from filling artifacts and exhausting disk.

Changes:

  • Removes the runner HOME fallback and exits successfully with a warning when job state is missing, empty, or contains no redactable files.
  • Adds regression coverage with populated historical sessions while preserving nested-file collection and redactable-file filtering.
File Description
pkg/​workflow/​copilot_session_copy_test.go Tests job-only collection and skipped collection despite populated historical sessions.
actions/​setup/​sh/​copy_copilot_session_state.sh Removes the HOME fallback and handles unusable job state without copying.

Review effort: Max (adaptive)

Comment on lines 37 to 39
if [ ! -d "$SESSION_STATE_DIR" ] || ! has_redactable_files "$SESSION_STATE_DIR"; then
echo "::warning::No Copilot session state files found in $SESSION_STATE_DIR"
exit 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Direct-mode durable capture now selects only the session UUID recorded in the capture baseline, and the shell collector uses that same UUID filter. Regression coverage exercises the direct-mode path without restoring an unbounded HOME fallback (aa87696).

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@lpcox

lpcox commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot address all review feedback

Fixed direct-mode durable collection to copy only the session UUID from its capture baseline, and narrowed durable checkpoints to that session. Added regression coverage; commit aa87696a.

Copilot AI commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

@copilot fix this failing ci check https://github.com/github/gh-aw/actions/runs/44160393757/job/134312571413?pr=78804

The Copilot-session Go/JS tests and final make agent-report-progress pass. The linked run fails in Aider parser attribution tests, which I reproduced locally; those tests and parser files are unchanged by this patch, so I kept the fix scoped. Commit 7ed2edc9 contains the review cleanup.

@copilot address all review feedback

Addressed the review findings: durable capture is scoped to the current session UUID, and the test no longer sets the unused legacy override. Commit 7ed2edc9.

Comment thread actions/setup/js/durable_session.cjs Outdated
const source = candidates.find(directory => fs.existsSync(directory) && fs.readdirSync(directory).length);
const baseline = readCopilotCaptureBaseline(destination);
if (!baseline) {
console.info("Copilot did not produce native durable session files");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot use correct logging infrastructure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Replaced the ad hoc console.info calls with the durable-session logger and updated the regression test. Commit 0d9801ce.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check lint-go-custom (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "0d9801ce2ed518a85283a9274e7deeb08e8ab143",
  "kind": "requested",
  "schema_version": "1",
  "state": "3607de81362a799f2cf0df04ee273925fcc1b86ea50d7c1bda0b68058848241d",
  "work": [
    "41c633c50467b0f2dc87116833139ebf287e1ad59f1a015d8d1dfedd9d1b23f1"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 18, 2026 01:59
…opilot-session-history

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Updated the PR branch from main in 2b00f6d4 without changing the Copilot session files. Fixed lint-go-custom in 07ad7917: the warning step now builds its own analyzer. I ran the exact step locally; it exited 0 and emitted warning annotations. The targeted Copilot and Aider tests also passed. I did not dispatch or rerun CI.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check impacted-go-tests (FAILURE): Check run.
  3. Fix failing check JS Tests (shard 7/8) (FAILURE): Check run.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "07ad79173a08b4e9f204aa9eae763ce14c154e9b",
  "kind": "requested",
  "schema_version": "1",
  "state": "56a5b9dd1130e1b42cb0f00875348a49d5b85d526e6595817a190cecb7c3e8c1",
  "work": [
    "42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac",
    "47f188a12b316525c2202f4f75b82185d76be0a140c0f99eae185cf2b7d8acb1"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 18, 2026 02:44
…opilot-session-history

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Merged main in 1317631a without changing the Copilot session code. Commit 19947810 updates the two failing tests for router/economy while retaining the Linter Miner sub-agent catalog checks. Focused Go and JavaScript tests passed locally; the broader checks were not yet confirmed. I did not dispatch or rerun CI.

SOURCE_DIR=""
if [ -n "$SESSION_ID" ]; then
COPILOT_HOME="${COPILOT_HOME:-$HOME/.copilot}"
for candidate in "$SESSION_STATE_DIR" "$COPILOT_HOME/session-state"; do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Capture baselines now include the current GITHUB_RUN_ID and GITHUB_RUN_ATTEMPT; stale baselines are ignored by copy, capture, and trim paths. Regression coverage was added in c42f900.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

Threat detection engine error

Threat detection could not complete its analysis due to a tooling error. This is not a security finding.

What happened

The threat detection results could not be parsed.

Review the workflow run logs to troubleshoot the error.

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "19947810a5d57549f97d8ee60074231bd6790900",
  "kind": "requested",
  "schema_version": "1",
  "state": "cc13d3d500c1033648315823113037e6f4ab5b9536c464aff0b4df4fc4ff626e",
  "work": [],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 18, 2026 04:09
…opilot-session-history

# Conflicts:
#	.github/workflows/cgo.yml
#	actions/setup/js/resolve_model_alias.test.cjs

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

[!WARNING]
Threat detection engine error
...

Merged the latest main into this branch in 4119f45 and resolved the merge conflicts.

@lpcox
lpcox merged commit 834ce4f into main Nov 18, 2026
90 checks passed
@lpcox
lpcox deleted the copilot/do-not-copy-copilot-session-history branch November 18, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not copy the runner user’s entire Copilot session history when job session state is empty

6 participants