Skip to content
Closed

v2 #18

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
26fd51e
add: README, CLAUDE.md
KO1231 Sep 12, 2026
1670bb8
add: uv + Python 3.14 への移行と品質ゲートの整備
KO1231 Sep 12, 2026
48109a8
add: MIME パーサの作り直し (epc.gmail)
KO1231 Sep 12, 2026
d4e310f
add: 後続フェーズに繰り越した宿題を CLAUDE.md に明記
KO1231 Sep 12, 2026
c6cd51c
add: 設定とラベル解決 (epc.settings, epc.gmail.labels/auth/client)
KO1231 Sep 12, 2026
25adbd4
add: epc という名前の由来と適用範囲を CLAUDE.md に記載
KO1231 Sep 13, 2026
a8a0fac
add: 信頼できない入力の無害化と注入検知 (epc.security)
KO1231 Sep 13, 2026
c522d7b
add: CSS解決を伴わない前提と、その穴をコーパスに固定
KO1231 Sep 13, 2026
5990568
add: トークン予算配分と引用除去 (epc.classify.budget)
KO1231 Sep 13, 2026
c6d7b5a
add: プロンプト管理と信頼できない入力の囲い込み (epc.classify.prompt)
KO1231 Sep 13, 2026
8eebca2
add: 分類バックエンド3種と共通の応答パーサ (epc.classify)
KO1231 Sep 13, 2026
698cd60
add: パイプライン、アクションエンジン、mutation の行き先 (Phase 4)
KO1231 Sep 13, 2026
1552569
add: ログ・分類履歴・差分同期 (Phase 5)
KO1231 Sep 13, 2026
c4cec31
add: reasoning_effort / verbosity / max_output_tokens を設定可能に
KO1231 Sep 13, 2026
f3dcbb2
change: OpenAI バックエンドを Responses API に、ローカルは chat completions に分離
KO1231 Sep 13, 2026
ffe9258
remove: legacy 実装を削除し、Phase 4 を締める
KO1231 Sep 13, 2026
cd0ea95
fix: .env.example を現行の実装に合わせる
KO1231 Sep 13, 2026
a8292d7
refactor: dry_run をルートに出し、run セクションを state に整理
KO1231 Sep 13, 2026
a02b0c6
add: SIGTERM での安全な停止 (epc.shutdown)
KO1231 Sep 13, 2026
01f38a7
add: コンテナ化 (Dockerfile, compose, CI)
KO1231 Sep 13, 2026
4b973a5
add: SQS ディスパッチと AWS バックエンド (SSM / S3)
KO1231 Sep 13, 2026
004e680
add: Terraform 一式 (Phase 7)
KO1231 Sep 13, 2026
1053d9f
docs: eval を後回しにした判断と、そこで決まった設計を記録
KO1231 Sep 13, 2026
e193ed1
docs: README を日本語に
KO1231 Sep 13, 2026
c2fb37a
add: settings.json
KO1231 Sep 13, 2026
f8fadda
update: バージョンを 2.0.0 に
KO1231 Sep 13, 2026
94f7da6
update: 依存関係系バージョンの調整
KO1231 Sep 13, 2026
1b74f6a
fix: 壊れたヘッダや通信エラーで実行全体が落ちないようにする
KO1231 Sep 13, 2026
14009f3
fix: 想定外の例外を1スレッドの失敗に閉じ込め、分類済みの結果を必ず書き込む
KO1231 Sep 13, 2026
f5d664b
fix: epc login が保存済みの壊れた資格情報に阻まれず、常に認証し直せるようにする
KO1231 Sep 13, 2026
525ba51
change: チェックポイントを廃止し、毎回クエリで探す方式と失敗が続くスレッドの記録に置き換える
KO1231 Sep 13, 2026
80f1c8c
add: ラベル付きスレッドに後から届いた返信へ既存の優先度ラベルを引き継ぐ
KO1231 Sep 14, 2026
c40aff8
fix: 区切り線・お知らせの見出し・転送メールで本文を切り落とさないよう引用と署名の判定を絞る
KO1231 Sep 14, 2026
b8abc50
fix: 非表示テキストの除去で見えている本文まで消さないよう、隠す指定だけを判定する
KO1231 Sep 14, 2026
b7bf89f
fix: 件名・送信者・添付ファイル名などペイロード内の全文字列をサニタイズと injection 検出に通す
KO1231 Sep 14, 2026
ff173e7
fix: security.on_suspected_injection の flag を記録のみにし、アクションを外すのは downgr…
KO1231 Sep 14, 2026
1f2b628
fix: ECS で設定とポリシーを注入して起動できるようにし、Secrets Manager 版の資格情報ストアを実装する
KO1231 Sep 14, 2026
74cf6d7
fix: pipeline のログを structlog に移し、ライブラリのログもマスキングと JSON 出力を通す
KO1231 Sep 14, 2026
2c64fab
fix: 履歴ファイルにモデルの reason を既定で残さず、applied を dispatched_via に置き換える
KO1231 Sep 14, 2026
0a532ed
fix: create_if_missing を epc labels --create に置き換え、epc apply が計画後に付いた…
KO1231 Sep 14, 2026
6d945e0
update: dry_run の適用範囲の説明と CLAUDE.md の未実装一覧を実態に合わせ、イメージに入るプロンプトを2ファイルに絞る
KO1231 Sep 14, 2026
f733511
fix: 転送メールは自身の件名と Apple Mail 形式の目印で判定し、転送本文を切り落とさない
KO1231 Sep 15, 2026
6073fa3
fix: 文字サイズを戻す指定を数値に限らず、明示的な 0 だけを非表示と判定する
KO1231 Sep 15, 2026
307646f
fix: http.client の例外も GmailError に包み、一覧取得や取得の失敗でも sink を必ず閉じる
KO1231 Sep 15, 2026
f1aefb2
fix: 設定パラメータの put-parameter に --tier を付け、ECS の /tmp をイメージ側で VOLUME とし…
KO1231 Sep 15, 2026
4ca3438
fix: 失敗の記録を内容起因の解析エラーに限り、分類器の版に llm 設定全体と版数を含め、確定済みのスキップを優先して残す
KO1231 Sep 15, 2026
077ffbb
fix: 失敗した呼び出しのトークン数も集計し、ログには例外の型とステータスだけを出す
KO1231 Sep 15, 2026
144d49c
fix: dry run を sink の種類だけで判断し、--config と --policy の明示を環境変数より優先する
KO1231 Sep 15, 2026
9f6cd64
fix: 引用はスレッド内に同じ文面があると確かめたときだけ削り、署名除去をやめ、上限は引用行から削る。本文は MIME 構造に沿って取り…
KO1231 Sep 15, 2026
f7501bb
fix: compose のビルドを実行環境のアーキテクチャに任せ、.env.example の古い変数名を直す
KO1231 Sep 16, 2026
451fe81
fix: コンテナのユーザーの GID も 10001 に固定する
KO1231 Sep 16, 2026
7cc2bd3
fix: ライブラリのリクエストごとのログを WARNING に絞り、dry run と SQS のサマリを「計画」「キュー投入」として表示する
KO1231 Sep 16, 2026
360c92b
update: 処理するスレッドがなかった回は、サマリの代わりに時刻付きの1行だけを出す
KO1231 Sep 16, 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
13 changes: 13 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"permissions": {
"deny": [
"Read(/environments/*/config.yml)",
"Read(/.env)",
"Read(/**/*.env)"
],
"ask": [
"Read(/.env.*)",
"Read(/**/.env.*)"
]
}
}
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Only what the image needs: the package, its lockfile, and the generic prompts.
*
!pyproject.toml
!uv.lock
!README.md
!src/
# The two generic prompts by name, as `.gitignore` does. A personal prompt left
# in a working copy must not ride along into a pushed image.
!prompts/system.md
!prompts/user.md

