Skip to content

fix(api): refresh state before project inventory reads#380

Merged
skulidropek merged 6 commits into
mainfrom
issue-372
Jun 7, 2026
Merged

fix(api): refresh state before project inventory reads#380
skulidropek merged 6 commits into
mainfrom
issue-372

Conversation

@skulidropek
Copy link
Copy Markdown
Member

Fixes #372

Summary

  • refresh shared .docker-git state before API project inventory reads and before API create preparation
  • serialize .docker-git git operations with a process-local Effect semaphore
  • keep project port proxy on local inventory lookup and align /health.projectsRoot with inventory root

Mathematical guarantees

Invariants

  • If DOCKER_GIT_STATE_AUTO_PULL is enabled and remote state contains project p, inventory reads can observe p after a successful refresh.
  • At most one guarded state git operation runs in the current process.
  • DOCKER_GIT_STATE_AUTO_PULL=false preserves local-only inventory reads.

Complexity

  • Inventory reads add O(git pull) remote round-trip only when auto-pull is enabled.

Tests

  • rtk bun run --filter @effect-template/lib typecheck
  • rtk bun run --filter @effect-template/api typecheck
  • rtk bun run --filter @effect-template/lib lint
  • rtk bun run --filter @effect-template/api lint
  • rtk bun run --cwd packages/api vitest run tests/projects.test.ts tests/api-console-routes.test.ts
  • rtk bun run --cwd packages/lib vitest run tests/usecases/state-repo-auto-pull.test.ts tests/usecases/create-project-state-sync-order.test.ts
  • rtk git diff --check

Serialize state repository git operations with a process-local lock.

Add regression coverage for remote inventory refresh, disabled auto-pull, mixed web/shell output directories, and health projectsRoot reporting.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

Warning

Review limit reached

@skulidropek, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 23 minutes and 50 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9ef0094d-692a-470e-887b-329538d8b12d

📥 Commits

Reviewing files that changed from the base of the PR and between 7f17905 and 01feba1.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • package.json
  • packages/api/src/services/project-port-proxy.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
  • packages/app/tests/docker-git/api-project-codec.test.ts
  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
📝 Walkthrough

Walkthrough

Этот PR реализует механизм синхронизации состояния проектов между shell и web версиями через автоматическое обновление инвентаря перед чтением, добавляет процесс-уровневое блокирование для сериализации git-операций и стабилизирует именование Docker Compose проектов.

Changes

State synchronization and Docker Compose stability for project inventory

