Skip to content
Draft
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
a4e97cb
feat(noema-agent): add calendar conflict-check tool
claude Aug 30, 2026
206655c
Merge remote-tracking branch 'origin/develop' into claude/noema-conte…
claude Aug 30, 2026
6a5365e
fix(noema-agent): fail closed on oversized existing-commitment batches
claude Aug 30, 2026
dff8550
feat(calendar): persist conflict judgments and human corrections (G-06)
claude Aug 30, 2026
7c20155
fix(calendar): address Devin review findings on the judgment/correcti…
claude Aug 30, 2026
86f4bd9
fix(calendar): scope judgments by workspace_id, fix 5 more Devin find…
claude Aug 30, 2026
e3e09ad
fix(calendar): no-op overrides preserve original reason; update stale…
claude Aug 30, 2026
a5cebe5
docs: fix self-contradiction in the just-updated doctoring doc
claude Aug 30, 2026
ee83eff
feat(attachments): quarantine content-type mismatches, add attachment…
claude Aug 30, 2026
dcc9fcd
fix(attachments,calendar): OOXML false-positive quarantine, unprocess…
claude Aug 30, 2026
ba9a01b
feat(attachments): add AttachmentReparseWorker to consume reparse_pen…
claude Aug 30, 2026
522d422
fix(attachments,calendar): Devin review round on AttachmentReparseWorker
claude Aug 30, 2026
ef49fc9
fix(attachments): correct cursor starvation and advisory-lock connect…
claude Aug 30, 2026
da81656
fix(migrations,calendar): correct downgrade constraint drop and add o…
claude Aug 30, 2026
733f22c
fix(newsdom-worker): dedicated lease connection + starvation-free cur…
claude Aug 30, 2026
d93cc8c
fix(workers): set AUTOCOMMIT on the dedicated advisory-lease connection
claude Aug 31, 2026
603ff17
fix(security): scope Email/Attachment queries by workspace_id, not ju…
claude Aug 31, 2026
fae8dbc
docs(security): verify workspace-claim trust boundary raised by review
claude Aug 31, 2026
af9ed1e
fix(security): enforce workspace claim matches org at auth layer
claude Aug 31, 2026
6cd3892
fix: add missing bootstrap_db columns and stop reparse from deleting …
claude Aug 31, 2026
ffed35e
fix: populate workspace_id in the ZIP-archive fixture importer's bulk…
claude Aug 31, 2026
b778fb6
fix: enforce workspace-safe Noema identity
seonghobae Aug 31, 2026
6df8f44
fix: match email upsert/bootstrap uniqueness to the workspace-scoped …
claude Aug 31, 2026
62b74a0
fix: migration 0020 also recognizes bootstrap's owner-only email index
claude Aug 31, 2026
d05e2a6
fix: enforce workspace identity across mail flows
seonghobae Aug 31, 2026
25e8e60
Merge commit '62b74a0532cbd2f7374ccc3c6febbb77846367dc' into codex/pr…
seonghobae Aug 31, 2026
9c49bd2
docs(adr-0005): correct stale auth workspace-claim rejection description
claude Aug 31, 2026
2c0fe37
test: align bootstrap identity regression
seonghobae Aug 31, 2026
2a6c8a5
test: accept early legacy index cleanup
seonghobae Aug 31, 2026
94f02eb
fix: create workspace identity after bootstrap backfill
seonghobae Aug 31, 2026
b355ec3
Merge commit '9c49bd29af162b8fea88f136b89744f4154f3d85' into codex/pr…
seonghobae Aug 31, 2026
611c9b5
fix: migration 0020 must check constraint before dropping backing index
claude Aug 31, 2026
e11cb07
Merge remote-tracking branch 'origin/claude/noema-contextualwisdomlab…
claude Aug 31, 2026
c3e2856
fix(pop3): resolve workspace from existing mail instead of nonexisten…
claude Aug 31, 2026
399c1e5
fix(fixtures): store imported email under the configured workspace id
claude Aug 31, 2026
c6085ef
fix(email-import): scope owner quota count to owner, not workspace
claude Aug 31, 2026
1b85703
fix(calendar): rename correction rationale column to two-word name
claude Aug 31, 2026
a3b5f8f
fix(db): preserve calendar rationale migration path
seonghobae Aug 31, 2026
a1027af
style(tests): replace unnecessary lambda with named function
claude Aug 31, 2026
786d154
fix(import): scope duplicate lookup and graph projection to workspace
claude Aug 31, 2026
968b21f
fix(search): exclude non-parsed attachments from hybrid search
claude Aug 31, 2026
96cd0c0
fix(db): skip absent legacy email table during bootstrap
seonghobae Aug 31, 2026
d3422db
fix(tests): add missing skip-on-no-postgres guard to two new smoke tests
claude Aug 31, 2026
b9b02dd
fix(db): stop 0001's fresh-install migration from crashing, fix hidde…
claude Sep 1, 2026
c1f02e2
fix(newsdom): stop pending-result starvation; fix(data-api): lock att…
claude Sep 1, 2026
780d910
fix(attachments): index reparsed attachment content into the content …
claude Sep 1, 2026
5096d1f
fix(attachments): preload graph relationships for reparse
seonghobae Sep 1, 2026
beded49
fix(attachments): persist reparsed graph topology and vectors
seonghobae Sep 1, 2026
f63a109
fix(attachments): chunk reparsed embedding sources
seonghobae Sep 1, 2026
41ae6a2
fix(db): skip absent legacy email read-state table
seonghobae Sep 1, 2026
a4e0119
fix(ci): treat draft governance as waiting
seonghobae Sep 1, 2026
bd4b5ae
Merge remote-tracking branch 'refs/remotes/origin/claude/noema-contex…
seonghobae Sep 1, 2026
86074f6
test(attachments): skip the persisted-reparse postgres smoke cleanly …
claude Sep 1, 2026
4b4b1cb
Merge remote-tracking branch into HEAD
claude Sep 1, 2026
51245f7
test: fail reparse smoke on postgres defects
seonghobae Sep 1, 2026
db97962
fix(ci): wire repo-root governance contract tests into CI; fix 2 brok…
claude Sep 1, 2026
de11149
fix(db): make 0011_email_read_state's legacy-table guard offline-safe
claude Sep 1, 2026
3cbbba8
merge: refresh attachment reparse stack base
seonghobae Sep 1, 2026
3a2246d
Merge remote-tracking branch 'origin/claude/attachment-reparse-conten…
seonghobae Sep 1, 2026
ede7f4b
fix(ci): parse app-ci.yml as YAML in the CI-wiring regression test; s…
claude Sep 1, 2026
87ef2e5
fix(db): defer 0011's legacy-table check to SQL, not Python
claude Sep 1, 2026
d78655a
Merge remote-tracking branch into HEAD
claude Sep 1, 2026
8e47575
fix(ci): stop the root governance test step from crashing under PYTHO…
claude Sep 1, 2026
09a2443
fix(db): resolve 0011's legacy-table check through search_path, not r…
claude Sep 1, 2026
c249096
docs(db): document 0011's op.execute as a deliberate structured-ops e…
claude Sep 1, 2026
26e685e
merge: refresh reparse stack and narrow postgres skip
seonghobae Sep 1, 2026
d244ccc
fix(attachments): resolve reparse embedding source and migration down…
claude Sep 1, 2026
f316b2d
merge: bring in base-branch CI-wiring fixes merged onto this branch a…
claude Sep 1, 2026
212acb9
fix(ci): add repo-root pytest.ini to stop the root-tests step crashing
claude Sep 1, 2026
f3af149
merge: bring in base-branch changes to resolve mergeable_state DIRTY
claude Sep 1, 2026
6294b8b
fix(migrations): suppress bandit B608 false positive on 0011 DDL cons…
claude Sep 1, 2026
0345eda
test(alembic): narrow the connectivity-probe exception handler in the…
claude Sep 1, 2026
5cb5e49
fix(noema-agent): route LLM calls through contextual-orchestrator, no…
claude Sep 2, 2026
ba1b9cc
docs(noema-agent): correct 'two separate agents, share only a name' f…
claude Sep 2, 2026
34c71d2
fix(newsdom-worker,attachment-reparse-worker): stop a stuck row from …
claude Sep 2, 2026
66f4f0f
docs(noema-agent): stop citing an ADR file that doesn't exist on this…
claude Sep 2, 2026
836c274
fix(newsdom-worker,tenant-config): wire the Noema gateway config and …
claude Sep 2, 2026
b8bccf7
fix(newsdom-worker,attachment-reparse-worker): rediscover rows revert…
claude Sep 2, 2026
cdcf2da
Merge remote-tracking branch 'origin/claude/noema-contextualwisdomlab…
claude Sep 2, 2026
d7e5d2d
fix(test): add missing refresh() to _LiveReparsePendingSession fake
claude Sep 2, 2026
ff8807a
fix(attachments): index reparsed attachment content into the content …
seonghobae Sep 2, 2026
b32954d
fix(migrations): suppress Semgrep false positive on 0011_email_read_s…
seonghobae Sep 3, 2026
7ce6592
fix(tasks): preserve scheduler lease across transactions
seonghobae Sep 5, 2026
1709ebb
test(tasks): preserve database import boundary
seonghobae Sep 5, 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
19 changes: 15 additions & 4 deletions .github/workflows/app-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: Application CI

