Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .egg/phase-permissions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": "1.0",
"phases": {
"refine": {
"analyze": {
"allowed_operations": [
{
"type": "gh",
Expand Down Expand Up @@ -33,7 +33,7 @@
{
"type": "gh",
"pattern": "pr create*",
"description": "Cannot create PRs during refine phase"
"description": "Cannot create PRs during analyze phase"
}
],
"exit_requires": "human"
Expand Down Expand Up @@ -135,15 +135,15 @@
}
},
"phase_file_restrictions": {
"refine": {
"analyze": {
"allowed_patterns": [
".egg-state/contracts/*",
".egg-state/drafts/*analysis*",
".egg-state/checkpoints/*",
".egg-state/agent-outputs/*",
".egg-state/reviews/*"
],
"description": "Refine phase can only push contracts, analysis drafts, checkpoints, agent outputs, and reviews"
"description": "Analyze phase can only push contracts, analysis drafts, checkpoints, agent outputs, and reviews"
},
"plan": {
"allowed_patterns": [
Expand Down
8 changes: 4 additions & 4 deletions .egg/schemas/contract.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"current_phase": {
"type": "string",
"description": "Current pipeline phase",
"enum": ["refine", "plan", "implement", "pr"],
"default": "refine"
"enum": ["analyze", "plan", "implement", "pr", "refine"],
"default": "analyze"
},
"acceptance_criteria": {
"type": "array",
Expand Down Expand Up @@ -138,7 +138,7 @@
"type": "object",
"description": "Phase-specific configurations",
"propertyNames": {
"enum": ["refine", "plan", "implement", "pr"]
"enum": ["analyze", "plan", "implement", "pr", "refine"]
},
"additionalProperties": {
"$ref": "#/$defs/phaseConfig"
Expand Down Expand Up @@ -500,7 +500,7 @@
"phase": {
"type": "string",
"description": "Pipeline phase this feedback belongs to",
"enum": ["refine", "plan", "implement", "pr"]
"enum": ["analyze", "plan", "implement", "pr", "refine"]
},
"questions": {
"type": "array",
Expand Down
2 changes: 1 addition & 1 deletion .egg/schemas/phase-permissions.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"$ref": "#/$defs/phasePermissions"
},
"properties": {
"refine": {
"analyze": {
"$ref": "#/$defs/phasePermissions"
},
"plan": {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ secrets.yaml
docker-compose.override.yml
.compose-build-hash

# Agent sandbox artifacts
CLAUDE.md

# OS
.DS_Store
Thumbs.db
Expand Down
2 changes: 1 addition & 1 deletion docs/hitl-decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ client.create_decision(
{"id": "q1", "question": "What is the expected traffic volume?"},
{"id": "q2", "question": "Any specific performance requirements?"},
],
phase="refine", # Optional: helps sandbox locate correct draft paths
phase="analyze", # Optional: helps sandbox locate correct draft paths
)
```

Expand Down
2 changes: 1 addition & 1 deletion gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ POST /api/v1/sessions/create
Description: Create a new session with optional SDLC phase tracking

PATCH /api/v1/sessions/<session_token>/phase
Request: {phase: "refine"|"plan"|"implement"|"pr"}
Request: {phase: "analyze"|"plan"|"implement"|"pr"}
Auth: Bearer {launcher_secret}
Description: Update the SDLC pipeline phase for a session
```
Expand Down
6 changes: 3 additions & 3 deletions gateway/agent_restrictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Tester: Can write test files only
- Documenter: Can write docs and markdown only
- Integrator: Can only write handoff output (read-only otherwise)
- Refiner: Can write drafts and agent-outputs only, blocked from source code and contracts
- Refiner: Can write drafts and agent-outputs only, blocked from source code and contracts (analyze phase)
- Reviewers: Can write reviews and agent-outputs only

The gateway uses these restrictions during git push to validate that
Expand Down Expand Up @@ -45,7 +45,7 @@ class AgentRole:
ARCHITECT = "architect"
TASK_PLANNER = "task_planner"
RISK_ANALYST = "risk_analyst"
# Refine-phase roles
# Analyze-phase roles
REFINER = "refiner"
# Reviewer roles
REVIEWER_CODE = "reviewer_code"
Expand Down Expand Up @@ -444,7 +444,7 @@ def _matches_pattern(file_path: str, pattern: str) -> bool:
blocked_patterns=_REVIEWER_BLOCKED,
)

# Refine-phase agent patterns
# Analyze-phase agent patterns

REFINER_PATTERNS = AgentFilePattern(
role=AgentRole.REFINER,
Expand Down
14 changes: 11 additions & 3 deletions gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def git_push() -> tuple[Response, int] | Response:
# SECURITY: Check phase-based file restrictions for local mode sessions.
# This replaces the blanket local-mode push block with granular phase-based
# restrictions. Each phase has specific allowed/blocked file patterns:
# - refine/plan: Can only push .egg-state/ files (contracts, drafts, checkpoints)
# - analyze/plan: Can only push .egg-state/ files (contracts, drafts, checkpoints)
# - implement: Can push code but not .egg-state/ (except checkpoints)
# - pr: Can push everything
#
Expand Down Expand Up @@ -3271,6 +3271,10 @@ def session_create() -> tuple[Response, int] | Response:
if gid is not None and (not isinstance(gid, int) or gid < 0):
return make_error("Invalid gid: must be a non-negative integer")

# Backwards compat: normalize legacy "refine" → "analyze"
if phase == "refine":
phase = "analyze"

# Validate phase if provided
if phase is not None and phase not in VALID_PIPELINE_PHASES:
return make_error(
Expand Down Expand Up @@ -3744,7 +3748,7 @@ def session_update(session_token: str) -> tuple[Response, int] | Response:


# Valid SDLC pipeline phases
VALID_PIPELINE_PHASES = frozenset({"refine", "plan", "implement", "pr"})
VALID_PIPELINE_PHASES = frozenset({"analyze", "plan", "implement", "pr"})


@app.route("/api/v1/sessions/<session_token>/phase", methods=["PATCH"])
Expand All @@ -3759,7 +3763,7 @@ def session_update_phase(session_token: str) -> tuple[Response, int] | Response:

Request body:
{
"phase": "refine"|"plan"|"implement"|"pr"
"phase": "analyze"|"plan"|"implement"|"pr"
}

Args:
Expand All @@ -3775,6 +3779,10 @@ def session_update_phase(session_token: str) -> tuple[Response, int] | Response:
if not phase:
return make_error("Missing phase")

# Backwards compat: normalize legacy "refine" → "analyze"
if phase == "refine":
phase = "analyze"

if phase not in VALID_PIPELINE_PHASES:
return make_error(
f"Invalid phase: {phase}. Must be one of: {', '.join(sorted(VALID_PIPELINE_PHASES))}"
Expand Down
2 changes: 1 addition & 1 deletion gateway/phase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def get_phase_permissions(phase: str) -> tuple[Response, int]:
Get the permissions for a specific phase.

URL params:
phase: Phase name (refine, plan, implement, pr)
phase: Phase name (analyze, plan, implement, pr)

Returns:
{"success": true, "data": {"allowed": [...], "blocked": [...], "exit_requires": "..."}}
Expand Down
6 changes: 3 additions & 3 deletions gateway/phase_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PipelinePhase(StrEnum):
complexity in the gateway module. Values must be kept in sync.
"""

REFINE = "refine"
ANALYZE = "analyze"
PLAN = "plan"
IMPLEMENT = "implement"
PR = "pr"
Expand Down Expand Up @@ -409,7 +409,7 @@ def _load_permissions(self) -> None:
def _get_default_permissions(self) -> dict[PipelinePhase, PhasePermissions]:
"""Get default permissions when no file is available."""
return {
PipelinePhase.REFINE: PhasePermissions(
PipelinePhase.ANALYZE: PhasePermissions(
allowed_operations=[
Operation(OperationType.GH, "issue comment *", "Comment on issues"),
Operation(OperationType.GH, "issue edit *", "Edit issues"),
Expand Down Expand Up @@ -487,7 +487,7 @@ def _get_default_phase_file_restrictions(self) -> dict[PipelinePhase, PhaseFileR
- pr: Everything
"""
return {
PipelinePhase.REFINE: PhaseFileRestriction(
PipelinePhase.ANALYZE: PhaseFileRestriction(
allowed_patterns=[
".egg-state/contracts/*",
".egg-state/drafts/*analysis*",
Expand Down
2 changes: 1 addition & 1 deletion gateway/phase_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TransitionRole(StrEnum):

# Phase transition graph: defines which phases can transition to which
VALID_TRANSITIONS: dict[PipelinePhase, list[PipelinePhase]] = {
PipelinePhase.REFINE: [PipelinePhase.PLAN],
PipelinePhase.ANALYZE: [PipelinePhase.PLAN],
PipelinePhase.PLAN: [PipelinePhase.IMPLEMENT],
PipelinePhase.IMPLEMENT: [PipelinePhase.PR],
PipelinePhase.PR: [], # Terminal state - no automatic transitions
Expand Down
6 changes: 3 additions & 3 deletions gateway/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class Session:
last_seen: Last request timestamp (for heartbeat)
expires_at: Session expiry timestamp
agent_role: Role set by workflow context for contract operations
phase: SDLC pipeline phase (refine, plan, implement, pr) for operation filtering
phase: SDLC pipeline phase (analyze, plan, implement, pr) for operation filtering
"""

session_token: str | None # Raw token, only in memory
Expand Down Expand Up @@ -522,7 +522,7 @@ def register_session(
container_id: Docker container ID
container_ip: Container's IP address on the Docker network
mode: Repository visibility mode (private or public)
phase: SDLC pipeline phase (e.g., "refine", "plan", "implement", "pr")
phase: SDLC pipeline phase (e.g., "analyze", "plan", "implement", "pr")
issue_number: Optional GitHub issue number for checkpoint linkage
pr_number: Optional GitHub PR number for checkpoint linkage
pipeline_id: Optional pipeline run ID for multi-agent correlation
Expand Down Expand Up @@ -787,7 +787,7 @@ def update_phase(self, token: str, phase: str) -> bool:

Args:
token: The session token
phase: The new phase value (e.g., "refine", "plan", "implement", "pr")
phase: The new phase value (e.g., "analyze", "plan", "implement", "pr")

Returns:
True if phase was updated, False if session not found
Expand Down
6 changes: 3 additions & 3 deletions gateway/tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,10 +1406,10 @@ def test_pr_create_allowed_without_phase_backward_compat(self, client, auth_head
data = json.loads(response.data)
assert data["success"] is True

def test_pr_create_blocked_during_refine_phase(self, client, auth_headers_with_phase):
"""PR create is blocked when session phase is 'refine'."""
def test_pr_create_blocked_during_analyze_phase(self, client, auth_headers_with_phase):
"""PR create is blocked when session phase is 'analyze'."""
headers, mock_result, mock_policy_result, current_session_manager = auth_headers_with_phase(
"refine"
"analyze"
)

with (
Expand Down
14 changes: 7 additions & 7 deletions gateway/tests/test_phase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def mock_contract():
title="Test Issue",
url="https://github.com/test/repo/issues/123",
),
current_phase=PipelinePhase.REFINE,
current_phase=PipelinePhase.ANALYZE,
)


Expand Down Expand Up @@ -119,7 +119,7 @@ def test_get_current_phase_success(self, client, auth_headers, mock_contract):
assert response.status_code == 200
data = response.get_json()
assert data["success"] is True
assert data["data"]["phase"] == "refine"
assert data["data"]["phase"] == "analyze"
assert data["data"]["exit_requires"] == "human"
assert data["data"]["next_phase"] == "plan"

Expand Down Expand Up @@ -149,17 +149,17 @@ def test_get_current_phase_not_found(self, client, auth_headers):
class TestGetPhasePermissions:
"""Tests for GET /api/v1/phase/permissions/<phase>."""

def test_get_permissions_refine(self, client, auth_headers):
"""Get permissions for refine phase."""
def test_get_permissions_analyze(self, client, auth_headers):
"""Get permissions for analyze phase."""
response = client.get(
"/api/v1/phase/permissions/refine",
"/api/v1/phase/permissions/analyze",
headers=auth_headers,
)

assert response.status_code == 200
data = response.get_json()
assert data["success"] is True
assert data["data"]["phase"] == "refine"
assert data["data"]["phase"] == "analyze"
assert data["data"]["exit_requires"] == "human"
assert len(data["data"]["blocked_operations"]) > 0

Expand Down Expand Up @@ -282,7 +282,7 @@ def test_advance_phase_success(self, client, auth_headers, mock_contract):
assert response.status_code == 200
data = response.get_json()
assert data["success"] is True
assert data["data"]["from_phase"] == "refine"
assert data["data"]["from_phase"] == "analyze"
assert data["data"]["to_phase"] == "plan"

def test_advance_phase_unauthorized(self, client, mock_contract):
Expand Down
Loading
Loading