Layer / File(s) Summary
Process-level git locking mechanism
packages/lib/src/usecases/state-repo/lock.ts
Вводит семафор с одним разрешением для предотвращения гонок при доступе к общему .docker-git рабочему дереву; экспортирует withStateGitLock для оборачивания эффектов.
Wrapping state operations with git lock
packages/lib/src/usecases/state-repo.ts, packages/lib/src/usecases/state-repo/local-ops.ts, packages/lib/src/usecases/state-repo/pull-push.ts
Переводит все операции состояния (stateSync, autoSyncState, autoPullState, stateInit, stateStatus, stateCommit, statePull, statePush) на выполнение под git-блокировкой; реализация выделена в внутренние *Raw функции.
Project inventory refresh and synchronization
packages/api/src/services/projects.ts, packages/api/src/services/project-port-proxy.ts
Добавляет readProjectItemsForInventory, которая выполняет auto-pull перед чтением инвентаря проектов; экспортирует refreshProjectStateForInventory; обновляет findProjectById, findProjectByKey, listProjects и resolveProxyProjectId для использования синхронизированного инвентаря.
Project inventory auto-pull test coverage
packages/api/tests/projects.test.ts
Добавляет интеграционные тесты с git-хелперами для проверки: обновления remote-состояния перед чтением инвентаря, соблюдения флага DOCKER_GIT_STATE_AUTO_PULL=false, корректной обработки абсолютных и относительных путей выходных директорий.
Controller Compose project name constants
packages/app/src/docker-git/controller-compose.ts
Экспортирует controllerComposeProjectName ("docker-git") и controllerComposeProjectArgs для единообразного именования Docker Compose проектов независимо от рабочей директории.
Docker commands with stable project naming
packages/app/src/docker-git/controller-docker.ts, packages/app/src/docker-git/controller-image-revision.ts
Интегрирует controllerComposeProjectArgs в команды docker compose в runCompose и inspectControllerComposeImageName для гарантированного использования стабильного имени проекта.
Docker Compose project naming tests
packages/app/tests/docker-git/controller-compose.test.ts, packages/app/tests/docker-git/controller-image-revision.test.ts
Проверяет, что runCompose и inspectControllerComposeImageName используют стабильное имя проекта в формируемых командах.
Validation and minor fixes
package.json, packages/api/src/http.ts, packages/api/tests/api-console-routes.test.ts, packages/app/tests/docker-git/gridland-react-singleton.test.ts
Фиксирует версию React 19.2.7 через overrides; обновляет калькуляцию projectsRoot в /health на основе process.cwd(); добавляет тестовые хелперы для изолированного тестирования с временными директориями и переменными окружения; проверяет контракт React singleton между приложением и Gridland-рендерером.

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: refreshing shared state before project inventory reads, which directly addresses the core objective of the PR.
Description check ✅ Passed The description covers all required template sections: links to issue #372, provides clear summary of changes, documents mathematical guarantees as requirements, and lists comprehensive verification steps.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #372: synchronizes project state between environments through auto-pull before inventory reads, prevents misalignment after create operations, and adds serialization to ensure consistent state observation.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #372 objectives: state synchronization, project inventory reads, create operation preparation, and controller compose project naming for consistency.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Requirements Alignment ✅ Passed PR требования реализованы: автоподтягивание перед инвентарными чтениями, сериализация git-операций, локализация port proxy, выравнивание /health, инварианты документированы, тесты покрывают обещанное.
Security Regression ✅ Passed No security regressions found. Code prevents command injection, path traversal, credential leaks, and uses safe resource management patterns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-372

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 521b1af
Status: success
Files: 6 (7.49 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

nothing to commit, working tree clean

@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 7f17905
Status: success
Files: 7 (10.93 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

nothing to commit, working tree clean

@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 57a1119
Status: success
Files: 7 (11.06 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

nothing to commit, working tree clean

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/api/src/http.ts`:
- Around line 808-810: The /health response computes cwd via
resolveWorkspaceRoot(process.cwd()) but computes projectsRoot from
defaultProjectsRoot(process.cwd()), causing a semantic mismatch; update the
/health handler to derive projectsRoot from the resolved workspace root (i.e.,
call defaultProjectsRoot(cwd) after resolveWorkspaceRoot) so both coordinates
use the same base, keeping behavior consistent with
loadProjectIndex/projectIdAliases, or alternatively update the /health
schema/docs to explicitly state that cwd is the resolved workspace root while
projectsRoot is independently computed; modify the code path around
resolveWorkspaceRoot and defaultProjectsRoot in the /health handler accordingly.

In `@packages/api/tests/api-console-routes.test.ts`:
- Around line 23-63: Add comprehensive TSDoc comments to the test helpers
withTempDir and withEnvVar: for each function include a short description,
`@param` and `@returns` annotations, and the required tags `@pure`, `@effect` (listing
used services like FileSystem and Process/Env behavior), `@invariant`,
`@precondition`, `@postcondition`, `@complexity`, and any thrown/error behavior;
ensure the docs describe the scoped lifecycle (temporary directory
creation/cleanup for withTempDir and environment variable set/restore for
withEnvVar), mention effect dependencies (e.g., FileSystem for withTempDir), and
keep wording consistent with the provided example.
- Around line 65-72: readResponseJson currently returns raw unknown JSON and
objectOrNull uses runtime checks; replace these with `@effect/schema` decoding so
boundary data is typed: have readResponseJson parse the response inside
Effect.tryPromise then pass the raw unknown into an `@effect/schema` Decoder (or
Schema.parse) for the expected response shape and return the decoded typed value
or a decoded error, and remove objectOrNull runtime checks by using a Schema for
the object shape (e.g., ResponseSchema) and validate via Schema.decode/parse
inside the same Effect so tests receive a typed object | null (or a validated
union) rather than unknown; update callers in the test to use the decoded type
and handle decoding failures through Effect error channels.

In `@packages/api/tests/projects.test.ts`:
- Around line 132-185: Add explicit TypeScript return type annotations and TSDoc
for runGit, runShell, makeStateRemote, and cloneStateRemote: declare the precise
Effect return types (matching the runCommandCapture/Effect.gen signatures, e.g.,
the appropriate Effect<E, A> or Promise-like effect type used in this codebase)
on each function signature, and add TSDoc blocks above each function including a
short description, `@pure`, `@effect`, `@complexity` tags, and `@param` entries for each
parameter and a `@returns` describing the effect result; ensure the annotated
return types align with the values returned (e.g., makeStateRemote returns an
Effect that yields the remotePath string) and use the existing function names
runGit, runShell, makeStateRemote, cloneStateRemote to locate where to add the
docs and types.

In `@packages/app/tests/docker-git/gridland-react-singleton.test.ts`:
- Around line 16-20: The test currently performs a direct synchronous assertion;
refactor the it(...) body to use `@effect/vitest` Effect composition by returning
or using an Effect that performs the resolution and the assertion (invoke
gridlandRequire.resolve("react") and compare to appReactEntry inside an Effect),
e.g. create an Effect that calls the resolve, wraps the expect assertion, and
then return/compose that Effect with the test runner utilities from
`@effect/vitest` so the test runs as an Effect rather than a direct synchronous
side-effect; update the test using the existing symbols gridlandRequire.resolve
and appReactEntry and the `@effect/vitest` test helpers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 72c51f3e-3e04-47fa-91aa-5d5ee5fd6132

📥 Commits

Reviewing files that changed from the base of the PR and between b4426a3 and 7f17905.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • package.json
  • packages/api/src/http.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
  • packages/app/src/docker-git/controller-compose.ts
  • packages/app/src/docker-git/controller-docker.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E (Runtime volumes + SSH)
  • GitHub Check: E2E (Login context)
  • GitHub Check: E2E (Clone cache)
  • GitHub Check: E2E (Browser command)
  • GitHub Check: E2E (Clone auto-open SSH)
  • GitHub Check: Test
  • GitHub Check: Lint
  • GitHub Check: Final build (windows-latest)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Implement Functional Core, Imperative Shell (FCIS) pattern: CORE layer contains only pure functions with immutable data and mathematical operations; SHELL layer isolates all effects (IO, network, database). Strict dependency direction: SHELL → CORE (never reverse).
Never use any, unknown, eslint-disable, ts-ignore, or as type assertions (except in rigorously justified cases with documentation). Always use exhaustive union type analysis through .exhaustive() pattern matching.
All external dependencies must be wrapped through typed interfaces and injected via Effect-TS Layer pattern. Never call external services directly from CORE functions.
Use monadic composition with Effect-TS for all effects: Effect<Success, Error, Requirements>. Compose effects through pipe() and Effect.flatMap(). Implement dependency injection via Layer pattern. Handle errors without try/catch blocks.
All functions must be pure in the CORE layer: no side effects (logging, console output, IO operations, mutations). Separate all side effects into the SHELL layer.
Use exhaustive pattern matching with Effect.Match instead of switch statements. Example: Match.value(item).pipe(Match.when(...), Match.exhaustive).
Document all functions with comprehensive TSDoc including: @pure (true/false), @effect (required services), @invariant (mathematical invariants), @precondition, @postcondition, @complexity (time and space), @throws Never (errors must be typed in Effect).
Use functional comment markers for code clarity: CHANGE (brief description), WHY (mathematical/architectural justification), QUOTE(ТЗ) (requirement citation), REF (RTM or message ID), SOURCE (external source with quote), FORMAT THEOREM (∀x ∈ Domain: P(x) → Q(f(x))), PURITY (CORE|SHELL), EFFECT (Effect type signature), INVARIANT (mathematical invariant), COMPLEXITY (time/space).
Define all external service dependencies as Context.Tag classes with fully typed methods returning Effect types. Example: `class Da...

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Implement property-based testing using fast-check for mathematical properties and invariants. Example: fc.property(fc.array(messageArbitrary), (messages) => isChronologicallySorted(sortMessagesByTimestamp(messages))).
Mock external dependencies in unit tests using Effect's testing utilities. Run tests without Effect runtime for speed. Example: Effect.provide(MockService), Effect.runPromise.

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Forbidden constructs in CORE code: any, eslint-disable, ts-ignore, async/await, raw Promise chains (then/catch), Promise.all, try/catch for logic control, console.*, switch statements (use Match with .exhaustive() instead)
All functions must use Effect-TS for composing effects: Effect<Success, Error, Requirements>. No direct async/await, Promise chains, or try/catch in product logic.
Functional comments must include: CHANGE, WHY, QUOTE(ТЗ) or n/a, REF, SOURCE or n/a, FORMAT THEOREM, PURITY (CORE|SHELL), EFFECT signature for SHELL functions, INVARIANT, and COMPLEXITY.
All data mutations must use immutable patterns (ReadonlyArray, readonly properties, Object.freeze); mutation in SHELL only when absolutely necessary and documented.

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Property-based tests (fast-check) must verify mathematical invariants; unit tests must use Effect test utilities without async/await.

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
**/*.{sh,bash,py,js,ts,jsx,tsx,go,java,rb,php}

📄 CodeRabbit inference engine (Custom checks)

Fail if changed files introduce command injection or unsafe shell/process execution with user-controlled input

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**/*.{py,js,ts,jsx,tsx,go,java,rb,php,sh,bash,c,cpp}

📄 CodeRabbit inference engine (Custom checks)

Fail if changed files introduce path traversal or writes outside intended project/container state directories

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**/*.{js,ts,jsx,tsx,py,java,go,rb,php,sh,bash,yml,yaml,json,env*,toml,cfg,config,dockerfile,dockerignore}

📄 CodeRabbit inference engine (Custom checks)

Fail if changed files expose credentials, tokens, private-keys, or PII in source, generated config, logs, or CI output

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • package.json
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**/*

⚙️ CodeRabbit configuration file

**/*: Ты строгий ревьюер SPEC DRIVEN DEVELOPMENT.

Перед выводами изучи README.md, другие *.md файлы, linked issues,
PR description, PR comments/discussion и релевантную кодовую базу.

Сверь изменения с исходным ТЗ/спекой и обсуждением. Флагай любой уход
от спеки, недокументированное изменение поведения, отсутствие тестов
для заявленного поведения и security-риск. Если спека не видна,
попроси автора добавить ее в issue или PR description.

Проверь решение с точки зрения формальной верификации: какие инварианты,
предусловия и постусловия можно доказать математически, а где доказуемость
слабая. Оцени решение с точки зрения теории игр: устойчивы ли стимулы,
нет ли выгодного обхода правил, и какое решение было бы сильнее.

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • package.json
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
**

⚙️ CodeRabbit configuration file

**: РОЛЬ: Математик-программист, специализирующийся на формально верифицируемой функциональной архитектуре.

ЦЕЛЬ: Создавать математически доказуемые решения через функциональную парадигму с полным разделением чистых вычислений и контролируемых эффектов.

МОДЕЛЬ РАССУЖДЕНИЯ:

  • Не выдавать “личные мнения”. Формировать вывод как результат симуляции профессионального обсуждения релевантных ролей
    (архитектор Effect/FP, ревьюер типов, страж CORE↔SHELL, тест-инженер).
  • Если запрос сформулирован как “что думаешь”, отвечать в терминах аргументов ролей и выбирать решение
    по критериям инвариантов, типовой безопасности и тестируемости (если пользователь явно просит выбор — выбрать и обосновать).

ПРАВИЛО ПРОЦЕССА (НЕ ФОРМАТ ОТВЕТА):
В начале работы (внутренне) формулировать Deep Research вопрос:
"I am looking for code that does , is there existing code that can do this?"
Далее:

  • если доступен проект/код — сперва искать и переиспользовать существующие паттерны (минимальный корректный diff),
  • если проект недоступен — опираться на предоставленный контекст и явно фиксировать допущения,
  • код писать только после формального понимания задачи (типы/инварианты → архитектура → код → тесты),
  • источники указывать только если реально использован внешний материал; иначе SOURCE: n/a.

ИНСТРУМЕНТАЛЬНОЕ ПОВЕДЕНИЕ (ОБЯЗАТЕЛЬНО, НЕ ФОРМАТ ОТВЕТА):

  • Агент всегда использует доступные инструменты среды (терминал, поиск по проекту, запуск тестов/скриптов, анализ сборки, web-ресёрч при необходимости)
    для ресёрча, проверки гипотез и выполнения действий. Приоритет: проверяемость, воспроизводимость, минимальный риск.
  • Агент не предлагает “гайд” как замену действия. Если действие возможно выполнить инструментами — агент выполняет его сам,
    затем сообщает, что было сделано и как повторить.
  • Любые инструкции (команды/процедуры) агент даёт только после собственной проверки на доступной среде.
    Если проверить невозможно — явно фиксирует ограничение и перечисляе...

Files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/lib/src/usecases/state-repo/lock.ts
  • package.json
  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/src/http.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/src/services/project-port-proxy.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
  • packages/app/src/docker-git/controller-docker.ts
package.json

📄 CodeRabbit inference engine (CLAUDE.md)

Dependencies must include Effect-TS (effect: ^3.x) for monadic effects and @effect/schema: ^0.x for validation with strong typing.

Dependencies like effect (^3.x) and @effect/schema (^0.x) are mandatory; project must enforce monadic composition through Effect.

Files:

  • package.json
**/{package*.json,requirements*.txt,setup.py,setup.cfg,Pipfile,Pipfile.lock,pyproject.toml,pom.xml,build.gradle,Gemfile,Gemfile.lock,go.mod,go.sum,composer.json,Cargo.toml,Cargo.lock}

📄 CodeRabbit inference engine (Custom checks)

Fail if dependency or package-manager changes materially increase supply-chain risk without justification

Files:

  • package.json
🧠 Learnings (19)
📓 Common learnings
Learnt from: ezocomp118-source
Repo: ProverCoderAI/docker-git PR: 366
File: packages/api/src/services/skiller.ts:366-369
Timestamp: 2026-06-03T17:35:55.293Z
Learning: In ProverCoderAI/docker-git, launching Electron via `setpriv --reuid/--regid` in the controller container causes a `Trace/breakpoint trap` crash even with `--no-sandbox`. The confirmed workaround is to launch Skiller as the controller user (bash -lc) and enforce project scope at the software level via SkillerContainerScope env vars (HOME, XDG_*, DOCKER_GIT_SKILLER_CONTAINER_HOME_PATH) and the add_project tRPC call. A future fix should use gosu/su-exec or a Chromium-sandbox-compatible credential-drop mechanism instead of setpriv. See PR `#366` for full context.
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Property-based tests (fast-check) must verify mathematical invariants; unit tests must use Effect test utilities without async/await.

Applied to files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/api/tests/api-console-routes.test.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to **/*.test.{ts,tsx} : Mock external dependencies in unit tests using Effect's testing utilities. Run tests without Effect runtime for speed. Example: `Effect.provide(MockService), Effect.runPromise`.

Applied to files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to package.json : Dependencies must include Effect-TS (`effect: ^3.x`) for monadic effects and `effect/schema: ^0.x` for validation with strong typing.

Applied to files:

  • packages/app/tests/docker-git/gridland-react-singleton.test.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Applies to **/*.{ts,tsx} : Resources with finalization must use ONLY `Effect.acquireRelease` combined with `Effect.scoped`.

Applied to files:

  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Interop with Promise/exceptions is permitted ONLY in SHELL via `Effect.try` or `Effect.tryPromise` with typed error mapping.

Applied to files:

  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/pull-push.ts
  • packages/api/tests/projects.test.ts
  • packages/lib/src/usecases/state-repo.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to **/*.{ts,tsx} : Use monadic composition with Effect-TS for all effects: `Effect<Success, Error, Requirements>`. Compose effects through `pipe()` and `Effect.flatMap()`. Implement dependency injection via Layer pattern. Handle errors without try/catch blocks.

Applied to files:

  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/api/src/services/projects.ts
  • packages/api/tests/projects.test.ts
  • packages/app/src/docker-git/controller-docker.ts
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All functions must use Effect-TS for composing effects: `Effect<Success, Error, Requirements>`. No direct async/await, Promise chains, or try/catch in product logic.

Applied to files:

  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
  • packages/app/src/docker-git/controller-docker.ts
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Applies to package.json : Dependencies like effect (^3.x) and effect/schema (^0.x) are mandatory; project must enforce monadic composition through Effect.

Applied to files:

  • packages/lib/src/usecases/state-repo/lock.ts
  • packages/app/tests/docker-git/controller-image-revision.test.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-22T21:08:18.083Z
Learnt from: skulidropek
Repo: ProverCoderAI/docker-git PR: 344
File: packages/app/src/docker-git/controller-compose.ts:34-40
Timestamp: 2026-05-22T21:08:18.083Z
Learning: In this repo’s docker-git controller compose generation, `${DOCKER_GIT_CONTROLLER_BUILD_SKILLER:-1}` should be treated as standard bash parameter expansion: when `DOCKER_GIT_CONTROLLER_BUILD_SKILLER` is unset, it defaults to the string "1". There is no "-1" mode. The runtime contract enforced by `packages/app/src/docker-git/controller-compose.ts` is: unset / "1" / "true" => output "1"; "0" / "false" => output "0". If review code shows branching/behavior for "-1" or any numeric value other than this 0/1 contract, flag it. Also ensure the Dockerfile ARG `DOCKER_GIT_CONTROLLER_BUILD_SKILLER` stays consistent with default `1`.

Applied to files:

  • packages/app/src/docker-git/controller-compose.ts
  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/app/src/docker-git/controller-docker.ts
📚 Learning: 2026-05-14T16:02:05.012Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: docs/integrations/skiller.md:0-0
Timestamp: 2026-05-14T16:02:05.012Z
Learning: Applies to docs/integrations/**/*.(ts|js)?(@(routes|handlers|api|middleware))* : API must scope Skiller filesystem access to the active project container by mapping `/home/<sshUser>` and project `targetDir` to controller-visible Docker volume paths

Applied to files:

  • packages/app/src/docker-git/controller-compose.ts
  • packages/app/tests/docker-git/controller-compose.test.ts
  • packages/api/tests/api-console-routes.test.ts
📚 Learning: 2026-06-03T17:35:55.293Z
Learnt from: ezocomp118-source
Repo: ProverCoderAI/docker-git PR: 366
File: packages/api/src/services/skiller.ts:366-369
Timestamp: 2026-06-03T17:35:55.293Z
Learning: In ProverCoderAI/docker-git, launching Electron via `setpriv --reuid/--regid` in the controller container causes a `Trace/breakpoint trap` crash even with `--no-sandbox`. The confirmed workaround is to launch Skiller as the controller user (bash -lc) and enforce project scope at the software level via SkillerContainerScope env vars (HOME, XDG_*, DOCKER_GIT_SKILLER_CONTAINER_HOME_PATH) and the add_project tRPC call. A future fix should use gosu/su-exec or a Chromium-sandbox-compatible credential-drop mechanism instead of setpriv. See PR `#366` for full context.

Applied to files:

  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-14T16:02:05.012Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: docs/integrations/skiller.md:0-0
Timestamp: 2026-05-14T16:02:05.012Z
Learning: Applies to docs/integrations/**/*.(ts|js)?(@(routes|handlers|api))* : API endpoint `POST /projects/by-key/:projectKey/terminal-sessions/:sessionId/skiller/open` must launch Skiller Electron app, register terminal session filesystem scope, and write output to ~/.docker-git/logs/skiller.log

Applied to files:

  • packages/app/src/docker-git/controller-compose.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-22T21:08:22.631Z
Learnt from: skulidropek
Repo: ProverCoderAI/docker-git PR: 344
File: packages/app/src/docker-git/controller-compose.ts:34-40
Timestamp: 2026-05-22T21:08:22.631Z
Learning: In the docker-git project, `${DOCKER_GIT_CONTROLLER_BUILD_SKILLER:-1}` in compose files is standard bash parameter expansion with default value `"1"` (not a literal "-1" mode). The supported runtime contract for `DOCKER_GIT_CONTROLLER_BUILD_SKILLER` in `packages/app/src/docker-git/controller-compose.ts` is: unset/`"1"`/`"true"` → `"1"`, `"0"`/`"false"` → `"0"`. There is no `-1` mode. The Dockerfile also declares `ARG DOCKER_GIT_CONTROLLER_BUILD_SKILLER=1`.

Applied to files:

  • packages/app/tests/docker-git/controller-compose.test.ts
📚 Learning: 2026-05-18T07:43:38.131Z
Learnt from: skulidropek
Repo: ProverCoderAI/docker-git PR: 313
File: packages/api/src/services/panel-cloudflare-tunnel.ts:123-135
Timestamp: 2026-05-18T07:43:38.131Z
Learning: In this repo’s ProverCoderAI/docker-git architecture, it is intentional for service modules under packages/api/src/services/ to call Node.js APIs directly (e.g., fs, child_process, fetch). Do not treat direct Node API usage in these service modules as a dependency-injection (DI) violation. This codebase provides the NodeContext at the program boundary (entry point) rather than injecting Context.Tag/Layer services into individual service modules; reviewers should only flag DI/context issues if the expected boundary setup is missing.

Applied to files:

  • packages/api/src/services/project-port-proxy.ts
  • packages/api/src/services/projects.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to **/*.{ts,tsx} : Implement service implementations as Layer.effect with Effect.gen pattern for dependency injection. Example: `const PostgresMessageRepository = Layer.effect(RepositoryTag, Effect.gen(function* (_) { ... }))`.

Applied to files:

  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/lib/src/usecases/state-repo/local-ops.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to **/*.{ts,tsx} : All errors must be typed in function signatures within Effect. Never use runtime exceptions (try/catch). Use typed error unions instead.

Applied to files:

  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
  • packages/api/tests/projects.test.ts
📚 Learning: 2026-05-13T07:10:13.213Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-13T07:10:13.213Z
Learning: Applies to **/*.{ts,tsx} : All external services must be integrated through Effect + Layer pattern with typed context tags (Context.Tag), never direct instantiation.

Applied to files:

  • packages/app/src/docker-git/controller-image-revision.ts
  • packages/api/tests/api-console-routes.test.ts
📚 Learning: 2026-05-13T07:09:47.992Z
Learnt from: CR
Repo: ProverCoderAI/docker-git PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-05-13T07:09:47.992Z
Learning: Applies to **/*.{ts,tsx} : Use exhaustive pattern matching with Effect.Match instead of switch statements. Example: `Match.value(item).pipe(Match.when(...), Match.exhaustive)`.

Applied to files:

  • packages/api/src/services/projects.ts
🪛 GitHub Check: Lint Effect-TS
packages/app/tests/docker-git/gridland-react-singleton.test.ts

[failure] 4-4:
'node:url' import is restricted from being used by a pattern. Do not import from node:* directly. Use @effect/platform-node or @effect/platform services


[failure] 3-3:
'node:path' import is restricted from being used by a pattern. Do not import from node:* directly. Use @effect/platform-node or @effect/platform services


[failure] 3-3:
'node:path' import is restricted from being used. Use @effect/platform Path instead of node:path


[failure] 2-2:
'node:module' import is restricted from being used by a pattern. Do not import from node:* directly. Use @effect/platform-node or @effect/platform services


[failure] 1-1:
'node:fs' import is restricted from being used by a pattern. Do not import from node:* directly. Use @effect/platform-node or @effect/platform services


[failure] 1-1:
'node:fs' import is restricted from being used. Use @effect/platform FileSystem instead of node:fs

🔇 Additional comments (18)
packages/lib/src/usecases/state-repo/lock.ts (1)

1-31: LGTM!

packages/lib/src/usecases/state-repo.ts (1)

41-41: LGTM!

Also applies to: 64-106, 108-149, 159-195, 319-342

packages/lib/src/usecases/state-repo/local-ops.ts (1)

10-10: LGTM!

Also applies to: 28-35, 37-64

packages/lib/src/usecases/state-repo/pull-push.ts (1)

12-12: LGTM!

Also applies to: 16-17, 19-63, 65-118

packages/api/src/services/projects.ts (2)

627-630: 💤 Low value

Изменение поведения: ошибки теперь пробрасываются вместо возврата пустого массива.

Раньше listProjects использовал catchAll(() => []), превращая любую ошибку чтения инвентаря в пустой список. Теперь ошибки listProjectItems мапятся в ApiInternalError и пробрасываются вызывающему коду.

Это изменение улучшает наблюдаемость (ошибки файловой системы не маскируются), но является breaking change для потребителей, ожидающих пустой массив при сбоях.

Убедитесь, что это намеренное изменение и обработчики API корректно возвращают HTTP 500 при ApiInternalError.


220-255: LGTM!

Also applies to: 296-296, 309-309, 690-690

packages/api/src/services/project-port-proxy.ts (2)

137-152: ⚡ Quick win

Несоответствие: port proxy не использует refresh-before-read паттерн.

resolveProxyProjectId использует listProjectItems напрямую, минуя readProjectItemsForInventory(), который выполняет auto-pull перед чтением инвентаря.

В то время как findProjectById, findProjectByKey и listProjects теперь синхронизируются с remote перед чтением (цель issue-372), port proxy lookup читает только локальное состояние.

Если это намеренно (проект уже должен существовать для работы port forward), рекомендую добавить комментарий, объясняющий почему auto-pull здесь пропущен. Если oversight — используйте readProjectItemsForInventory() из ./projects.js.


7-7: LGTM!

Also applies to: 143-144, 151-151

packages/api/tests/projects.test.ts (3)

119-130: LGTM!


9-10: LGTM!


400-534: LGTM!

packages/app/src/docker-git/controller-compose.ts (1)

26-41: LGTM!

packages/app/src/docker-git/controller-docker.ts (1)

382-386: LGTM!

packages/app/src/docker-git/controller-image-revision.ts (1)

136-142: LGTM!

packages/app/tests/docker-git/controller-compose.test.ts (1)

210-235: LGTM!

packages/app/tests/docker-git/controller-image-revision.test.ts (1)

193-214: LGTM!

package.json (1)

64-66: LGTM!

packages/app/tests/docker-git/gridland-react-singleton.test.ts (1)

1-4: gridland-react-singleton.test.ts: замечание про node: импорты неактуально*
В текущем содержимом packages/app/tests/docker-git/gridland-react-singleton.test.ts нет прямых импортов node:fs/node:module/node:path/node:url (внутри только @effect/vitest и чтение package.json через import assertions), поэтому требование заменить на @effect/platform для этого файла неприменимо.

			> Likely an incorrect or invalid review comment.

Comment thread packages/api/src/http.ts
Comment thread packages/api/tests/api-console-routes.test.ts
Comment thread packages/api/tests/api-console-routes.test.ts Outdated
Comment thread packages/api/tests/projects.test.ts Outdated
Comment thread packages/app/tests/docker-git/gridland-react-singleton.test.ts
@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 8885511
Status: success
Files: 7 (12.31 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

nothing to commit, working tree clean

@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 36a68cb
Status: success
Files: 7 (12.72 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

nothing to commit, working tree clean

@skulidropek
Copy link
Copy Markdown
Member Author

skulidropek commented Jun 6, 2026

AI Session Backup

Commit: 01feba1
Status: success
Files: 8 (17.37 MB)
Links: README | Manifest

git status

On branch issue-372
Your branch is up to date with 'origin/issue-372'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	artifacts/

nothing added to commit but untracked files present (use "git add" to track)

@skulidropek skulidropek merged commit b54828d into main Jun 7, 2026
18 of 19 checks passed
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.

Fix error into shell version

1 participant