Skip to content

Pre-arm external buyer pilot watcher#21

Merged
dolepee merged 2 commits into
mainfrom
codex/pilot-prearmed-watcher
Jul 25, 2026
Merged

Pre-arm external buyer pilot watcher#21
dolepee merged 2 commits into
mainfrom
codex/pilot-prearmed-watcher

Conversation

@dolepee

@dolepee dolepee commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • add watch-next so the pilot watcher can arm before the external buyer creates the Foreman task
  • discover exactly one new escrow task from the expected independent buyer
  • hand the discovered task into the existing acceptance, preflight, and confirmation path
  • refuse ambiguity instead of guessing when multiple jobs appear

Safety

  • read-only watcher; it never pays, accepts, settles, or deploys
  • existing buyer-independence and policy-binding checks remain authoritative
  • no production runtime changes

Verification

  • npm run agent:verify-pilot-watcher
  • npm run typecheck
  • npm run agent:gate
  • git diff --check

@dolepee

dolepee commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

@codex review

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cca1854ae

ℹ️ About Codex in GitHub

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

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

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

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

Comment thread scripts/pilot-acceptance-watcher.mjs Outdated
Comment on lines +174 to +176
const startBlock = args.fromBlock && args.fromBlock !== true
? BigInt(String(args.fromBlock))
: await headBlock();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude the current head from the next-job scan

When the buyer already created a task in the block returned by this initial headBlock() call, the inclusive scan treats that existing task as the “next” one and immediately hands it to watch(). The watcher then stops looking for the task created after it was armed, so the intended pilot task can be missed; default the scan to the following block or snapshot and exclude logs already present at startup.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in the latest branch commit. The default scan now begins at startup head + 1, and cap syntax is validated before PRE-ARMED is printed. Regression assertions and the complete agent:gate pass.

async function watchNext(args) {
const buyer = String(args.buyer || "").toLowerCase();
const jobDescription = String(args.jobDescription || "");
const cap = String(args.cap || "0.5");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate the cap before declaring the watcher pre-armed

When an explicit --cap is malformed, watch-next prints PRE-ARMED and waits successfully, but the existing cap validation in watch() runs only after the one-shot job has been discovered. The command therefore exits at the time-sensitive moment it was intended to protect, leaving the operator to restart during the 60-second enrollment window; apply the same cap validation before entering this loop.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in the latest branch commit. The default scan now begins at startup head + 1, and cap syntax is validated before PRE-ARMED is printed. Regression assertions and the complete agent:gate pass.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This is fixed in 3250a44 at lines 171-173: cap validation now runs before PRE-ARMED at line 182. The regression assertion and full agent:gate pass are included.

@dolepee

dolepee commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

@codex review\n\nFixed both watcher findings and reran the full PolicyPool agent gate.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 3250a44935

ℹ️ About Codex in GitHub

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

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

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

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

@dolepee

dolepee commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

@codex review\n\nPlease recheck current commit 3250a44; both prior findings are fixed before PRE-ARMED.

@dolepee
dolepee merged commit b47133f into main Jul 25, 2026
2 checks passed
@dolepee
dolepee deleted the codex/pilot-prearmed-watcher branch July 25, 2026 20:23

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3250a44935

ℹ️ About Codex in GitHub

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

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

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

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

Comment on lines +166 to +170
const jobDescription = String(args.jobDescription || "");
const cap = String(args.cap || "0.5");
const targetAgent = String(args.targetAgent || "Foreman#4348");
if (!/^0x[a-f0-9]{40}$/.test(buyer)) throw new Error("--buyer must be an address");
if (!jobDescription) throw new Error("--job-description is required");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject valueless job descriptions before arming

When watch-next is invoked with a valueless --job-description (for example, immediately followed by --cap), parseArgs stores true and this conversion turns it into the nonempty string "true", so the required-value check passes and PRE-ARMED is printed. The watcher then consumes the buyer's next one-shot job only for the preflight guard to reject that bogus description, potentially losing the 60-second enrollment opportunity; require a string value before announcing that the watcher is armed.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant