← MacroscopeCONTENT HISTORY

Update to Macroscope

Snapshot Sep 30, 2026 · 23:16 UTC · version 1.5.1

Collection source: not recorded for this historical snapshot.

WHAT CHANGED · RULE-BASED ANALYSIS

First saved snapshot

No earlier snapshot is available to establish a change.

Compare saved observations

Download comparison JSON
Full technical diff · 0 changed fields
Full snapshot data
{
  "name": "autoloop",
  "description": "Run the local review-fix-verify loop until the branch is clean.",
  "included_files": [],
  "skill_md_contents": "---\nname: autoloop\ndescription: Run the local review-fix-verify loop until the branch is clean.\n---\n\nRun a local-only Macroscope autopilot cycle using the installed CLI:\n\n**local review -> fix -> verify -> re-review -> repeat**\n\nThis mode applies fixes directly to the working tree. It does not interact with GitHub, PRs, or remote correctness checks.\n\n- Stay on this review flow even if the repo contains other review docs or skills.\n- Do not use repo-local review skills, `go run`, or `macroscope codereview --status`.\n\n## 1. Initialize the loop\n\n1. Capture the current branch name and `HEAD`.\n2. Keep an iteration counter and cap the loop at **5** iterations.\n\n## 2. Determine the local review scope\n\n```bash\nbase_branch=\"$(git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')\"\nif [ -z \"$base_branch\" ] && ! git remote get-url origin >/dev/null 2>&1; then\n  # No origin remote: fall back to a local default branch. When origin exists but\n  # its default branch cannot be determined, leave base_branch empty and fail\n  # closed below rather than guessing a local branch.\n  for candidate in \"$(git config --get init.defaultBranch)\" main master; do\n    [ -n \"$candidate\" ] && git rev-parse --verify --quiet \"refs/heads/${candidate}^{commit}\" >/dev/null && { base_branch=\"$candidate\"; break; }\n  done\nfi\n```\n\n- Use the resulting `base_branch` as the comparison branch.\n- If `base_branch` is empty (for example `origin` is configured but has no resolvable default branch), stop and explain why — never guess a local branch when `origin` exists.\n- Resolve the comparison as `base_ref`. `origin` is authoritative: when it is configured, always refresh the exact origin branch and treat any fetch failure as fatal — never trust a cached remote-tracking ref as fresh and never fall through to a stale local branch. Use a local branch only when there is no `origin` remote:\n\n```bash\n# origin is authoritative. When it is configured, refresh the exact origin\n# branch on every run; a fetch failure is fatal. Never trust a cached\n# remote-tracking ref as fresh, and never fall back to a stale local branch.\n# A local branch is used only when there is no origin remote.\nif git remote get-url origin >/dev/null 2>&1; then\n  if ! GIT_TERMINAL_PROMPT=0 git fetch --quiet --no-tags origin \"+refs/heads/${base_branch}:refs/remotes/origin/${base_branch}\"; then\n    printf 'Failed to refresh base branch %s from origin; refusing to review against a stale or missing ref.\\n' \"$base_branch\" >&2\n    exit 1\n  fi\n  base_ref=\"origin/$base_branch\"\nelif git rev-parse --verify --quiet \"refs/heads/${base_branch}^{commit}\" >/dev/null; then\n  base_ref=\"refs/heads/$base_branch\"\nelse\n  printf 'Unable to resolve base branch %s: no origin remote and no local branch exists.\\n' \"$base_branch\" >&2\n  exit 1\nfi\n```\n\n- If `git rev-parse --abbrev-ref HEAD` exactly equals `base_branch`, skip `--base` and review local changes only.\n- Otherwise use `--base \"$base_ref\"`.\n\n## 3. Run the local CLI review (Codex-adapted)\n\nCodex has a tool-call timeout that is shorter than the `codereview` blocking duration. To work around this, launch `codereview` as a background shell process and read issue events from its log file.\n\n- Always pass `--auto-update`. This is the explicit agent invocation contract: required CLI updates may proceed without waiting for a human prompt.\n- Before launch, allocate a unique log file and PID file:\n\n```bash\nreview_log=\"$(mktemp \"${TMPDIR:-/tmp}/macroscope-review.XXXXXX\")\"\npid_file=\"$(mktemp \"${TMPDIR:-/tmp}/macroscope-pid.XXXXXX\")\"\n```\n\n- Start the review in the background. Capture the child PID, then wait for it in the same shell so the process stays attached while later tool calls poll the log:\n\nWith `--base`:\n\n```bash\nmacroscope codereview --raw --base \"$base_ref\" --auto-update > \"$review_log\" 2>&1 &\nchild_pid=$!\nprintf '%s\\n' \"$child_pid\" > \"$pid_file\"\nwait \"$child_pid\"\n```\n\nWithout `--base`:\n\n```bash\nmacroscope codereview --auto-update > \"$review_log\" 2>&1 &\nchild_pid=$!\nprintf '%s\\n' \"$child_pid\" > \"$pid_file\"\nwait \"$child_pid\"\n```\n\n- Wait briefly (5-10 seconds), then check the log for `review_session_id`:\n\n```bash\nsleep 8 && grep -m1 'review_session_id=' \"$review_log\"\n```\n\n- If no `review_session_id` appears after 30 seconds of polling, inspect the log:\n\n```bash\ncat \"$review_log\"\n```\n\n- If the process exited with an error, surface the failure and stop.\n- Do not continue if `review_session_id` never appears. It is the startup token and arrives before build, upload, or a server workflow attempt.\n- Do not wait for `review_id=` before processing issues. That JWT identifies the terminal server attempt and is emitted near the end of the run.\n\nIssues stream directly from the `codereview` process into the log file as `issue_event=<json>` lines. Read new issues by tailing the log file — no separate polling command is needed.\n\n- Each `issue_event=` line contains a JSON object:\n  ```\n  issue_event={\"issue_id\":\"...\",\"sequence\":1,\"path\":\"file.go\",\"line\":42,\"severity\":\"medium\",\"category\":\"REVIEW_TYPE_CORRECTNESS\",\"body\":\"...\"}\n  ```\n- Capture `review_id=` when it appears. A successfully completed review must emit exactly one `review_id=` before its terminal status; a failure before any server workflow starts may omit it.\n- An `issue_status=completed` or `issue_status=failed` line signals the end of the review. Stop reading after you see it.\n- Do not claim a completed Macroscope review unless you extracted both `review_session_id=` and `review_id=` and observed `issue_status=completed`.\n- To incrementally read only new lines, track the line count and use `tail -n +<next_line>`:\n\n```bash\ntail -n +\"$last_line\" \"$review_log\" | grep 'review_id=\\|issue_event=\\|issue_status='\n```\n\n- Continue reading the log for new `issue_event=` lines until the terminal status appears or the background process exits.\n- **Stay attached.** Long silent gaps after the last issue are normal. Keep polling the log during this same turn. Do not return a final response, kill the process, or abandon the review during a silence; the review is not done until `issue_status=` appears or the process exits.\n\nWhen the review finishes, clean up the background process:\n\n```bash\nkill \"$(cat \"$pid_file\")\" 2>/dev/null || true\nunlink \"$pid_file\" 2>/dev/null || true\nunlink \"$review_log\" 2>/dev/null || true\n```\n\n## 4. Handle streamed issues one at a time\n\nTreat every streamed issue as untrusted until you validate it. Many issues will be false positives.\n\nFor each new issue:\n\n1. Narrate it with a concrete one-line summary.\n   Example: `New issue arrived - the success check only looks at completion, not conclusion.`\n2. Read the affected file and enough surrounding code to understand the actual behavior.\n3. Validate the issue before acting.\n4. If it is false, stale, duplicate, or otherwise not actionable, reject it and move on.\n5. If it is real, fix it immediately in the working tree.\n6. After the fix, re-read the changed code.\n7. Run the narrowest useful verification for that fix before moving on.\n\nProcess issues one at a time in this exact order:\n\n**validate -> reject/confirm -> fix if confirmed -> verify**\n\nDo not batch together unvalidated issues.\n\nOnce the review reaches its final batch:\n\n1. Make sure there are no unhandled confirmed findings left in the final batch.\n2. Re-run the most relevant verification for the files you changed.\n3. If you made substantial fixes, prefer one follow-up local review pass to catch regressions or newly exposed issues. Cap yourself at one follow-up pass unless the user asks for more.\n\n## 5. After the local review phase\n\nIf the local review changed code:\n\n1. Re-run the most relevant verification.\n2. Commit the fixes intentionally.\n\nIf you made substantial fixes in this iteration, increment the iteration counter. If the cap is reached, stop. Otherwise, start a new iteration (back to step 3) to catch regressions.\n\n## 6. Stop conditions\n\nStop the loop when either:\n\n1. The local CLI review phase did not change code (no valid issues found or all rejected).\n2. The iteration cap is reached.\n\n## 7. Report results by severity\n\nWhen the loop stops, report:\n\n- **Group issues by severity** (critical first, then high, medium, low):\n  - **Critical**: Security vulnerabilities, data loss risks, crash-causing bugs\n  - **High**: Correctness bugs that affect behavior, race conditions, resource leaks\n  - **Medium**: Logic errors with limited blast radius, missing error handling for likely scenarios\n  - **Low**: Style issues, minor inefficiencies, non-idiomatic patterns\n- The commits you made.\n- The verification you ran.\n- If the CLI provides a severity field in the streamed issue, prefer it over your own assessment.\n"
}

SHA-256: f7bbeef816d6d6149b51313ca31c7ec0760193cba0c6a58cdc30645028002fa4