Skip to content

infra: fleet-paperwork — file GitHub issues as the developing.today App - #3692

Merged
dezren39 merged 1 commit into
mainfrom
feat/fleet-paperwork
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
feat/fleet-paperwork

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What

Adds infra/fleet-paperwork/fleet_paperwork.py: a small CLI that files GitHub issues/comments/closes as the developing.today GitHub App instead of as a user token.

  • Auth: sops-stored App key (~/secrets/pm-stack.sops.yaml, referenced by key name only — no credential values in the repo) → RS256 JWT (openssl) → per-owner installation token, installation resolved live by repo-owner login (org install for developing-today/*, personal for dezren39/nix); repo scope confirmed before any write.
  • Why: on 2026-11-01 a ~322-issue batch through gh tripped the user token's secondary rate limit, and two creates returned exit 0 while creating nothing (one batch issue was later found missing by audit). An App installation token is a separate actor with its own rate-limit bucket.
  • Verified-or-failed: every create/comment/close is followed by a readback GET and compared; creates are deduped by exact title (search API + byte-exact filter) and paced (default 3 s, enforced across runs via ~/.local/state/fleet-paperwork/ledger.tsv).

Live proof (already filed through the App, authored app/developing-today)

Tests

  • python3 -m unittest discover -s infra/fleet-paperwork/tests — 7/7 pass (run on the laptop; pure functions, no network).
  • fleet_paperwork.py check --repo developing-today/code and --repo developing-today/opencode — live read-only check passes; the laptop copy used for the filings was sha256-identical to the script in this PR.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Bulk fleet bookkeeping through a user token tripped GitHub's per-actor
secondary rate limit on 2026-11-01, and two gh creates silently created
nothing. fleet_paperwork.py authenticates as the developing.today GitHub
App (separate installation-token bucket), resolves the installation by
repo owner, dedupes creates by exact title, paces writes via a local
ledger, and verifies every create/comment/close by readback.

First live use filed the three pending items: opencode#1280
(preserved-branch decision issue for
rescue/3041-631-subagent-ancestor-2026-11-01), the resolution comment +
close on opencode#1203, and code#3691 (the audit gap:
queue/3201-2167-shebang-dispatch).
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 13:09
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dac6d290-08d1-4672-b6ee-5a81aa2a363d
Commits

Reviewing files that changed from the base of the PR and between 792b69b and 240bab3.

Files selected for processing: 3
  • infra/fleet-paperwork/README.md
  • infra/fleet-paperwork/fleet_paperwork.py
  • infra/fleet-paperwork/tests/test_fleet_paperwork.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T13:13:38.698138Z 240bab3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 240bab3158

ℹ️ 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 +240 to +243
q = urllib.parse.quote(f'repo:{repo} "{title}"')
_, data = http("GET", f"/search/issues?q={q}&per_page=20", token)
for item in data.get("items", []):
if item.get("title") == title:

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 pull requests from issue deduplication

If a pull request already has the requested title, this lookup accepts it as an existing issue, and cmd_create returns success without filing the requested issue. GitHub's search endpoint searches both issues and pull requests, but neither the query nor the exact-title filter excludes PRs. Add is:issue to the query or reject results containing pull_request before treating them as dedupe hits.

Useful? React with 👍 / 👎.

Comment on lines +241 to +245
_, data = http("GET", f"/search/issues?q={q}&per_page=20", token)
for item in data.get("items", []):
if item.get("title") == title:
return item
return None

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 Check subsequent search pages before creating another issue

When more than 20 results match the search phrase, an existing exact-title issue can fall outside the first page because the query also matches longer titles and body text. This function then returns None, causing a rerun to create a duplicate despite deduplication being enabled. Follow the search pagination before declaring the title absent, and narrow the query with in:title to reduce unrelated matches.

Useful? React with 👍 / 👎.

Comment on lines +302 to +305
_, got = http("GET", f"/repos/{args.repo}/issues/{number}", token)
if got.get("title") != title or got.get("number") != number:
die(f"readback mismatch for {args.repo}#{number}: "
f"title={got.get('title')!r}")

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 Compare the issue body during create readback

If readback returns the expected number and title but an empty or altered body, this condition still accepts the filing, records it in the ledger, and prints created+verified. A subsequent rerun also skips the issue through title deduplication, leaving the missing paperwork content undetected. This contradicts the documented verified-or-failed contract; compare the returned body against the submitted body, as cmd_comment already does.

Useful? React with 👍 / 👎.

def ledger_append(action: str, repo: str, number: str, detail: str) -> None:
path = ledger_path()
path.parent.mkdir(parents=True, exist_ok=True)
ts = datetime.now(timezone.utc).isoformat(timespec="seconds")

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 Preserve subsecond precision in the pacing ledger

When successive invocations run within the configured pacing interval, truncating the ledger timestamp to whole seconds lets the next write proceed almost a second early: a write recorded at epoch 100.9 becomes 100, so an immediate pace(3) waits only 2.1 seconds. This also makes test_pace_waits_remainder nondeterministically fail its minimum-duration assertion; running the unchanged test at fractional second 0.8 reproduced a roughly 0.2-second wait against its 0.4-second minimum. Preserve fractional seconds in the stored timestamp so pacing measures the actual elapsed interval.

Useful? React with 👍 / 👎.

if len(seen) >= data.get("total_count", 0) or not data.get("repositories"):
break
page += 1
if repo not in seen:

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 Compare repository scope names case-insensitively

When --repo uses different capitalization from the installation's canonical full_name, such as Developing-Today/code instead of developing-today/code, this check rejects the authorized repository and prevents every command from proceeding. GitHub documents both owner and repository names as case-insensitive, and installation_for() already compares owner logins that way. Normalize both sides of the scope membership check rather than requiring canonical capitalization.

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