Skip to content

Phases 1-2: Repository setup, docs, and gateway extraction (partial) - #1

Closed
james-in-a-box[bot] wants to merge 3 commits into
mainfrom
jib/jib-20260202-130850-2491128/work
Closed

james-in-a-box[bot] wants to merge 3 commits into
mainfrom
jib/jib-20260202-130850-2491128/work

Conversation

@james-in-a-box

@james-in-a-box james-in-a-box Bot commented Feb 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implement Phase 1, 1.5, and partial Phase 2 of the egg extraction plan.

Phase 1: Repository Infrastructure (Complete)

  • Repository structure (gateway/, sandbox/, cli/, shared/, tests/)
  • pyproject.toml with uv for dependency management
  • GitHub Actions workflows (lint.yml, test.yml)
  • ./dev wrapper script for CI parity
  • Pre-commit, Dependabot configurations
  • Module structure with init.py files
  • Initial unit tests

Phase 1.5: Documentation (Complete)

  • Security documentation extracted from james-in-a-box ADRs
  • docs/security.md: Core security model and threat mitigations
  • docs/adr/: Git isolation and credential injection ADRs
  • docs/configuration.md, setup.md, api.md, troubleshooting.md

Phase 2: Gateway Extraction (In Progress)

Completed:

  • shared/egg_config/: Config loading and validation
  • shared/egg_logging/: Structured JSON/console logging
  • gateway/policy.py: Policy engine (parameterized for egg)

Remaining:

  • session_manager.py, git_client.py, github_client.py
  • worktree_manager.py and other supporting modules
  • gateway.py Flask app
  • Test files

Issue: none

Test plan:

  1. Clone repo, run ./dev setup
  2. Run ./dev native lint - should pass
  3. Run ./dev native test - tests should pass
  4. Verify from gateway.policy import PolicyEngine works

Authored-by: jib

Implement Phase 1 of the egg extraction plan:

- Create repository structure with gateway/, sandbox/, cli/, shared/, tests/
- Add pyproject.toml with uv for dependency management
- Add GitHub Actions workflows (lint.yml, test.yml)
- Add ./dev wrapper script for CI parity (runs act locally)
- Add pre-commit configuration
- Add Dependabot configuration
- Write README.md with architecture overview
- Write CONTRIBUTING.md with development guidelines
- Add egg.yaml.example and secrets.yaml.example
- Create module structure with __init__.py files
- Add initial unit tests for module imports
- Add docs/testing.md and docs/architecture.md

This establishes the infrastructure before extracting gateway code in Phase 2.

Authored-by: jib
Extract and create documentation for the egg repository:

- docs/security.md: Core security model and threat mitigations
- docs/adr/git-isolation-architecture.md: Git worktree isolation ADR
- docs/adr/credential-injection.md: Credential injection ADR
- docs/configuration.md: Configuration reference
- docs/setup.md: Setup guide
- docs/api.md: Gateway API reference
- docs/troubleshooting.md: Common issues and solutions

Security documentation extracted from james-in-a-box ADRs:
- ADR-Gateway-Credential-Injection.md
- ADR-Git-Isolation-Architecture.md
- ADR-Anthropic-API-Credential-Injection.md

All docs regenerated for egg (no james-specific references).

Authored-by: jib
@james-in-a-box james-in-a-box Bot changed the title Phase 1: Repository setup and CI infrastructure Phase 1 & 1.5: Repository setup and documentation Feb 2, 2026
Add core shared modules:
- shared/egg_config/loader.py: YAML config loading with env var expansion
- shared/egg_config/validators.py: Config validation utilities
- shared/egg_logging/logger.py: Structured JSON/console logging

Add first gateway module:
- gateway/policy.py: Policy engine for branch ownership and access control
  - Parameterized for egg (configurable bot_name, branch_prefix)
  - Removed james-in-a-box specific references
  - Uses EGG_TRUSTED_USERS instead of GATEWAY_TRUSTED_USERS

Remaining Phase 2 tasks:
- Port session_manager, git_client, github_client, worktree_manager
- Port remaining supporting modules
- Port gateway.py Flask app
- Port test files