on:
pull_request:
branches:
- develop
- master
- "release/**"
push:
branches:
- develop
Expand Down Expand Up @@ -76,6 +72,21 @@ jobs:
exit 1
fi

- name: Run repository-root governance contract tests
# tests/ (repo root) holds workflow/YAML contract tests, e.g.
# test_stacked_pr_workflow_contract.py. The backend job's own pytest
# invocation above runs from backend/ and never collects this
# directory, so it needs its own explicit step. Mirrors that step's
# own log scan: a warning-class message pytest prints without
# actually failing the run must not be accepted as clean evidence.
run: |
set -o pipefail
python -m pytest -q tests 2>&1 | tee root_pytest_output.log
if grep -qiE 'timeout|fatal|warn|denied' root_pytest_output.log; then
echo "::error::Root governance contract tests produced Timeout, Fatal, Warn, or Denied outputs"
exit 1
fi

frontend:
name: frontend
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
workflow_dispatch:

permissions:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ name: Dependency Review

on:
pull_request:
branches:
- develop
- master
- "release/**"
workflow_dispatch:

permissions:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ on:
tags:
- "v*"
pull_request:
branches:
- develop
- master
- "release/**"

permissions:
contents: read
Expand Down
826 changes: 826 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions backend/alembic/versions/0001_initial_control_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sqlalchemy import text