# Belt and braces. The patterns above already exclude these, but this file is
# the last thing standing between a secret and a layer that gets pushed.
**/.env
**/config.yml
**/policy.yml
**/secrets/
**/log/
**/.state/
**/__pycache__/
29 changes: 26 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
OPENAI_API_KEY=sk-????
OPENAI_PROMPT_ID=pmpt_????
OPENAI_PROMPT_VERSION=????
# Secrets only. Everything else lives in config.yml, which is meant to be
# readable and diffable.
#
# Not loaded automatically — there is no python-dotenv. Use:
# uv run --env-file .env epc run

# --- backend: openai -------------------------------------------------------
# A key scoped to api.responses.write and api.responses.read is sufficient;
# the broader model.request scope is not needed.
OPENAI_API_KEY=sk-...

# --- backend: bedrock ------------------------------------------------------
# Uses the usual AWS credential resolution (profile, instance role, env). Set
# these only if you are not using a profile or a role.
# AWS_PROFILE=...
# AWS_REGION=ap-northeast-1

# --- backend: local --------------------------------------------------------
# No credential needed. The server address is llm.base_url in config.yml, not
# an environment variable, so the same container image can point at a server
# outside itself.

# --- Any setting can be overridden from the environment --------------------
# EPC__ prefix, __ between levels. Useful for one-off runs and for schedulers.
# EPC__GMAIL__MAX_THREADS=50
# EPC__DRY_RUN=true
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @KO1231
* @KO1231
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI

on:
pull_request:
push:
branches: [develop]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
# Keep CI from silently resolving around the committed lockfile.
UV_FROZEN: "1"

jobs:
quality:
runs-on: ubuntu-latest
steps:
# Actions are pinned by commit SHA: a mutable tag is itself a
# supply-chain hole. Comments record which release each SHA is.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
with:
enable-cache: true

- name: Install
run: uv sync --all-extras

- name: Lint
run: uv run ruff check --output-format=github .

- name: Format
run: uv run ruff format --check .

- name: Types
run: uv run mypy

