Skip to content

feat: --goal launch receipts for ccx session attribution - #516

Open
lroolle wants to merge 1 commit into
mainfrom
feat/goal-receipts
Open

feat: --goal launch receipts for ccx session attribution#516
lroolle wants to merge 1 commit into
mainfrom
feat/goal-receipts

Conversation

@lroolle

@lroolle lroolle commented Jul 29, 2026

Copy link
Copy Markdown
Member

Launch receipts (#499): stamp intent at launch so ccx sessions stop
being born orphans.

  • --goal SLUG validates [a-z0-9][a-z0-9-]*, exports DEVA_GOAL
    into the container (create-time env; attach restamps only when a
    fresh --goal is given)
  • appends one JSONL receipt host-side to
    $XDG_DATA_HOME/ccx/launches/YYYY-MM-DD.jsonl with ts, goal, agent,
    cwd, container, source; ccx joins receipt->session by cwd+time
  • receipt write sits after the DRY_RUN gate and is warning-only:
    it never blocks a launch; no --goal = zero behavior change

ccx-side join ships separately. CHANGELOG and DEV-LOGS included.

Closes #499

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 29, 2026 05:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a94fcaaf22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread deva.sh
Comment on lines +4232 to +4233
printf '{"ts":"%s","goal":"%s","agent":"%s","cwd":"%s","container":"%s","source":"deva"}\n' \
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$GOAL" "${ACTIVE_AGENT:-}" "$(pwd)" "$CONTAINER_NAME" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Escape cwd before writing the JSONL receipt

When the workspace's absolute path contains a double quote, backslash, or newline—each valid in a Linux filename—$(pwd) is interpolated directly into the JSON string without escaping. This produces malformed or split JSONL records, so ccx cannot parse the receipt and the new session-attribution feature silently fails for that workspace; serialize these fields with a JSON encoder rather than printf interpolation.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds “launch receipts” to deva.sh so a launch can be attributed to a goal in downstream ccx session reporting. This introduces a new --goal SLUG flag that validates a slug and stamps the launch both in-container (DEVA_GOAL) and host-side (JSONL receipt under the ccx data directory), with documentation updates in the changelog and dev logs.

Changes:

  • Add --goal SLUG parsing/validation and export DEVA_GOAL into the container (create-time and optional attach-time restamp).
  • Append a host-side JSONL launch receipt to $XDG_DATA_HOME/ccx/launches/YYYY-MM-DD.jsonl after the --dry-run gate, warning-only on failure.
  • Document the feature in CHANGELOG.md and DEV-LOGS.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
deva.sh Implements --goal, exports DEVA_GOAL, and writes host-side JSONL launch receipts.
DEV-LOGS.md Adds a dev log entry describing the new --goal launch receipt behavior.
CHANGELOG.md Notes the new feature under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deva.sh
Comment on lines +4225 to +4236
write_launch_receipt() {
[ -n "$GOAL" ] || return 0
local dir="${XDG_DATA_HOME:-$HOME/.local/share}/ccx/launches"
if ! mkdir -p "$dir" 2>/dev/null; then
echo "warning: cannot create $dir; skipping launch receipt" >&2
return 0
fi
printf '{"ts":"%s","goal":"%s","agent":"%s","cwd":"%s","container":"%s","source":"deva"}\n' \
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$GOAL" "${ACTIVE_AGENT:-}" "$(pwd)" "$CONTAINER_NAME" \
>>"$dir/$(date -u +%Y-%m-%d).jsonl" 2>/dev/null ||
echo "warning: failed to write launch receipt" >&2
}
Comment thread deva.sh
Comment on lines 4318 to +4322
if [ "$AUTH_PROVISION_MODE" = true ]; then
docker exec -e "$_trace_env" "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}" || true
docker exec -e "$_trace_env" ${_goal_env[@]+"${_goal_env[@]}"} "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}" || true
finish_auth_provision
else
exec docker exec -e "$_trace_env" "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}"
exec docker exec -e "$_trace_env" ${_goal_env[@]+"${_goal_env[@]}"} "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}"
Comment thread deva.sh
Comment on lines +3204 to +3208
--goal)
if [ $((i + 1)) -ge ${#incoming[@]} ]; then
echo "error: --goal requires a slug" >&2
exit 1
fi
Comment thread deva.sh
Comment on lines +4225 to +4229
write_launch_receipt() {
[ -n "$GOAL" ] || return 0
local dir="${XDG_DATA_HOME:-$HOME/.local/share}/ccx/launches"
if ! mkdir -p "$dir" 2>/dev/null; then
echo "warning: cannot create $dir; skipping launch receipt" >&2
- validate slug, export DEVA_GOAL (create env; attach restamps on
  fresh --goal only)
- append JSONL receipt to $XDG_DATA_HOME/ccx/launches/ after the
  DRY_RUN gate; warning-only on failure, never blocks a launch
- receipts are evidence: ccx data dir, not the ops ledger; ccx joins
  receipt->session by cwd+time (ccx side ships separately)

Refs #499

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 29, 2026 05:48
@lroolle
lroolle force-pushed the feat/goal-receipts branch from a94fcaa to 01dec9e Compare July 29, 2026 05:48
@claude-yolo

claude-yolo Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error after 1s —— View job


I'll analyze this and get back to you.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

deva.sh:4242

  • The launch receipt is formatted as JSON but values like cwd (and potentially agent/container) are not JSON-escaped, so paths containing quotes/backslashes/newlines will produce invalid JSON. Also, date is called twice, which can put a receipt into a different YYYY-MM-DD file than its ts if the call crosses midnight UTC.
    printf '{"ts":"%s","goal":"%s","agent":"%s","cwd":"%s","container":"%s","source":"deva"}\n' \
        "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$GOAL" "${ACTIVE_AGENT:-}" "$(pwd)" "$CONTAINER_NAME" \
        >>"$dir/$(date -u +%Y-%m-%d).jsonl" 2>/dev/null ||
        echo "warning: failed to write launch receipt" >&2

deva.sh:4329

  • The optional _goal_env array is expanded unquoted in the docker exec calls. Even though GOAL is currently validated, quoting the array expansion avoids accidental word-splitting/globbing if this is refactored later.
        docker exec -e "$_trace_env" ${_goal_env[@]+"${_goal_env[@]}"} "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}" || true
        finish_auth_provision
    else
        exec docker exec -e "$_trace_env" ${_goal_env[@]+"${_goal_env[@]}"} "${DOCKER_TERMINAL_ARGS[@]}" "$CONTAINER_NAME" /usr/local/bin/docker-entrypoint.sh "${AGENT_COMMAND[@]}"

deva.sh:161

  • The help text for --goal advertises the slug pattern as ([a-z0-9-]), but the parser enforces ^[a-z0-9][a-z0-9-]*$. Updating the usage text to match the actual validation avoids confusing users.
  --goal SLUG             Stamp this launch with a goal slug ([a-z0-9-]):

lroolle added a commit that referenced this pull request Jul 29, 2026
Decision chain for the #516/#523/#517 stack and issues #518-#524:
scope corrections (ps already existed), stacked-PR reasoning, goal
source-of-truth choice, and the #518 layout decision as the live wire.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

launch receipts: --goal stamps intent for ccx attribution

2 participants