Skip to content

feat: add backend exploration forcing#12

Merged
fazxes merged 2 commits intomainfrom
feat/backend-forcing
Apr 4, 2026
Merged

feat: add backend exploration forcing#12
fazxes merged 2 commits intomainfrom
feat/backend-forcing

Conversation

@fazxes
Copy link
Copy Markdown
Member

@fazxes fazxes commented Apr 4, 2026

Summary

  • Adds backend exploration forcing (Loop 1 item docs: use --merge and --admin for all PR merges #4) to steer agents away from frontend-heavy exploration in full-stack repos
  • classify_repo_dirs() classifies top-level dirs as frontend/backend using dir name matching with extension-sampling fallback for ambiguous dirs like src/
  • build_backend_escalation() injects a "Backend exploration directive" naming specific backend dirs when the last N cycles all touched frontend-classified paths
  • New config option backend_forcing_cycle (default 3) controls the threshold
  • Loop 1 now at 95% (20/21 components, only multi-repo remaining)

Test plan

  • 9 unit tests for classify_repo_dirs (frontend/backend by name, mixed repo, ambiguous dirs by extension, hidden dirs skipped, node_modules skipped, empty repo, unclassifiable dirs)
  • 7 unit tests for build_backend_escalation (before/at/after threshold, backend visited, no backend dirs, not enough history, custom threshold, names specific dirs)
  • 3 integration tests for prompt injection (block included, block absent when empty, coexists with test escalation)
  • make check passes (mypy strict, ruff, 189 pytest, dry-runs, ASCII, install.sh refs)
  • bash scripts/validate-docs.sh passes (doc consistency)
  • Behavioral verification with simulated full-stack repo structure

…code

In full-stack repos, agents gravitate toward React components. This adds
a three-part system to detect and correct frontend-heavy exploration:

1. classify_repo_dirs() classifies top-level dirs as frontend/backend
   using dir name matching with extension-sampling fallback
2. build_backend_escalation() injects a directive naming specific backend
   dirs when the last N cycles all touched frontend paths
3. New config option backend_forcing_cycle (default 3) controls threshold

Loop 1 item #4 complete. 20/21 components done (95%).
+19 tests (9 classification, 7 escalation, 3 prompt integration).
189 tests passing, make check clean.
Copy link
Copy Markdown

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

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: 00b4696b59

ℹ️ 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 nightshift/cycle.py
Comment on lines +199 to +203
threshold = int(config.get("backend_forcing_cycle", 3))
if cycle < threshold:
return ""
recent = state["recent_cycle_paths"]
if len(recent) < threshold:
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 Clamp backend forcing threshold to stored history

build_backend_escalation() accepts any backend_forcing_cycle, but it gates on len(state["recent_cycle_paths"]) >= threshold while state tracking keeps only the last 4 paths (append_cycle_state() truncates to [-4:]). That means any configured threshold above 4 can never trigger backend forcing, so the new config appears valid but silently disables the feature for those values.

Useful? React with 👍 / 👎.

Comment thread nightshift/cli.py
Comment on lines +152 to +156
backend_esc = build_backend_escalation(
cycle=cycle_number,
config=config,
state=state,
repo_dir=repo_dir,
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 Classify backend dirs from the active worktree

The cycle loop computes backend escalation using repo_dir, but all accepted changes happen in worktree_dir; after cycle 1 those directory trees can diverge. In that case the escalation block may suggest backend directories that were renamed/removed in the worktree or miss new backend dirs created earlier in the shift, producing inaccurate guidance for subsequent cycles.

Useful? React with 👍 / 👎.

- Move CLASSIFY_SKIP_DIRS to constants.py (no hardcoded data in logic)
- Filter "(none)" from prior paths in build_backend_escalation
- Sort __all__ exports alphabetically
- Export new constants and functions from __init__.py
@fazxes fazxes merged commit 60958cb into main Apr 4, 2026
6 checks passed
@fazxes fazxes deleted the feat/backend-forcing branch April 4, 2026 00:25
fazxes added a commit that referenced this pull request Apr 5, 2026
5-agent audit identified task selection as mesa-optimization: agent
optimizes session success over project progress. 5 more agents audited
the fix and found 7 issues, all resolved.

Phase 1 — Prompt fixes:
- Remove "smaller in scope" incentive from evolve-auto.md
- Queue order authoritative, handoff advisory
- "Tasks I Did NOT Pick and Why" in every handoff
- Tracker delta required in session reports
- Staleness multiplier (5+ sessions = 2x priority)
- All-integration-tasks edge case handled

Phase 2 — Task queue:
- environment: internal | integration tags
- blocked_reason subtypes: environment, dependency, design
- .next-id for atomic task ID allocation
- archive/ for done tasks (daemon auto-archives)
- Tagged #12, #28, #29 blocked-environment
- Fixed #43 broken frontmatter (duplicate of #40)

Phase 3 — Overseer avoidance detection:
- 6 new checks: stale tasks, cherry-picking, stuck integration,
  weak blocks, max attempts, skip accountability

Learnings index:
- INDEX.md with categorized one-line summaries (31/31 matched)
- Agent reads index, opens files only when relevant
- Updated CLAUDE.md, evolve.md Step 1 and Step 6l

Meta layer vision (8 new tasks #46-#53):
- #46 Healer — between-session trend observer
- #47 Multi-agent PR review panel
- #48 Human escalation (gh issue create + webhook)
- #49 Self-evaluation loop against real repos
- #50 Prompt self-refinement via strategist
- #51 Cross-session cost intelligence
- #52 Codebase world model (MODULE_MAP.md)
- #53 Agent generates its own tasks across all dimensions

Also: OPERATIONS.md stale task queue + --squash example fixed
fazxes added a commit that referenced this pull request Apr 9, 2026
fazxes added a commit that referenced this pull request Apr 9, 2026
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