from db.models import Base
from scripts.bootstrap_db import schema_backfill_sql
from scripts.bootstrap_db import execute_schema_backfill

revision = "0001_initial_control_plane"
down_revision = None
Expand All @@ -19,8 +19,7 @@ def upgrade() -> None:
connection = op.get_bind()
connection.execute(text("CREATE EXTENSION IF NOT EXISTS vector"))
Comment thread
seonghobae marked this conversation as resolved.
Base.metadata.create_all(connection)
for statement in schema_backfill_sql():
connection.execute(statement)
execute_schema_backfill(connection)
Comment thread
coderabbitai[bot] marked this conversation as resolved.


def downgrade() -> None:
Expand Down
109 changes: 98 additions & 11 deletions backend/alembic/versions/0011_email_read_state.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,116 @@
"""Add is_read to emails (IMAP \\Seen read state).

Existing rows default to read so historical/file imports do not surface as unread.

Deliberate exception to this repo's "Alembic migrations use structured
operations (``op.create_index``, ...), never ``sa.text(f"...")`` DDL" rule
(``AGENTS.md``/``CLAUDE.md``): ``upgrade()``/``downgrade()`` below use
``op.execute()`` with the module-level ``_UPGRADE_SQL``/``_DOWNGRADE_SQL``
constants instead of a structured ``op.*`` call. That rule's actual target is
DDL built from interpolated identifier strings (an injection-safety concern);
these constants interpolate only ``_IS_READ_PROVENANCE_MARKER``, a fixed
module-level literal, never an identifier or a value built from a variable,
external input, or runtime state -- the same safety property a structured
call would have. The reason a structured call isn't used is different: this
migration's behavior must be conditional on whether the legacy ``emails``
table exists, evaluated at apply time (see the comment on ``_UPGRADE_SQL``
below for why that check cannot live in Python), and no structured Alembic
operation expresses "run this DDL only if a runtime condition holds" -- a
``DO $$ ... $$`` block is the correct primitive for that, not a workaround
for one.
"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "0011_email_read_state"
down_revision = "0009_project_graph_projection"
branch_labels = None
depends_on = None

# Fresh installations materialize the current ``email_records`` model in the
# 0001 baseline, including ``is_read``. This historical side branch only
# applies to databases that still carry its legacy ``emails`` table.
#
# The condition has to be evaluated in SQL, not Python: offline SQL
# generation (``alembic upgrade --sql``, a real flag ``scripts/migrate_db.py``
# exposes) has no live connection to introspect with and no specific target
# database to ask "does this legacy table exist" at generation time either --
# the same static script is meant to later be applied by a DBA against
# whichever database they choose, fresh-install or legacy. A Python-side
# check (``sa.inspect(op.get_bind())``) can only ever answer that question
# for one hypothetical target chosen at generation time, so it is wrong for
# the other: skip unconditionally and the column silently never gets added
# for a legacy database that applies the generated script (while
# ``alembic_version`` still advances, permanently hiding the gap); inspect
# online and bake in one fixed answer and the same script fails outright
# against the other kind of target. A ``DO $$ ... $$`` block defers the
# check to apply time instead, so the one generated script is correct
# against either kind of target, online or offline-then-applied-later alike.
#
# ``to_regclass('emails')`` (not ``information_schema.tables`` by bare
# ``table_name``) deliberately: the unqualified ``ALTER TABLE emails`` below
# resolves through the connection's ``search_path``, and ``to_regclass``
# resolves an unqualified name exactly the same way, returning NULL if it
# doesn't. ``information_schema.tables`` filtered only by ``table_name``
# ignores ``search_path`` entirely and matches a same-named table in *any*
# schema the connecting role can see -- on a deployment with more than one
# accessible schema, that could find an unrelated ``emails`` table outside
# the search path while the unqualified ``ALTER TABLE emails`` targets a
# different (or no) table, passing the guard for the wrong relation or
# aborting the migration outright. Resolving both the check and the DDL
# through the same name lookup makes that mismatch structurally impossible.
#
# ``COMMENT ON COLUMN emails.is_read`` tags the column with a provenance
# marker (``_IS_READ_PROVENANCE_MARKER``) the moment upgrade() actually adds
# it. downgrade() only drops the column when that exact marker is present
# (CodeRabbit, naruon#1501): an ``emails.is_read`` column that already
# existed before this revision ran -- from some other, unrelated origin --
# would upgrade()'s ``NOT EXISTS`` guard correctly leave alone, but an
# unconditional ``DROP COLUMN IF EXISTS`` on downgrade would still destroy it
# and its data, since a downgrade has no other way to tell "I added this"
# apart from "this happens to be present". Checking the marker via
# ``col_description`` makes downgrade drop only what this exact revision's
# upgrade created.
_IS_READ_PROVENANCE_MARKER = "0011_email_read_state:added"
_UPGRADE_SQL = f"""
DO $$
BEGIN
IF to_regclass('emails') IS NOT NULL AND NOT EXISTS (
SELECT 1 FROM pg_attribute
WHERE attrelid = to_regclass('emails')
AND attname = 'is_read'
AND NOT attisdropped
) THEN
ALTER TABLE emails ADD COLUMN is_read boolean NOT NULL DEFAULT true;
COMMENT ON COLUMN emails.is_read IS '{_IS_READ_PROVENANCE_MARKER}';
END IF;
END $$;
""" # nosec B608

_DOWNGRADE_SQL = f"""
DO $$
BEGIN
IF to_regclass('emails') IS NOT NULL AND EXISTS (
SELECT 1 FROM pg_attribute
WHERE attrelid = to_regclass('emails')
AND attname = 'is_read'
AND NOT attisdropped
) AND col_description(to_regclass('emails'), (
SELECT attnum FROM pg_attribute
WHERE attrelid = to_regclass('emails')
AND attname = 'is_read'
AND NOT attisdropped
)) = '{_IS_READ_PROVENANCE_MARKER}' THEN
ALTER TABLE emails DROP COLUMN IF EXISTS is_read;
END IF;
END $$;
""" # nosec B608

Comment thread
seonghobae marked this conversation as resolved.

def upgrade() -> None:
op.add_column(
"emails",
sa.Column(
"is_read",
sa.Boolean(),
nullable=False,
server_default=sa.text("true"),
),
)
op.execute(_UPGRADE_SQL)
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed


def downgrade() -> None:
op.drop_column("emails", "is_read")
op.execute(_DOWNGRADE_SQL)
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
109 changes: 109 additions & 0 deletions backend/alembic/versions/0018_calendar_conflict_judgments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"""add calendar conflict judgments and corrections

