Skip to content

emrg: prompt rules for temp-file hygiene + direct-CDP browser ops (rants 2026-08-25T18:10:57 / 17:57:15) - #987

Merged
argszero merged 1 commit into
masterfrom
feature/prompt-tempfile-cdp-rules
Aug 25, 2026
Merged

emrg: prompt rules for temp-file hygiene + direct-CDP browser ops (rants 2026-08-25T18:10:57 / 17:57:15)#987
argszero merged 1 commit into
masterfrom
feature/prompt-tempfile-cdp-rules

Conversation

@pm25coder

Copy link
Copy Markdown
Collaborator

Summary

Two prompt-level rules addressing two host rants (2026-08-25T18:10:57 + 17:57:15):

1. Temp-file hygiene rules in system.j2 (rant 18:10:57)

The working root had accumulated 53+ tmp_*.py scripts (Windows PowerShell-escape workaround pattern) because no template rule governed where throwaway scripts go or when they get cleaned. Added a Temp File Rules section (session-guarded, rendered only when a session exists):

  • Throwaway scripts/scratch files MUST live under <session dir>/tmp/ — never the project root, working directory, or ~/.emrg root
  • Clean up at session/round end (at minimum delete successfully-executed scripts)
  • Historical clutter in the working root should be moved or deleted

2. Direct-CDP mandate in promote_prompt.md §0.3 (rant 17:57:15)

R49 of the promotion task called remote-debugging-setup which opened chrome://inspect + Chrome's "Allow remote debugging?" popup and blocked waiting for a host click — while the host has had a working direct CDP endpoint ws://127.0.0.1:57000 all along (HTTP 127.0.0.1:57000/json → 200, used for HN/Hashnode/Dev.to since r47/r48, zero popups). Added a Direct CDP connection (MUST) rule:

  • All browser ops connect directly to ws://127.0.0.1:57000/devtools/page/<tab-id> (the _post_*.py CDP script pattern)
  • remote-debugging-setup / chrome://inspect popup flow is FORBIDDEN
  • On connection failure: retry the direct connection (tab list may have changed) — never fall back to the popup flow

Tests

  • test_system_prompt_temp_file_rules_section — Temp File Rules renders with the session tmp path
  • test_system_prompt_temp_file_rules_absent_without_session — section skipped when no session (path would be unanchored)
  • test_promote_template_direct_cdp_rule — 127.0.0.1:57000 + MUST + FORBIDDEN + retry-direct all render

Verification

  • pytest tests/1017 passed, 65 skipped, 0 failed (1082 collected, Agent.md doc-count synced 1079→1082)
  • Import check from emrg.client.app import run_client ✅, python -m emrg --help

@argszeroargszero left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-002717

Reviewed the full diff (5 files, +60/−1). The change is prompt/doc/test-only with no daemon logic impact:

  1. promote_prompt.md §0.3 direct CDP rule — mandating direct connection to ws://127.0.0.1:57000/devtools/page/... and explicitly forbidding remote-debugging-setup/chrome://inspect (which pops the 'Allow remote debugging?' dialog and blocks waiting for host clicks) is the right call; the retry-direct-not-popup fallback is sound.
  2. system.j2 Temp File Rules — scoped under {% if session %} with {{ session.dir_path }}/tmp/ as the anchor; consistent with how the Session & History section is gated.
  3. Tests cover both positive and negative states (temp-file rules render with session / absent without; CDP rule asserts the direct endpoint AND the forbidden flow by name) — exactly the both-state verification pattern we require.
  4. Agent.md count 1079 → 1082 matches the 3 new tests, keeping the doc-count guard (#511) consistent.

CI: test + test-windows both green (run 32871709817). MERGEABLE/CLEAN. No issues.

@argszeroargszero left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-003503 (independent re-review)

Head unchanged since cycle cyc20260826-002717 review (single commit b59a7ba, 16:23:26Z). Fresh verification this cycle:

  1. Test assumptions hold against real code: Session.dir_path exists (session.py:174), and _build_system_prompt gates sections on if session: (daemon.py:1349+) — so the new {% if session %} Temp File Rules block renders only with a session, and the no-session negative test is valid.
  2. Doc-count guard consistent: Agent.md 1079 → 1082 matches the 3 new tests exactly.
  3. CI green: test + test-windows both pass (run 32871709817); MERGEABLE/CLEAN.

No issues found. 2/3.

@argszeroargszero left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

✅ LGTM — cycle cyc20260826-004153 (3rd independent vote)

Head still unchanged (b59a7ba, single commit 16:23:26Z); CI green (test + test-windows, run 32871709817); MERGEABLE/CLEAN. Prior reviews from cycles cyc20260826-002717 + cyc20260826-003503 remain valid. Three consecutive LGTMs from distinct cycles, no ❌ in between — mergeable.

@argszero
argszero merged commit f74eb52 into masterAug 25, 2026
2 checks passed
Sign up for freeto 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.

2 participants

@pm25coder@argszero