No description
Find a file
changukyu 6193ed242d fix: serialize store read-modify-write and harden seed/queue paths
Under ThreadingHTTPServer several store writers ran unlocked read-modify-write
cycles, so concurrent operator actions could silently lose each other's
updates or revert an in-flight change.

Concurrency (_write_lock; external I/O kept OUTSIDE the lock):
- record_decision now takes _write_lock so a decision isn't reverted by a
  concurrent rescore/sweep.
- manual_search runs the network search first, then re-reads the submission
  under the lock before the queryHistory RMW (was clobbering concurrent edits).
- _apply_provider_usage_delta merges only usage/status onto the fresh row
  instead of rewriting a stale pre-search snapshot (kept an in-flight emergency
  disable from being reverted).
- _sync_provider_payloads preserves an operator's disable via an
  operatorDisabled flag (connectivity-only disables still reconnect).
- set_provider_enabled / emergency_disable / _sync_submission_provider_state /
  collect_keyword_candidates now lock (+ single transaction where applicable).

Robustness:
- seed: a zero-byte/corrupt image now yields a 'failed' submission + audit
  instead of an IndexError that aborted the whole import.
- ensure_queue: key the UPDATE/SELECT on the existing row id on a folder_path
  match (was matching zero rows and returning None -> seed TypeError); audit
  queue activation / legacy migration.
- store_enrichment: lastFailure uses the first failed item; auto-search dedup
  reads only the submission's evidence; log a swallowed face-crop load error.
- image_store: documents the pre-existing same-stem id limitation (a prior
  sibling-dependent fix was reverted — it resurrected decided submissions).

Tests: operator-disable survives reseed, usage delta keeps an in-flight
disable, seed survives an unanalyzable image, ensure_queue mismatched-id,
dismiss persistence.
2026-07-11 16:06:28 +09:00
docs docs: add 2026-06-22 multi-agent project review report 2026-06-22 14:00:45 +09:00
src/rights_filter fix: serialize store read-modify-write and harden seed/queue paths 2026-07-11 16:06:28 +09:00
tests fix: serialize store read-modify-write and harden seed/queue paths 2026-07-11 16:06:28 +09:00
web/operator-gui fix: Phase 1 HIGH review remediation (5 of 6) 2026-06-22 14:01:05 +09:00
.env.example fix: harden operator HTTP server 2026-06-20 18:18:54 +09:00
.gitattributes chore: add .gitattributes to enforce LF line endings 2026-06-22 11:22:23 +09:00
.gitignore test: add Playwright E2E harness for operator GUI with decision-flow spec 2026-06-21 21:10:22 +09:00
package.json chore: initial commit of copyrighter (rights_filter) 2026-06-09 09:50:31 +09:00
README.md docs: add project README 2026-06-21 22:35:31 +09:00
requirements-dev.txt test: add Playwright E2E harness for operator GUI with decision-flow spec 2026-06-21 21:10:22 +09:00
requirements.txt chore: pin runtime dependencies for offline air-gapped install 2026-06-20 18:19:08 +09:00
run_copyrighter_server.py chore: initial commit of copyrighter (rights_filter) 2026-06-09 09:50:31 +09:00

POSA Copyrighter

이미지 저작권 위험을 자동 분석하고, 운영자가 콘솔에서 근거를 확인해 승인 / 보류 / 반려를 판정하는 폐쇄망(air-gapped) 운영 도구입니다.

  • 분석 서버: 제출 이미지를 분석해 위험도·근거를 산출하고 SQLite에 저장
  • 운영자 콘솔: 심사 큐, 근거 검토, 판정, 지식 DB, 감사 로그를 제공하는 단일 페이지 웹 GUI
  • 외부 근거 검색: Naver 검색, Google Vision/Custom Search, 로컬 LLM(Ollama) 연동(선택)

요구 사항

  • Python 3.13
  • 런타임 서드파티 의존성은 이미지 처리 라이브러리뿐입니다(지연 로딩): numpy, opencv-python-headless, pillow

폐쇄망(air-gapped) 원칙: 모든 의존성·자산은 빌드/스테이징 머신에서 미리 받아 오프라인 휠로 설치합니다. 대상 서버는 설치·실행 시 인터넷에 접근하지 않습니다. 자세한 절차는 docs/operations/offline-install.md를 참고하세요.

설치

# 개발 머신 (온라인) — 의존성 설치
pip install -r requirements.txt          # 런타임
pip install -r requirements-dev.txt      # 테스트 포함

# 폐쇄망 대상 — 오프라인 휠로 설치 (예시)
pip install --no-index --find-links wheelhouse -r requirements.txt

.env.example를 복사해 .env를 만들고 필요한 값(인증 토큰, 검색 API 키 등)을 채웁니다. 키를 비워 두면 해당 외부 검색은 자동으로 비활성화됩니다.

cp .env.example .env

실행

python run_copyrighter_server.py
# 또는
python -m rights_filter.server --host 127.0.0.1 --port 9500

주요 옵션: --host, --port, --db(SQLite 경로), --images(제출 이미지 폴더), --static(운영자 GUI 경로), --env(.env 경로).

기본값으로 실행하면 http://127.0.0.1:9500 에서 운영자 콘솔이 열립니다.

보안: COPYRIGHTER_AUTH_TOKEN이 비어 있으면 데이터 라우트가 인증 없이 열립니다. 단일 호스트 개발 환경 외에는 반드시 토큰을 설정하세요.

프로젝트 구조

src/rights_filter/      분석·서버·통합·도메인 로직 (Python)
  server/               http.server 기반 API + 정적 파일 서빙, SQLite 저장소
  analysis/             이미지 분석·위험도 산출
  integrations/         Naver / Google / LLM 어댑터
web/operator-gui/       운영자 콘솔 (정적 SPA: index.html, app.js, styles.css)
tests/                  pytest 테스트
  operator_gui/         운영자 GUI 정적 검증 + Playwright E2E
docs/                   기획·설계·운영 문서

테스트

# 전체
python -m pytest

# 운영자 GUI E2E (Playwright)
playwright install chromium      # 빌드 머신에서 1회 — 브라우저 바이너리는 오프라인 번들에 포함
python -m pytest tests/operator_gui/
  • 브라우저(E2E) 테스트는 Playwright/Chromium이 없으면 자동으로 건너뜁니다(importorskip + graceful skip).
  • 운영자 워크벤치는 tests/operator_gui/pages/의 Page Object(OperatorWorkbench)와 conftest.py의 공용 픽스처를 사용합니다.

문서