Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a43be14
chore: pcc sync worker
themarolt Apr 6, 2026
d71ee96
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 7, 2026
d616b51
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 9, 2026
ad1fb1b
chore: pcc sync worker wip1
themarolt Apr 14, 2026
c462cc9
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 14, 2026
b7bc7a5
fix: comments
themarolt Apr 14, 2026
3d012f5
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 14, 2026
d9c3a75
fix: lint
themarolt Apr 14, 2026
e1c45e7
fix: lint
themarolt Apr 14, 2026
34463ab
fix: mouads comments
themarolt Apr 15, 2026
31867f4
fix: joanas comments
themarolt Apr 15, 2026
f5c90fb
fix: comment
themarolt Apr 15, 2026
8b6800a
fix: bugfixes
themarolt Apr 15, 2026
c0a80b0
fix: bugfixes
themarolt Apr 16, 2026
9af4f28
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 16, 2026
2c9ab8d
fix: bugfixes
themarolt Apr 16, 2026
08be688
fix: guard against empty levelRows after HIERARCHY_LEVEL filter
themarolt Apr 16, 2026
b54fa85
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 17, 2026
33ad92e
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 20, 2026
a26acf6
fix: comments
themarolt Apr 20, 2026
68d71c7
fix: address copilot and cursor review feedback
themarolt Apr 20, 2026
d9037e5
fix: address copilot shutdown and diagnostics feedback
themarolt Apr 20, 2026
dce54ad
Merge branch 'main' into feat/pcc-sync-CM-1086-CM-1087-CM-1088-CM-1089
themarolt Apr 20, 2026
286765c
fix: comments
themarolt Apr 20, 2026
f3fd2b2
fix: trim everything
themarolt Apr 20, 2026
c6b6350
fix: query
themarolt Apr 20, 2026
15bb77c
fix: comments
themarolt Apr 20, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DROP INDEX IF EXISTS pcc_sync_errors_dedup_idx;

DROP TABLE IF EXISTS pcc_projects_sync_errors;

ALTER TABLE segments DROP COLUMN IF EXISTS maturity;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Add maturity field to segments for PCC project_maturity_level sync
ALTER TABLE segments ADD COLUMN IF NOT EXISTS maturity TEXT NULL;

-- Catch-all table for PCC sync issues that require manual review
CREATE TABLE IF NOT EXISTS pcc_projects_sync_errors (
id BIGSERIAL PRIMARY KEY,
run_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
external_project_id TEXT,
external_project_slug TEXT,
error_type TEXT NOT NULL,
details JSONB,
resolved BOOLEAN NOT NULL DEFAULT FALSE
);

-- Deduplication index: one unresolved error per (project, error_type).
-- On repeated daily exports the same error upserts in place instead of accumulating rows.
-- Excludes rows where external_project_id IS NULL (e.g. SCHEMA_MISMATCH with no project id).
CREATE UNIQUE INDEX IF NOT EXISTS pcc_sync_errors_dedup_idx
ON pcc_projects_sync_errors (external_project_id, error_type)
WHERE NOT resolved AND external_project_id IS NOT NULL;

-- Deduplication index for unidentifiable rows (no external_project_id).
-- Keyed on (error_type, reason) so repeated daily exports don't accumulate duplicate rows
-- for the same class of malformed input (e.g. rows missing PROJECT_ID/NAME/DEPTH).
CREATE UNIQUE INDEX IF NOT EXISTS pcc_sync_errors_dedup_unknown_idx
ON pcc_projects_sync_errors (error_type, (details->>'reason'))
WHERE NOT resolved AND external_project_id IS NULL;
86 changes: 68 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions scripts/services/docker/Dockerfile.pcc_sync_worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:20-bullseye-slim AS builder

RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/crowd/app
RUN npm install -g corepack@latest && corepack enable pnpm && corepack prepare pnpm@9.15.0 --activate

COPY ./pnpm-workspace.yaml ./pnpm-lock.yaml ./
RUN pnpm fetch

COPY ./services ./services
RUN pnpm i --frozen-lockfile

FROM node:20-bullseye-slim AS runner

RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/crowd/app
RUN npm install -g corepack@latest && corepack enable pnpm && corepack prepare pnpm@9.15.0 --activate

