Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
drive the review-loop local-LLM reviewer through the stdin bridge instead of HTTP (#7670)
[._.]/ Adam Eivy2b9c1f68127f
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.jsindex fdfc9dfc63..2fedf5441a 100644--- a/server/services/agentPromptBuilder.test.js+++ b/server/services/agentPromptBuilder.test.js@@ -2324,7 +2324,7 @@ describe('buildLightContextPrompt', () => {expect(prompt).not.toMatch(/--model gpt-5\.6-sol/);});- it('emits the local-LLM POST instruction when a local-LLM reviewer is configured', () => {+ it('emits the local-LLM bridge instruction when a local-LLM reviewer is configured', () => {const prompt = buildLightContextPrompt(makeTask({ metadata: {reviewLoopFollowUp: true,@@ -2337,12 +2337,14 @@ describe('buildLightContextPrompt', () => {'/r',{ branchName: 'b', worktreePath: '/tmp/wt' },isTruthyMeta);- // The agent gets a copy-pasteable curl pipeline pointing at PortOS's- // loopback API — without it the lmstudio/ollama reviewer kinds have no- // way to actually run a review.- expect(prompt).toMatch(/POST the diff to PortOS's local reviewer endpoint/);- expect(prompt).toMatch(/http:\/\/127\.0\.0\.1:5555\/api\/code-review\/local/);+ // The agent gets a copy-pasteable stdin bridge pipeline — no HTTP route,+ // no instance-password gate — without it the lmstudio/ollama reviewer+ // kinds have no way to actually run a review.+ expect(prompt).toMatch(/Pipe the diff into PortOS's local-review bridge/);+ expect(prompt).not.toMatch(/\/api\/code-review\/local/);expect(prompt).toMatch(/gh pr diff 9 \| jq/);+ expect(prompt).toMatch(/run-local-code-review\.mjs/);+ expect(prompt).toMatch(/timeoutMs: 1800000/);expect(prompt).toMatch(/jq -er '\.findings \| select\(type == "string" and length > 0\)'/);expect(prompt).toMatch(/Never treat an absent or malformed response as clean/);});@@ -3322,7 +3324,7 @@ describe('buildReviewLoopFollowUpSection — CLI reviewer procedure inlining', ({ verbose: false, localAgentLoopBody: null });expect(out).toMatch(/Local reviewer failed:/);- expect(out).toMatch(/STATUS=no-verdict[^]*exit 1/);+ expect(out).toMatch(/exit 1 # Never treat an absent or malformed response as clean/);});it('keeps an inline merge gate closed when the pre-PR required review is unavailable', () => {diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-compact.txtindex 953260ee3e..45dc59ee94 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-compact.txt@@ -9,33 +9,18 @@ A previous agent finished task **task-example** and opened **PR https://github.c**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a PR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-verbose.txtindex 42a27dd9bc..0c4e46e369 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-leaveopen-verbose.txt@@ -14,33 +14,18 @@ A previous agent finished implementing the work for source task **task-example****Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-compact.txtindex c229c45e71..bf28651865 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-compact.txt@@ -9,33 +9,18 @@ A previous agent finished task **task-example** and opened **PR https://github.c**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a PR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), merge the PR **immediately** with this exact command (flags: `--merge --delete-branch`, nothing else — a true merge commit keeps the branch tip in main's history so automated worktree cleanup can prove the branch is merged):diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-verbose.txtindex 641353b41b..6b6d12c9a8 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-gh-merge-verbose.txt@@ -14,33 +14,18 @@ A previous agent finished implementing the work for source task **task-example****Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), merge the PR **immediately** with this exact command (flags: `--merge --delete-branch`, nothing else — a true merge commit keeps the branch tip in main's history so automated worktree cleanup can prove the branch is merged):diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-compact.txtindex ebda2788a2..c936c04a77 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-compact.txt@@ -9,33 +9,18 @@ A previous agent finished task **task-example** and opened **PR https://github.c**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a MR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-verbose.txtindex 68fa90a249..932248ea5e 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-leaveopen-verbose.txt@@ -14,33 +14,18 @@ A previous agent finished implementing the work for source task **task-example****Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-compact.txtindex 18c002ce0b..e8398f9426 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-compact.txt@@ -9,33 +9,18 @@ A previous agent finished task **task-example** and opened **PR https://github.c**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a MR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), merge the PR **immediately** with this exact command (flags: `--merge --delete-branch`, nothing else — a true merge commit keeps the branch tip in main's history so automated worktree cleanup can prove the branch is merged):diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-verbose.txtindex 6c34cface9..28618843c2 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/followUp-glab-merge-verbose.txt@@ -14,33 +14,18 @@ A previous agent finished implementing the work for source task **task-example****Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), merge the PR **immediately** with this exact command (flags: `--merge --delete-branch`, nothing else — a true merge commit keeps the branch tip in main's history so automated worktree cleanup can prove the branch is merged):diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-compact.txtindex 7c809ba402..74ae71473f 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-compact.txt@@ -17,33 +17,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a PR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-verbose.txtindex e029a003c6..126313c3c9 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-leaveopen-verbose.txt@@ -22,33 +22,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-compact.txtindex 1d80fca345..760f341e28 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-compact.txt@@ -17,33 +17,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a PR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.**Required local-review merge gate:** Before any CI-fix or merge action, load the worktree-private local review state with `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`, fail closed if it is missing, and source it. If `LOCAL_OVERALL_STATUS=review-blocked`, do NOT run this merge path; the PR/MR was already published and the required comment was posted, so leave it open, report that the required review is pending, and return to the enclosing completion handoff (write the sentinel for a TUI run or exit for a CLI run) without claiming a merge. Accept only `clean` or `partial`; any other or missing status, or a `LOCAL_REVIEWED_HEAD_SHA` that does not equal `$(git rev-parse HEAD)`, fails closed.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-verbose.txtindex 4fc902bbb9..87d13d4be1 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-gh-merge-verbose.txt@@ -22,33 +22,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`; on GitHub `gh pr diff 42` also works). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+gh pr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `gh pr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as PR reviewer (`gh pr edit 42 --add-reviewer <user>`, drop the `@`), then wait for their review (poll every 5–15s) and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.**Required local-review merge gate:** Before any CI-fix or merge action, load the worktree-private local review state with `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`, fail closed if it is missing, and source it. If `LOCAL_OVERALL_STATUS=review-blocked`, do NOT run this merge path; the PR/MR was already published and the required comment was posted, so leave it open, report that the required review is pending, and return to the enclosing completion handoff (write the sentinel for a TUI run or exit for a CLI run) without claiming a merge. Accept only `clean` or `partial`; any other or missing status, or a `LOCAL_REVIEWED_HEAD_SHA` that does not equal `$(git rev-parse HEAD)`, fails closed.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-compact.txtindex dd5e8ce155..60ae457027 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-compact.txt@@ -17,33 +17,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a MR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-verbose.txtindex 987e2848a5..01bdd1a390 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-leaveopen-verbose.txt@@ -22,33 +22,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.4. When the reviewer list is exhausted (or the stop mode triggers), **leave the PR open** — do NOT merge it, and do NOT delete the branch. Its JIRA ticket is sitting in review and a human lands both together; merging here would leave the work merged and the ticket stuck in review.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-compact.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-compact.txtindex 713e982ba3..e4da4cec46 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-compact.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-compact.txt@@ -17,33 +17,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Missing reviewer CLI:** verify each configured binary is on PATH (`command -v codex`) before concluding it is unavailable. If a required reviewer binary is genuinely missing (`codex`), that reviewer is UNSATISFIED — do NOT substitute your own self-review and do NOT merge; post a MR comment naming the missing command and exit.**Optional reviewers (~opt):** `ollama` still run and their findings must still be fixed, but a timeout, skipped/incomplete pass, or missing/malformed/no-verdict result from one of them is non-blocking; provider/transport failure from one of them is also non-blocking. A substantive rejection, failed build/test, or push failure still blocks.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.**Required local-review merge gate:** Before any CI-fix or merge action, load the worktree-private local review state with `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`, fail closed if it is missing, and source it. If `LOCAL_OVERALL_STATUS=review-blocked`, do NOT run this merge path; the PR/MR was already published and the required comment was posted, so leave it open, report that the required review is pending, and return to the enclosing completion handoff (write the sentinel for a TUI run or exit for a CLI run) without claiming a merge. Accept only `clean` or `partial`; any other or missing status, or a `LOCAL_REVIEWED_HEAD_SHA` that does not equal `$(git rev-parse HEAD)`, fails closed.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-verbose.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-verbose.txtindex dcc09087ab..8c66284fbc 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-verbose.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/inline-glab-merge-verbose.txt@@ -22,33 +22,18 @@ When the local phase satisfies the stop condition, skip the PR-side phase and re**Run this loop UNTIL all configured reviewers are satisfied (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+glab mr diff 42 | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `glab mr diff 42 | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. **@github reviewers**: request `@example-user` as MR reviewer using the GitLab project UI or API, then inspect `glab mr view 42` for their review and address any findings; their approval gates the merge.2. If there are unresolved review findings, fix them in this worktree, run the project's tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), push, and (for Copilot) resolve the addressed threads.3. Re-review with the same reviewer until it reports clean, then advance to the next reviewer in the list.**Required local-review merge gate:** Before any CI-fix or merge action, load the worktree-private local review state with `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`, fail closed if it is missing, and source it. If `LOCAL_OVERALL_STATUS=review-blocked`, do NOT run this merge path; the PR/MR was already published and the required comment was posted, so leave it open, report that the required review is pending, and return to the enclosing completion handoff (write the sentinel for a TUI run or exit for a CLI run) without claiming a merge. Accept only `clean` or `partial`; any other or missing status, or a `LOCAL_REVIEWED_HEAD_SHA` that does not equal `$(git rev-parse HEAD)`, fails closed.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-gh.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-gh.txtindex 756fe80b96..33f5650c1b 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-gh.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-gh.txt@@ -12,33 +12,18 @@ This runs as **step 3 of the Completion Workflow above**, against the committed**Rebase conflict gate:** resolve routine conflicts and finish the rebase in this agent session. If a conflict genuinely cannot be resolved safely, run `git rebase --abort 2>/dev/null || true` and stop; never publish a conflicted or half-rebased worktree.**State persistence:** shell calls do not share variables. Reload state before each reviewer, preserve it while persisting `LOCAL_REVIEWER_START_SHA`; reload before commit/stop calculations and the final aggregate. Any read/write failure blocks publication; only an explicitly recorded `review-blocked` reviewer-availability result may proceed to publication.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff origin/main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff origin/main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. Username reviewers will be requested after the PR/MR is published.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. Username reviewers will be requested after the PR/MR is published.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), then re-run the same local reviewer. Do NOT push or open a PR/MR yet.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the local reviewer list is exhausted (or the stop mode triggers), record `LOCAL_OVERALL_STATUS`: use `review-blocked` only when a required reviewer could not produce a verdict because of an availability, quota/provider, timeout, transport, malformed, empty, or no-verdict failure; never use it for substantive findings, failed tests/build, unpushed fixes, or state/publication failures, and do not self-review. Set `LOCAL_STOP_TRIGGERED=true` when the configured stop condition actually fired on a qualifying verdict, including when that verdict came from the final local reviewer; set it false for list exhaustion, an inconclusive result, or `review-blocked`. The configured reviewer positions are zero-based: `mtplx`=0, `ollama`=1, `copilot`=2, `codex`=3, `@example-user`=4. When a qualifying verdict triggers the configured stop condition, set `LOCAL_STOP_TRIGGERED=true` and `LOCAL_STOP_INDEX` to that triggering local reviewer's position; when the list exhausts without a qualifying stop or a result is inconclusive, set `LOCAL_STOP_TRIGGERED=false` and `LOCAL_STOP_INDEX=-1`. Compute `LOCAL_PHASE_COMMITS=$(git rev-list "$LOCAL_PHASE_START_SHA..HEAD" --count)`; if a qualifying stop fired, retain the triggering reviewer's `LOCAL_REVIEWER_COMMITS` as `LOCAL_STOP_REVIEW_COMMITS`, otherwise set `LOCAL_STOP_REVIEW_COMMITS=-1`. Record `LOCAL_REVIEWED_HEAD_SHA=$(git rev-parse HEAD)`. Persist all phase state for later shell calls in the worktree-private Git state file: `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`; then run `printf 'LOCAL_PHASE_START_SHA=%s\nLOCAL_OVERALL_STATUS=%s\nLOCAL_STOP_TRIGGERED=%s\nLOCAL_STOP_INDEX=%s\nLOCAL_STOP_REVIEW_COMMITS=%s\nLOCAL_PHASE_COMMITS=%s\nLOCAL_REVIEWED_HEAD_SHA=%s\n' "$LOCAL_PHASE_START_SHA" "$LOCAL_OVERALL_STATUS" "$LOCAL_STOP_TRIGGERED" "$LOCAL_STOP_INDEX" "$LOCAL_STOP_REVIEW_COMMITS" "$LOCAL_PHASE_COMMITS" "$LOCAL_REVIEWED_HEAD_SHA" > "$LOCAL_REVIEW_STATE_FILE"`. A `review-blocked` state is a completed local phase that permits publication but blocks the merge gate; the publication step posts the required comment. If that write fails, do NOT push or open the PR/MR. For a final-reviewer stop, follow the same phase-level gate below: `on-clean` requires `LOCAL_OVERALL_STATUS=clean` with `LOCAL_STOP_REVIEW_COMMITS=0`, while `on-findings` requires `LOCAL_OVERALL_STATUS=clean` with `LOCAL_STOP_REVIEW_COMMITS>0`; a `partial` status is already a qualifying stop. Return to the Completion Workflow and continue with the push and PR/MR creation step when all executed required reviewers are clean and optional reviewers are clean or inconclusive, when `LOCAL_OVERALL_STATUS=partial` records a qualifying configured stop-mode short-circuit, or when `LOCAL_OVERALL_STATUS=review-blocked` records only reviewer unavailability. Do NOT push or open the PR/MR before this local phase is complete.diff --git a/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-glab.txt b/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-glab.txtindex 756fe80b96..33f5650c1b 100644--- a/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-glab.txt+++ b/server/services/promptSections/__snapshots__/reviewLoopMatrix/local-glab.txt@@ -12,33 +12,18 @@ This runs as **step 3 of the Completion Workflow above**, against the committed**Rebase conflict gate:** resolve routine conflicts and finish the rebase in this agent session. If a conflict genuinely cannot be resolved safely, run `git rebase --abort 2>/dev/null || true` and stop; never publish a conflicted or half-rebased worktree.**State persistence:** shell calls do not share variables. Reload state before each reviewer, preserve it while persisting `LOCAL_REVIEWER_START_SHA`; reload before commit/stop calculations and the final aggregate. Any read/write failure blocks publication; only an explicitly recorded `review-blocked` reviewer-availability result may proceed to publication.**Loop UNTIL all required reviewers are satisfied and optional reviewers are satisfied or explicitly inconclusive (or the stop mode triggers), capped at 10 iterations per reviewer:**-1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff origin/main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.+1. For EACH reviewer in order — `ollama` → `copilot` → `codex` → `@example-user` — run a full review-and-fix sub-loop before advancing to the next. **copilot**: request a Copilot review when you reach its turn (poll every 5–15s, max 5 min/round), then re-request on later rounds. **codex**: invoke that CLI to review this branch's diff against its base (use the CLI's own base-diff mode or `git diff origin/main...HEAD`). When invoking a reviewer with a pinned model or reasoning effort, pass it: `codex --model gpt-5.6-sol -c model_reasoning_effort=high …`. Follow the **CLI Reviewer Procedure** section below for the exact headless invocation and review-only contract — do NOT probe the CLI or guess flags. **ollama**: Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.```bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", diff: . }' | curl -sS -X POST http://127.0.0.1:5555/api/code-review/local -H 'Content-Type: application/json' -H "Authorization: Bearer ${PORTOS_API_TOKEN:-}" -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", timeoutMs: 1800000, diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "${REVIEW_RESPONSE}.findings"fi```-Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. An `HTTP 401` is not a review result — it means this install has an instance password and the `PORTOS_API_TOKEN` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: `git diff origin/main...HEAD | jq -Rs '{ backend: "ollama", diff: . }' | node /portos/server/scripts/run-local-code-review.mjs > "$REVIEW_RESPONSE"`, then extract `.findings` from it exactly as above. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON body (`jq -Rs '{ backend: "ollama", model: "…", diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. Username reviewers will be requested after the PR/MR is published.+Only a successfully extracted `.findings` value is the review text; treat it like any other reviewer's findings. This run pins settings for `ollama` → `"model": "qwen3-coder"` — add those keys to the JSON object (`jq -Rs '{ backend: "ollama", model: "…", timeoutMs: 1800000, diff: . }'`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk. Username reviewers will be requested after the PR/MR is published.2. If unresolved findings: fix in this worktree, run tests, commit (`feat:`/`fix:` prefix, no Co-Authored-By), then re-run the same local reviewer. Do NOT push or open a PR/MR yet.3. Re-review with the same reviewer until clean, then advance to the next reviewer in the list.4. When the local reviewer list is exhausted (or the stop mode triggers), record `LOCAL_OVERALL_STATUS`: use `review-blocked` only when a required reviewer could not produce a verdict because of an availability, quota/provider, timeout, transport, malformed, empty, or no-verdict failure; never use it for substantive findings, failed tests/build, unpushed fixes, or state/publication failures, and do not self-review. Set `LOCAL_STOP_TRIGGERED=true` when the configured stop condition actually fired on a qualifying verdict, including when that verdict came from the final local reviewer; set it false for list exhaustion, an inconclusive result, or `review-blocked`. The configured reviewer positions are zero-based: `mtplx`=0, `ollama`=1, `copilot`=2, `codex`=3, `@example-user`=4. When a qualifying verdict triggers the configured stop condition, set `LOCAL_STOP_TRIGGERED=true` and `LOCAL_STOP_INDEX` to that triggering local reviewer's position; when the list exhausts without a qualifying stop or a result is inconclusive, set `LOCAL_STOP_TRIGGERED=false` and `LOCAL_STOP_INDEX=-1`. Compute `LOCAL_PHASE_COMMITS=$(git rev-list "$LOCAL_PHASE_START_SHA..HEAD" --count)`; if a qualifying stop fired, retain the triggering reviewer's `LOCAL_REVIEWER_COMMITS` as `LOCAL_STOP_REVIEW_COMMITS`, otherwise set `LOCAL_STOP_REVIEW_COMMITS=-1`. Record `LOCAL_REVIEWED_HEAD_SHA=$(git rev-parse HEAD)`. Persist all phase state for later shell calls in the worktree-private Git state file: `LOCAL_REVIEW_STATE_FILE="$(git rev-parse --git-path portos-local-review-state)"`; then run `printf 'LOCAL_PHASE_START_SHA=%s\nLOCAL_OVERALL_STATUS=%s\nLOCAL_STOP_TRIGGERED=%s\nLOCAL_STOP_INDEX=%s\nLOCAL_STOP_REVIEW_COMMITS=%s\nLOCAL_PHASE_COMMITS=%s\nLOCAL_REVIEWED_HEAD_SHA=%s\n' "$LOCAL_PHASE_START_SHA" "$LOCAL_OVERALL_STATUS" "$LOCAL_STOP_TRIGGERED" "$LOCAL_STOP_INDEX" "$LOCAL_STOP_REVIEW_COMMITS" "$LOCAL_PHASE_COMMITS" "$LOCAL_REVIEWED_HEAD_SHA" > "$LOCAL_REVIEW_STATE_FILE"`. A `review-blocked` state is a completed local phase that permits publication but blocks the merge gate; the publication step posts the required comment. If that write fails, do NOT push or open the PR/MR. For a final-reviewer stop, follow the same phase-level gate below: `on-clean` requires `LOCAL_OVERALL_STATUS=clean` with `LOCAL_STOP_REVIEW_COMMITS=0`, while `on-findings` requires `LOCAL_OVERALL_STATUS=clean` with `LOCAL_STOP_REVIEW_COMMITS>0`; a `partial` status is already a qualifying stop. Return to the Completion Workflow and continue with the push and PR/MR creation step when all executed required reviewers are clean and optional reviewers are clean or inconclusive, when `LOCAL_OVERALL_STATUS=partial` records a qualifying configured stop-mode short-circuit, or when `LOCAL_OVERALL_STATUS=review-blocked` records only reviewer unavailability. Do NOT push or open the PR/MR before this local phase is complete.diff --git a/server/services/promptSections/reviewLifecycle.js b/server/services/promptSections/reviewLifecycle.jsindex 7910c3311d..d98a0cad38 100644--- a/server/services/promptSections/reviewLifecycle.js+++ b/server/services/promptSections/reviewLifecycle.js@@ -12,6 +12,12 @@ import { LOCAL_REVIEW_BRIDGE_SCRIPT } from '../../lib/localReviewBridge.js';import { INLINE_REVIEW_LOOP_STEP } from './constants.js';import { normalizeForgeCli } from './forge.js';+// A large model reviewing a large diff should not be cut off at the HTTP+// route's 600000ms cap (`server/routes/codeReview.js`) — the bridge spreads+// this straight into `runLocalCodeReview`'s own `timeoutMs`, so there is no+// route-imposed ceiling to work around.+const LOCAL_LLM_REVIEW_TIMEOUT_MS = 1_800_000;+/*** True when a follow-up task is a **merge-only** run: it has a PR to land but no* reviewer to run (Review Loop off, or every configured reviewer was stripped —@@ -300,35 +306,26 @@ function resolveReviewRoster(metadata, { reviewerPositions = [] } = {}) {/*** The `lmstudio`/`ollama` reviewer recipe. Those backends have no CLI the agent- * can spawn — PortOS exposes `POST /api/code-review/local`, which runs the- * configured local model against the diff and returns findings text. The agent- * reaches it over plain HTTP at `localApiBaseUrl()` — the loopback HTTP mirror- * port when this install booted with HTTPS (where the API port is TLS-only and- * a plain-HTTP curl would fail at the transport layer), the API port otherwise.- *- * `/api/*` is gated when the install has an instance password set, which is the- * recommended posture — so the request carries the loopback session token PortOS- * injects into the agent's environment (`services/agentApiAuth.js`). Without it- * every one of these reviews came back `401 AUTH_REQUIRED`, which reads as a- * broken reviewer. A 401 nonetheless (a run spawned before the token existed, a- * rotated password) is not a review verdict: the prose points the agent at the- * auth-independent stdin bridge, the same service without the gate.+ * can spawn, so the agent pipes the diff into the auth-independent local-review+ * bridge (`LOCAL_REVIEW_BRIDGE_SCRIPT` → `server/scripts/run-local-code-review.mjs`)+ * — the same transport the CoS claim procedure already uses for every tool-free+ * reviewer (`buildLocalReviewerInstructions` in `cosTaskPrompts.js`). The bridge+ * calls `runLocalCodeReview` directly, so it needs no `/api/*` credential and is+ * not bound by the HTTP route's `timeoutMs` cap (`server/routes/codeReview.js`).*- * A pinned local-LLM model can't ride the endpoint's server-side default: that- * reads the GLOBAL settings scalar and has never seen this task. So when the- * user pinned one on the reviewer's row, name it in the request body — `model`- * in the POST body overrides the configured default (see routes/codeReview.js).- * Absent pin ⇒ omit the key entirely rather than sending `""`, which would be a- * model id the backend can't resolve. The pinned reasoning effort rides the same- * body as `effort` — the endpoint forwards it as the backend's- * OpenAI-compatible `reasoning_effort`, under the same absent-vs-empty contract.+ * A pinned local-LLM model can't ride the bridge's own default: that reads the+ * GLOBAL settings scalar and has never seen this task. So when the user pinned+ * one on the reviewer's row, name it in the request object — `model` overrides+ * the configured default (see `run-local-code-review.mjs`). Absent pin ⇒ omit+ * the key entirely rather than sending `""`, which would be a model id the+ * backend can't resolve. The pinned reasoning effort rides the same object as+ * `effort`, under the same absent-vs-empty contract.** The `backend` value is derived from the reviewers THIS run configured rather- * than a fixed `<lmstudio|ollama>` placeholder: naming a backend that isn't in- * the list is a 400 from the route's `z.enum`, and a single configured backend+ * than a fixed `<lmstudio|ollama>` placeholder, so a single configured backend* needs no substitution step at all.*/-function buildLocalLlmInvocation({ localLlmBackends, reviewerModelMap, reviewerEffortMap, diffCommand, apiBase }) {+function buildLocalLlmInvocation({ localLlmBackends, reviewerModelMap, reviewerEffortMap, diffCommand }) {const backendToken = localLlmBackends.length === 1? localLlmBackends[0]: `<${localLlmBackends.join('|')}>`;@@ -351,42 +348,29 @@ function buildLocalLlmInvocation({ localLlmBackends, reviewerModelMap, reviewerE// hoisting one line above the other silently emptied the key list. The jq// example names only the keys THIS run pins: an effort-only run that was shown// a `model: "…"` placeholder would have the agent send the literal ellipsis,- // and the route's `body.model || configured` prefers that truthy junk over the- // install default — turning a pinned-effort review into a model-not-found error.+ // and the bridge's `request.model || configured` prefers that truthy junk over+ // the install default — turning a pinned-effort review into a model-not-found+ // error.const pinJq = [`backend: "${backendToken}"`,...(pins.some(p => p.model) ? ['model: "…"'] : []),...(pins.some(p => p.effort) ? ['effort: "…"'] : []),+ `timeoutMs: ${LOCAL_LLM_REVIEW_TIMEOUT_MS}`,'diff: .'].join(', ');- const invocation = `POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it.${backendNote}+ const invocation = `Pipe the diff into PortOS's local-review bridge and extract its review text before evaluating it.${backendNote}\`\`\`bashREVIEW_RESPONSE=$(mktemp)-HTTP_STATUS=$(${diffCommand} | jq -Rs '{ backend: "${backendToken}", diff: . }' | curl -sS -X POST ${apiBase}/api/code-review/local -H 'Content-Type: application/json' ${AGENT_API_AUTH_CURL_ARG} -d @- -o "$REVIEW_RESPONSE" -w '%{http_code}') || {- echo "Local reviewer failed: request transport error" >&2- STATUS=cli-error- exit 1-}-if [ "$HTTP_STATUS" -ge 400 ] 2>/dev/null; then- echo "Local reviewer failed: HTTP $HTTP_STATUS $(jq -r '.error // "request failed"' "$REVIEW_RESPONSE" 2>/dev/null)" >&2- STATUS=cli-error- exit 1-fi-if jq -e '.error | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" >/dev/null 2>&1; then- echo "Local reviewer failed: $(jq -r '.error' "$REVIEW_RESPONSE")" >&2- STATUS=cli-error- exit 1-fi+${diffCommand} | jq -Rs '{ backend: "${backendToken}", timeoutMs: ${LOCAL_LLM_REVIEW_TIMEOUT_MS}, diff: . }' | node ${shellQuote(LOCAL_REVIEW_BRIDGE_SCRIPT)} > "$REVIEW_RESPONSE"if ! jq -er '.findings | select(type == "string" and length > 0)' "$REVIEW_RESPONSE" > "\${REVIEW_RESPONSE}.findings"; thenecho "Local reviewer failed: $(jq -r '.error // "missing .findings in reviewer response"' "$REVIEW_RESPONSE")" >&2- STATUS=no-verdict # Never treat an absent or malformed response as clean.- exit 1+ exit 1 # Never treat an absent or malformed response as clean.elsecat "\${REVIEW_RESPONSE}.findings"fi\`\`\`-Only a successfully extracted \`.findings\` value is the review text; treat it like any other reviewer's findings. An \`HTTP 401\` is not a review result — it means this install has an instance password and the \`PORTOS_API_TOKEN\` in your environment is missing or stale. Re-run the SAME request body (with whatever keys this run pins) through the auth-independent bridge — the same service without the gate — before recording any status: \`${diffCommand} | jq -Rs '{ backend: "${backendToken}", diff: . }' | node ${shellQuote(LOCAL_REVIEW_BRIDGE_SCRIPT)} > "$REVIEW_RESPONSE"\`, then extract \`.findings\` from it exactly as above.${pinNote.length- ? ` This run pins settings for ${pinNote.join(', ')} — add those keys to the JSON body (\`jq -Rs '{ ${pinJq} }'\`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk.`+Only a successfully extracted \`.findings\` value is the review text; treat it like any other reviewer's findings.${pinNote.length+ ? ` This run pins settings for ${pinNote.join(', ')} — add those keys to the JSON object (\`jq -Rs '{ ${pinJq} }'\`) so the review runs with them instead of the install defaults. Send ONLY the keys named above; a key with no pinned value overrides the install default with junk.`: ''}`;return { backendToken, invocation };}@@ -783,7 +767,7 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,const apiBase = localApiBaseUrl();const diffCommand = phase.diffCommand(forge);const { backendToken: localLlmBackendToken, invocation: localLlmInvocation } = buildLocalLlmInvocation({- localLlmBackends, reviewerModelMap, reviewerEffortMap, diffCommand, apiBase,+ localLlmBackends, reviewerModelMap, reviewerEffortMap, diffCommand,});const githubUsersInvocation = phase.supportsUsernameReviewers? forge.requestReviewersText(usernames)diff --git a/server/services/promptSections/reviewLifecycle.test.js b/server/services/promptSections/reviewLifecycle.test.jsindex e3610f4a27..1c191f2ac7 100644--- a/server/services/promptSections/reviewLifecycle.test.js+++ b/server/services/promptSections/reviewLifecycle.test.js@@ -1,10 +1,12 @@/**- * The review-lifecycle prompt hands CoS agents two copy-pasteable `curl`- * commands aimed at this install's own API. Those must resolve through- * `localApiBaseUrl()` rather than a hardcoded origin: on an install that ran- * `npm run setup:cert`, `:5555` is TLS-only and a plain-HTTP request to it dies- * at the transport layer, so the local-LLM reviewer reports `cli-error` and the- * challenge-protocol dispute silently cannot be filed (#5656).+ * The review-lifecycle prompt hands CoS agents a copy-pasteable `curl` command+ * aimed at this install's own API for the challenge protocol. That must resolve+ * through `localApiBaseUrl()` rather than a hardcoded origin: on an install that+ * ran `npm run setup:cert`, `:5555` is TLS-only and a plain-HTTP request to it+ * dies at the transport layer, so the challenge-protocol dispute silently cannot+ * be filed (#5656). The local-LLM reviewer itself goes through the+ * auth-independent local-review bridge (`server/scripts/run-local-code-review.mjs`)+ * instead of an HTTP call, so it needs no origin and no credential at all (#7670).*/import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';@@ -38,13 +40,12 @@ describe('reviewLifecycle agent-facing API origin', () => {process.env = { ...ORIGINAL_ENV };});- it('points both agent curl commands at the loopback HTTP mirror when HTTPS is active', () => {+ it('points the challenge-protocol curl at the loopback HTTP mirror when HTTPS is active', () => {getHttpsEnabledAtBoot.mockReturnValue({ value: true, initialized: true });const section = buildReviewLoopFollowUpSection(metadata);expect(section).not.toContain(':5555');- expect(section).toContain('http://127.0.0.1:5553/api/code-review/local');expect(section).toContain('http://127.0.0.1:5553/api/cos/tasks/task-example/challenge');});@@ -53,7 +54,6 @@ describe('reviewLifecycle agent-facing API origin', () => {const section = buildReviewLoopFollowUpSection(metadata);- expect(section).toContain('http://127.0.0.1:5555/api/code-review/local');expect(section).toContain('http://127.0.0.1:5555/api/cos/tasks/task-example/challenge');});});@@ -79,30 +79,28 @@ describe('reviewLifecycle reviewer invocation details', () => {expect(section).toContain('Substitute the active reviewer name');});- // Both commands hit `/api/*`, which the optional instance password gates. An- // agent holds no browser cookie, so without the injected session token every- // review came back `401 AUTH_REQUIRED` and read as a broken reviewer (#7660- // follow-on). The whole header is one quoted argument so a token can never be- // word-split, and the `:-` default keeps the command valid on an install with- // no password set.- it('spends the injected loopback session token on both agent curl commands', () => {+ // The challenge-protocol curl hits `/api/*`, which the optional instance+ // password gates. An agent holds no browser cookie, so without the injected+ // session token the dispute came back `401 AUTH_REQUIRED` and read as a+ // broken protocol (#7660 follow-on). The whole header is one quoted argument+ // so a token can never be word-split, and the `:-` default keeps the command+ // valid on an install with no password set.+ it('spends the injected loopback session token on the challenge-protocol curl', () => {const section = buildReviewLoopFollowUpSection(metadata);const authHeader = '-H "Authorization: Bearer ${PORTOS_API_TOKEN:-}"';- expect(section).toContain(`/api/code-review/local -H 'Content-Type: application/json' ${authHeader}`);expect(section).toContain(`/api/cos/tasks/task-example/challenge -H 'Content-Type: application/json' ${authHeader}`);});- // A 401 is an absent credential, not a reviewer verdict — recording it as one- // would block the merge on an outage that does not exist. The bridge runs the- // same service over stdin with no gate.- it('points a 401 at the auth-independent review bridge instead of a verdict', () => {+ // #7670: the local-LLM reviewer drives the same auth-independent stdin bridge+ // the claim prompt already uses — no HTTP route, no 401, no credential.+ it('pipes the local-LLM reviewer through the stdin bridge, not the HTTP route', () => {const section = buildReviewLoopFollowUpSection(metadata);- expect(section).toContain('An `HTTP 401` is not a review result');- // Basename only: the path is built with `join()`, so a Windows checkout- // renders it with backslashes.+ expect(section).not.toContain('/api/code-review/local');+ expect(section).not.toContain('An `HTTP 401` is not a review result');expect(section).toContain('run-local-code-review.mjs');+ expect(section).toContain('timeoutMs: 1800000');});// `opencode run -m <provider/model>`: rendering `--model` here had agentsdiff --git a/server/services/promptSections/reviewLifecycleMatrix.test.js b/server/services/promptSections/reviewLifecycleMatrix.test.jsindex bc806d31cd..cb5be124f3 100644--- a/server/services/promptSections/reviewLifecycleMatrix.test.js+++ b/server/services/promptSections/reviewLifecycleMatrix.test.js@@ -262,7 +262,7 @@ describe('buildReviewLoopFollowUpSection — load-bearing lines stay with theirexpect(section).toContain('## Review-Loop Follow-up (PRIMARY OBJECTIVE)');expect(section).toContain('Drive the review-and-fix loop to completion and merge.');expect(section).toContain('on GitHub `gh pr diff 42` also works');- expect(section).toContain('HTTP_STATUS=$(gh pr diff 42 | jq');+ expect(section).toContain(`gh pr diff 42 | jq -Rs '{ backend:`);expect(section).toContain('gh pr merge "https://github.com/example-org/example-repo/pull/42" --merge --delete-branch');expect(section).toContain('(Equivalent: `gh pr merge 42 --repo example-org/example-repo --merge --delete-branch`.)');expect(section).toContain('`gh pr view "https://github.com/example-org/example-repo/pull/42" --json state -q .state` must return `MERGED`');@@ -285,7 +285,7 @@ describe('buildReviewLoopFollowUpSection — load-bearing lines stay with theirit('routes every forge command through the caller override on a self-managed GitLab', () => {const section = render(CELL('followUp', 'glab', false, false));- expect(section).toContain('HTTP_STATUS=$(glab mr diff 42 | jq');+ expect(section).toContain(`glab mr diff 42 | jq -Rs '{ backend:`);expect(section).toContain('glab mr merge "42" --yes --remove-source-branch');expect(section).toContain('`glab mr view "42"` must show it merged');expect(section).toContain('request `@example-user` as MR reviewer using the GitLab project UI or API');@@ -310,7 +310,7 @@ describe('buildReviewLoopFollowUpSection — load-bearing lines stay with theirfor (const phase of ['inline', 'followUp']) {const section = render(CELL(phase, 'glab', true, false));- expect(section).toContain('HTTP_STATUS=$(glab mr diff 42 | jq');+ expect(section).toContain(`glab mr diff 42 | jq -Rs '{ backend:`);expect(section).toContain('5. Post a short comment on the MR summarising');expect(section).toContain('`glab mr note 42 --message "<summary>"`');expect(section).not.toContain('gh pr comment');@@ -351,7 +351,7 @@ describe('buildReviewLoopFollowUpSection — load-bearing lines stay with their);const merging = hostGlab({}, {});- expect(merging).toContain('HTTP_STATUS=$(glab mr diff 42 | jq');+ expect(merging).toContain(`glab mr diff 42 | jq -Rs '{ backend:`);expect(merging).toContain('glab mr merge "42" --yes --remove-source-branch');expect(merging).toContain('`glab mr view "42"` must show it merged');expect(merging).toContain('request `@example-user` as MR reviewer using the GitLab project UI or API');