Revision ID: 0018_calendar_conflict_judgments
Revises: 0017_merge_newsdom_carddav_heads
Create Date: 2026-08-30 00:00:00.000000
"""

from alembic import op
import sqlalchemy as sa

revision = "0018_calendar_conflict_judgments"
down_revision = "0017_merge_newsdom_carddav_heads"

_JUDGMENT_TABLE = "calendar_conflict_judgments"
_CORRECTION_TABLE = "calendar_conflict_corrections"


def upgrade() -> None:
connection = op.get_bind()
inspector = sa.inspect(connection)

if not inspector.has_table(_JUDGMENT_TABLE):
op.create_table(
Comment thread
seonghobae marked this conversation as resolved.
_JUDGMENT_TABLE,
sa.Column("calendar_conflict_judgment_id", sa.Integer(), nullable=False),
sa.Column("judgment_uid", sa.String(length=96), nullable=False),
sa.Column("user_id", sa.String(), nullable=False),
sa.Column("organization_id", sa.String(), nullable=True),
sa.Column("workspace_id", sa.String(), nullable=False),
sa.Column("proposed_commitment_id", sa.String(length=256), nullable=False),
sa.Column("source_thread_id", sa.String(), nullable=True),
sa.Column("source_message_id", sa.String(), nullable=True),
sa.Column("decision_code", sa.String(length=32), nullable=False),
sa.Column("reason_code", sa.String(length=64), nullable=False),
sa.Column("recommended_action", sa.Text(), nullable=False),
sa.Column("policy_version", sa.String(length=32), nullable=False),
sa.Column("conflicts_json", sa.JSON(), nullable=False),
sa.Column("status_code", sa.String(length=32), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("calendar_conflict_judgment_id"),
sa.UniqueConstraint(
"judgment_uid", name="uq_calendar_conflict_judgments_uid"
),
)

if not inspector.has_table(_CORRECTION_TABLE):
op.create_table(
_CORRECTION_TABLE,
sa.Column("calendar_conflict_correction_id", sa.Integer(), nullable=False),
sa.Column("correction_uid", sa.String(length=96), nullable=False),
sa.Column("calendar_conflict_judgment_id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.String(), nullable=False),
sa.Column("organization_id", sa.String(), nullable=True),
sa.Column("workspace_id", sa.String(), nullable=False),
sa.Column("actor_user_id", sa.String(), nullable=False),
sa.Column("correction_action", sa.String(length=64), nullable=False),
sa.Column("before_json", sa.JSON(), nullable=False),
sa.Column("after_json", sa.JSON(), nullable=False),
sa.Column("rationale", sa.Text(), nullable=True),
Comment thread
seonghobae marked this conversation as resolved.
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.ForeignKeyConstraint(
["calendar_conflict_judgment_id"],
["calendar_conflict_judgments.calendar_conflict_judgment_id"],
),
sa.PrimaryKeyConstraint("calendar_conflict_correction_id"),
sa.UniqueConstraint(
"correction_uid", name="uq_calendar_conflict_corrections_uid"
),
)

for table_name, indexes in _calendar_conflict_indexes().items():
for index_name, column_names in indexes:
op.create_index(
index_name,
table_name,
column_names,
if_not_exists=True,
)


def downgrade() -> None:
connection = op.get_bind()
inspector = sa.inspect(connection)

for table_name in (_CORRECTION_TABLE, _JUDGMENT_TABLE):
if inspector.has_table(table_name):
for index_name, _column_names in reversed(
_calendar_conflict_indexes()[table_name]
):
op.drop_index(index_name, table_name=table_name, if_exists=True)
op.drop_table(table_name)


def _calendar_conflict_indexes() -> dict[str, list[tuple[str, list[str]]]]:
return {
_JUDGMENT_TABLE: [
(
"ix_calendar_conflict_judgments_scope_thread",
["user_id", "organization_id", "workspace_id", "source_thread_id"],
),
],
_CORRECTION_TABLE: [
(
"ix_calendar_conflict_corrections_judgment",
["calendar_conflict_judgment_id"],
),
],
}
Loading
Loading