COPY --from=builder /usr/crowd/app/node_modules ./node_modules
COPY --from=builder /usr/crowd/app/services/base.tsconfig.json ./services/base.tsconfig.json
COPY --from=builder /usr/crowd/app/services/libs ./services/libs
COPY --from=builder /usr/crowd/app/services/archetypes/ ./services/archetypes
COPY --from=builder /usr/crowd/app/services/apps/pcc_sync_worker/ ./services/apps/pcc_sync_worker
18 changes: 18 additions & 0 deletions scripts/services/docker/Dockerfile.pcc_sync_worker.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/.git
**/node_modules
**/venv*
**/.webpack
**/.serverless
**/.env
**/.env.*
**/.idea
**/.vscode
**/dist
.vscode/
.github/
frontend/
scripts/
.flake8
*.md
Makefile
backend/
53 changes: 53 additions & 0 deletions scripts/services/pcc-sync-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.1'

x-env-args: &env-args
DOCKER_BUILDKIT: 1
NODE_ENV: docker
SERVICE: pcc-sync-worker
CROWD_TEMPORAL_TASKQUEUE: pccSync
SHELL: /bin/sh

services:
pcc-sync-worker:
build:
context: ../../
dockerfile: ./scripts/services/docker/Dockerfile.pcc_sync_worker
command: 'pnpm run start'
working_dir: /usr/crowd/app/services/apps/pcc_sync_worker
env_file:
- ../../backend/.env.dist.local
- ../../backend/.env.dist.composed
- ../../backend/.env.override.local
- ../../backend/.env.override.composed
environment:
<<: *env-args
restart: always
networks:
- crowd-bridge

pcc-sync-worker-dev:
build:
context: ../../
dockerfile: ./scripts/services/docker/Dockerfile.pcc_sync_worker
command: 'pnpm run dev'
working_dir: /usr/crowd/app/services/apps/pcc_sync_worker
env_file:
- ../../backend/.env.dist.local
- ../../backend/.env.dist.composed
- ../../backend/.env.override.local
- ../../backend/.env.override.composed
environment:
<<: *env-args
hostname: pcc-sync-worker
networks:
- crowd-bridge
volumes:
- ../../services/libs/common/src:/usr/crowd/app/services/libs/common/src
- ../../services/libs/logging/src:/usr/crowd/app/services/libs/logging/src
- ../../services/libs/snowflake/src:/usr/crowd/app/services/libs/snowflake/src
- ../../services/libs/temporal/src:/usr/crowd/app/services/libs/temporal/src
- ../../services/apps/pcc_sync_worker/src:/usr/crowd/app/services/apps/pcc_sync_worker/src

networks:
crowd-bridge:
external: true
36 changes: 36 additions & 0 deletions services/apps/pcc_sync_worker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@crowd/pcc-sync-worker",
"scripts": {
"start": "CROWD_TEMPORAL_TASKQUEUE=pccSync SERVICE=pcc-sync-worker tsx src/index.ts",
"start:debug": "CROWD_TEMPORAL_TASKQUEUE=pccSync SERVICE=pcc-sync-worker LOG_LEVEL=debug tsx src/index.ts",
"start:debug:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && CROWD_TEMPORAL_TASKQUEUE=pccSync SERVICE=pcc-sync-worker LOG_LEVEL=debug tsx src/index.ts",
"dev": "nodemon --watch src --watch ../../libs --ext ts --exec pnpm run start:debug",
"dev:local": "nodemon --watch src --watch ../../libs --ext ts --exec pnpm run start:debug:local",
"lint": "npx eslint --ext .ts src --max-warnings=0",
"format": "npx prettier --write \"src/**/*.ts\"",
"format-check": "npx prettier --check .",
"tsc-check": "tsc --noEmit",
"trigger-export": "SERVICE=pcc-sync-worker tsx src/scripts/triggerExport.ts",
"trigger-export:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=pcc-sync-worker tsx src/scripts/triggerExport.ts",
"trigger-cleanup": "SERVICE=pcc-sync-worker tsx src/scripts/triggerCleanup.ts",
"trigger-cleanup:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && SERVICE=pcc-sync-worker tsx src/scripts/triggerCleanup.ts"
},
"dependencies": {
"@crowd/archetype-standard": "workspace:*",
"@crowd/archetype-worker": "workspace:*",
"@crowd/common": "workspace:*",
"@crowd/database": "workspace:*",
"@crowd/types": "workspace:*",
"@crowd/logging": "workspace:*",
"@crowd/slack": "workspace:*",
"@crowd/snowflake": "workspace:*",
"@crowd/temporal": "workspace:*",
"@temporalio/client": "~1.11.8",
"@temporalio/workflow": "~1.11.8",
"tsx": "^4.7.1",
"typescript": "^5.6.3"
},
"devDependencies": {
"nodemon": "^3.0.1"
}
}
Loading
Loading