- name: Test
# The eval suite hits a real LLM API against local golden data; it must
# never run here.
run: uv run pytest -m "not eval" --cov --cov-report=term-missing

terraform:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.14.5

- name: Format
run: terraform fmt -check -recursive environments/ modules/

- name: Validate
# -backend=false: validation needs no state and no credentials.
run: |
for env in environments/*/; do
terraform -chdir="$env" init -backend=false
terraform -chdir="$env" validate
done

audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0

- name: Audit dependencies for known vulnerabilities
run: |
uv export --all-extras --no-emit-project --format requirements.txt > requirements.txt
uvx pip-audit --requirement requirements.txt --strict
2 changes: 1 addition & 1 deletion .github/workflows/close_pr_from_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
};

await github.rest.issues.createComment(commentParams);
await github.rest.pulls.update(closeParams);
await github.rest.pulls.update(closeParams);
2 changes: 1 addition & 1 deletion .github/workflows/close_pr_to_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
};

await github.rest.issues.createComment(commentParams);
await github.rest.pulls.update(closeParams);
await github.rest.pulls.update(closeParams);
65 changes: 65 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Container

on:
pull_request:
paths: [Dockerfile, .dockerignore, compose.yaml, pyproject.toml, uv.lock, "src/**"]
push:
branches: [develop]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: container-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
# Actions pinned by commit SHA; a mutable tag is itself a supply-chain hole.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Lint the Dockerfile
uses: hadolint/hadolint-action@06be81baf89a55ffd0e24b8f04a4185738dd3387 # v3.5.0
with:
dockerfile: Dockerfile

- uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0

- name: Build
run: docker build --load -t epc:ci .

- name: The entrypoint runs and the package is importable
run: |
docker run --rm epc:ci --version
docker run --rm --entrypoint python epc:ci -c "import epc.pipeline, epc.classify.factory"

- name: It runs as a non-root user
run: |
uid=$(docker run --rm --entrypoint id epc:ci -u)
test "$uid" = "10001" || { echo "expected uid 10001, got $uid"; exit 1; }

- name: No build toolchain reached the runtime image
run: |
if docker run --rm --entrypoint sh epc:ci -c "command -v gcc cc make uv" 2>/dev/null; then
echo "a build tool survived into the runtime layer"; exit 1
fi

- name: Nothing personal was baked in
# The .dockerignore is the last thing between a secret and a pushed
# layer, so its failure is checked rather than assumed.
run: |
if docker run --rm --entrypoint sh epc:ci -c \
"ls /app/config.yml /app/policy.yml /app/.env /app/secrets 2>/dev/null"; then
echo "personal files were copied into the image"; exit 1
fi

- name: Scan for known vulnerabilities
uses: aquasecurity/trivy-action@a9c7b0f06e461e9d4b4d1711f154ee024b8d7ab8 # v0.36.0
with:
image-ref: epc:ci
severity: HIGH,CRITICAL
ignore-unfixed: true
exit-code: "1"
50 changes: 45 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,52 @@
# --- IDE / OS -------------------------------------------------------------
/.idea
/**/__pycache__
/.env
.DS_Store

/config.yml
# --- Python ---------------------------------------------------------------
__pycache__/
*.py[cod]
/.venv/
/build/
/dist/
*.egg-info/
/.pytest_cache/
/.ruff_cache/
/.mypy_cache/
/.coverage
/htmlcov/

# --- Secrets and personal configuration -----------------------------------
# The remote is public. Nothing below this line may ever be committed.
/.env
/config.yml
/policy.yml
/secrets/**
!/secrets/.gitkeep

/prompts
# Prompts: deny by default, allow the committed generic ones by name. A new
# file under prompts/ stays ignored until it is listed here explicitly, which is
# the correct default when the remote is public — the legacy gptoss_*.txt
# templates carry personal escalation rules and must never be published.
/prompts/*
!/prompts/system.md
!/prompts/user.md

# --- Runtime artefacts ----------------------------------------------------
/log
/.state/

# --- Terraform ------------------------------------------------------------
# Only environments/sample/ is committed. dev/ and prod/ carry real account
# IDs, ARNs and bucket names.
/environments/*/
!/environments/sample/
**/.terraform/
*.tfstate
*.tfstate.*
.terraform.lock.hcl
/environments/*/.plan

/log
# --- Evaluation data ------------------------------------------------------
# Golden-set threads are real mail. Fixtures under tests/fixtures/ are
# synthetic and ARE committed.
/tests/eval/data/
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Install once with: uv run pre-commit install
# The remote is public, so the secret scanner is the load-bearing hook here.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=512"]
- id: check-merge-conflict
- id: check-yaml
- id: check-toml
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- id: no-commit-to-branch
args: ["--branch", "main"]

- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaks

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.6
hooks:
- id: ruff-check
args: ["--fix"]
- id: ruff-format
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13.5
3.14.5
1 change: 1 addition & 0 deletions .terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.14.0
Loading
Loading