Authored-by: jib
@james-in-a-box james-in-a-box Bot changed the title Phase 1 & 1.5: Repository setup and documentation Phases 1-2: Repository setup, docs, and gateway extraction (partial) Feb 2, 2026
@james-in-a-box james-in-a-box Bot closed this Feb 2, 2026
james-in-a-box Bot pushed a commit that referenced this pull request Feb 7, 2026
Fix critical issues from review:
- Task ID convention mismatch: Parser now generates task-{phase}-{number}
  format matching CLI expectations (Issue #3)
- Integer parsing vulnerability: Added parse_task_id() and parse_phase_id()
  helpers with proper validation and error handling (Issue #1)
- URL parameter injection: Use urllib.parse.urlencode for query params (Issue #2)
- Placeholder task numbering: Use task_number=1 instead of 0 (Issue #5)
- Silent failure in shell script: gh_api_safe now sets GH_API_FAILED flag
  and returns empty JSON for graceful fallback (Issue #6)

Additional improvements:
- Updated Task model pattern to accept task-P-N format
- Added comprehensive test coverage for error paths
- Added edge case tests for plan parser
- All 73 tests pass, ruff linter clean

Authored-by: egg
jwbron added a commit that referenced this pull request Feb 7, 2026
* Implement Phase 3: Agent CLI and prompt integration

Add the agent-facing components for the SDLC pipeline:

- Contract CLI (egg-contract) for agents to interact with contract state:
  - show: Display current contract state
  - add-commit: Link commits to tasks
  - update-notes: Add implementation notes
  - mark-task/mark-phase: Update status (reviewer role)
  - add-decision: Create HITL decision points

- Agent rules file (contract.md) with CLI usage guidance

- Document templates for refine and plan phases:
  - analysis.md: Problem analysis template
  - plan.md: Implementation plan template with task ID format

- SDLC prompt builder that provides phase-specific context and
  instructions to the agent

- Plan parser for extracting tasks from plan documents:
  - Parses [TASK-X-Y] patterns from markdown
  - Supports YAML front matter for structured task definitions
  - Generates placeholder tasks for empty phases
  - Produces warnings for parse issues

- Unit tests for plan parser and contract CLI

Issue: #133

Authored-by: egg

* Fix bash syntax error in build-sdlc-prompt.sh

Change the inner heredoc delimiter in the PR format example from 'EOF'
to 'BODY' to avoid conflicting with the outer heredoc delimiter. The
'EOF' on line 363 was being interpreted as the end of the outer heredoc
(starting at line 322), causing a syntax error on the closing ')'.

Authored-by: egg

* Fix lint and type errors in Phase 3 contracts code

- Fix import sorting in shared/egg_contracts/__init__.py (I001)
- Fix import sorting in tests/sandbox/test_contract_cli.py (I001)
- Fix unused variable in tests/sandbox/test_contract_cli.py (F841)
- Fix import sorting and remove unused import in tests/shared/egg_contracts/test_plan_parser.py (I001, F401)
- Fix mypy type annotation in shared/egg_contracts/plan_parser.py
- Fix mypy no-any-return errors in sandbox/egg_lib/contract_cli.py
- Apply ruff formatting fixes

Authored-by: egg

* Address code review feedback for Phase 3 implementation

Fix critical issues from review:
- Task ID convention mismatch: Parser now generates task-{phase}-{number}
  format matching CLI expectations (Issue #3)
- Integer parsing vulnerability: Added parse_task_id() and parse_phase_id()
  helpers with proper validation and error handling (Issue #1)
- URL parameter injection: Use urllib.parse.urlencode for query params (Issue #2)
- Placeholder task numbering: Use task_number=1 instead of 0 (Issue #5)
- Silent failure in shell script: gh_api_safe now sets GH_API_FAILED flag
  and returns empty JSON for graceful fallback (Issue #6)

Additional improvements:
- Updated Task model pattern to accept task-P-N format
- Added comprehensive test coverage for error paths
- Added edge case tests for plan parser
- All 73 tests pass, ruff linter clean

Authored-by: egg

* Remove unused GH_API_FAILED variable from build-sdlc-prompt.sh

The GH_API_FAILED variable was declared and set but never read,
triggering shellcheck SC2034 warning. The variable has been removed
as the functionality was never implemented.

Authored-by: egg

* Address remaining PR review feedback

- Fix add-decision RBAC: Add decisions.* to FIELD_OWNERSHIP with
  IMPLEMENTER role, allowing implementers to create decisions while
  only humans can resolve them.

- Fix array append in validator: Handle appending to arrays when
  idx == len(array) by appending instead of raising IndexError.
  Also handle the case in apply_mutation where old_value doesn't
  exist yet for append operations.

- Document race condition in add-decision: Added comments explaining
  the TOCTOU race condition between reading decision count and
  submitting mutation. Gateway should handle conflicts.

- Fix mark-task/mark-phase role documentation: Updated docstrings
  and help text to clarify these operations require REVIEWER role.

- Add commit SHA validation: New validate_commit_sha() function
  validates 7-40 character hex strings for git SHAs.

- Fix short question ellipsis: Only append "..." if question is
  longer than 50 characters.

- Add comprehensive tests for new functionality including commit
  SHA validation and array append operations.

Authored-by: egg

* Fix ruff format issue in contract_cli.py

Collapse multi-line ValueError string to single line to satisfy
ruff format requirements.

Authored-by: egg

* Address low-severity review feedback

- Add integration tests verifying plan parser task IDs are compatible
  with the CLI's parse_task_id() function
- Add RETURN trap in gh_api_safe() to clean up temp files on interruption
- Refactor MockGatewayHandler to use a factory function that creates
  handler classes with isolated responses, ensuring thread safety when
  running tests in parallel
- Generate unique HEREDOC delimiter using random suffix to prevent
  injection if issue body contains the delimiter string

Authored-by: egg

---------

Co-authored-by: jwbron <8340608+jwbron@users.noreply.github.com>
Co-authored-by: james-in-a-box[bot] <246424927+james-in-a-box[bot]@users.noreply.github.com>
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