diff --git a/shared/sx/ref/boundary_parser.py b/shared/sx/ref/boundary_parser.py index d51dee5..20b924d 100644 --- a/shared/sx/ref/boundary_parser.py +++ b/shared/sx/ref/boundary_parser.py @@ -36,13 +36,22 @@ def _ref_dir() -> str: def _project_root() -> str: - """Return the project root (3 levels up from shared/sx/ref/).""" + """Return the project root containing service directories. + + Dev: shared/sx/ref -> shared/sx -> shared -> project root + Docker: /app/shared/sx/ref -> /app (shared is inside /app) + """ ref = _ref_dir() - # shared/sx/ref -> shared/sx -> shared -> project root + # Go up 3 levels: shared/sx/ref -> project root root = os.path.abspath(os.path.join(ref, "..", "..", "..")) - # In Docker the layout is /app/shared/sx/ref -> /app - if not os.path.isdir(root): - root = os.path.abspath(os.path.join(ref, "..", "..")) + # Verify by checking for a known service directory or shared/ + if os.path.isdir(os.path.join(root, "shared")): + return root + # Docker: /app/shared/sx/ref -> /app + # shared is INSIDE /app, not a sibling — go up to parent of shared + root = os.path.abspath(os.path.join(ref, "..", "..")) + if os.path.isdir(os.path.join(root, "sx")): # /app/sx exists in Docker + return root return root @@ -98,12 +107,25 @@ def _extract_declarations( def _find_service_boundary_files() -> list[str]: - """Find all {service}/sx/boundary.sx files in the project.""" + """Find service boundary.sx files. + + Dev: {project}/{service}/sx/boundary.sx (e.g. blog/sx/boundary.sx) + Docker: /app/sx/boundary.sx (service's sx/ dir copied directly into /app/) + """ root = _project_root() - pattern = os.path.join(root, "*/sx/boundary.sx") - files = glob.glob(pattern) - # Exclude shared/sx/ref/ — that's the core boundary - return [f for f in files if "/shared/" not in f] + files: list[str] = [] + + # Dev layout: {root}/{service}/sx/boundary.sx + for f in glob.glob(os.path.join(root, "*/sx/boundary.sx")): + if "/shared/" not in f: + files.append(f) + + # Docker layout: service's sx/ dir is at {root}/sx/boundary.sx + docker_path = os.path.join(root, "sx", "boundary.sx") + if os.path.exists(docker_path) and docker_path not in files: + files.append(docker_path) + + return files # ---------------------------------------------------------------------------