Skip to content

docs: Add label-as-first-class-citizen pipeline design and specifications - #2

Open
jcyeom wants to merge 3 commits into
masterfrom
claude/focused-cray-tubi6k
Open

jcyeom wants to merge 3 commits into
masterfrom
claude/focused-cray-tubi6k

Conversation

@jcyeom

@jcyeom jcyeom commented Sep 18, 2026

Copy link
Copy Markdown
Owner

What type of PR is this?

/kind documentation

What this PR does / why we need it

This PR adds comprehensive design documentation and implementation specifications for a label-as-first-class-citizen data pipeline system. The documentation includes:

  1. Revised Research Paper (00-paper-revised.md): Updated version of the original paper incorporating implementation feedback, with corrections to key claims about LLM reproducibility and clarifications on the replay vs. reproduce distinction.

  2. Implementation Design Specification (02-design.md): Complete technical design covering:

    • Architecture and system boundaries
    • 4-layer storage strategy (Bronze/Silver/Gold/Meta) with immutability principles
    • Detailed schema definitions for L0-L3 labels with metadata
    • Label Fusion Engine algorithm with calibration and correlation adjustment
    • Replay mechanism for non-deterministic labelers
    • Ontology versioning and migration strategy
    • Drift detection and monitoring metrics
  3. Use Cases and Scenarios (03-usecases.md): 16 documented use cases with detailed flows covering:

    • Labeler batch execution and failure recovery
    • Consensus generation and review routing
    • Anchor set extraction and calibration
    • Dataset manifest generation and reproducibility
  4. Backend Design Specification (04-backend-design.md): Detailed control plane design including:

    • OLTP/OLAP separation (Postgres for control, Delta/Iceberg for data)
    • State machines for runs and review tasks with lease management
    • Idempotency and concurrency models
    • Job orchestration and error handling
    • Authorization and audit logging
  5. DDL Specifications: Complete SQL schemas for:

    • Bronze layer (L0 raw responses)
    • Silver layer (L1 candidate labels with rationale separation)
    • Gold layer (L2 consensus and L3 verified labels)
    • Meta layer (labeler registry, fusion policies, calibration models, anchor sets, review queues, drift metrics, dataset manifests)
  6. Configuration Example (config/pipeline.example.yaml): Concrete example showing how to configure labelers, policies, and runtime parameters.

  7. Revision Notes (01-revision-notes.md): Detailed mapping of changes from initial paper to revised version, categorized by type (论证缺陷/스키마 누락/구조 보강/미해결).

Design Principles Implemented

The design enforces six core principles:

  • P1: L0/L1 immutability with append-only writes and versioned corrections
  • P2: Full reproducibility through input set and policy version tracking
  • P3: Explicit abstention vs. negative labels distinction
  • P4: Mandatory recording of excluded data in manifests
  • P5: Evaluation baselines from random anchor samples only
  • P6: Versioned configuration-based policies, not code-based

Key Technical Contributions

  1. Replay Mechanism: Preserves raw responses in Bronze layer to enable replay of parsing logic changes without re-invoking external APIs, addressing non-determinism in LLM labelers.

  2. Anchor-Based Evaluation: Enforces random sample allocation for review to prevent selection bias in labeler evaluation and drift detection.

  3. Leakage Prevention: Explicit separation of train/eval holdout purposes in L3 with deterministic hash-based assignment to prevent data leakage into training sets.

  4. Unified Schema: Single structured schema spanning rule/LLM/human labelers with support for abstention, multiple target types (whole/span/bbox/cell), and ontology versioning.

  5. Calibration Pipeline: Per-labeler confidence calibration using isotonic regression on anchor sets, with correlation-adjusted voting to handle model family dependencies.

Which issue(s) this PR fixes

This PR establishes the foundational design documentation for the label pipeline system. It is not tied to a specific issue but serves as the specification baseline for implementation.

Special notes for your reviewer

  • The design reflects implementation-driven refinement of the original paper, particularly around LLM reproducibility constraints (see A1 in revision notes)
  • All design decisions are traced to specific use

https://claude.ai/code/session_01VT1t6FEdipAhQbdU4HNYnP

Revise the weak-supervision label pipeline paper per an implementation
review, and add a design spec that code can be built from.

Paper fixes (8 substantive):
- Replace the "seed-fixed reproducibility" claim, which contradicted the
  cited run-to-run variance work, with replay from preserved raw responses
- Separate consensus policies from agreement metrics; Cohen's kappa is a
  dataset-level chance-corrected statistic, not a per-sample decision
  function, and is limited to two raters
- Add anchor-based monotonic calibration; rule/LLM/human confidences are
  not comparable on a shared scale
- Stop emitting NULL consensus labels for disagreements, which removed
  only hard samples from training and biased the set; keep a soft label
  and declare inclusion in the dataset manifest instead
- Introduce a random anchor set with a forced share of the review budget,
  so labeler accuracy and drift are not estimated from disagreement-only
  samples
- Split verified labels into train and eval_holdout purposes to stop
  leakage between labeler evaluation and training
- Identify drift cause from two signals (distribution shift plus anchor
  rescoring) instead of PSI alone
- Move the agreement field from the candidate to the consensus schema,
  removing a circular dependency in the append-only layer

Schema gaps closed: sample_id, label_task, target_ref, is_abstain,
ontology_ver, run_id, split value columns, cost/latency, per-component
LLM hashes, feature_snapshot_id, and consensus replay metadata.

Structural additions: an operational definition of first-class labels,
a four-tier mapping with raw responses in Bronze, labeler correlation
adjustment, a dataset manifest, canonical hashing rules, and an
evaluation plan that measures the value of retaining candidate labels.

Design spec covers architecture, table schemas with DDL, replay
procedure, fusion algorithm, calibration, review routing, drift
detection, idempotency, storage economics, governance, module layout
with interface contracts, test strategy, and an eight-stage roadmap.

Documentation only; no Python is added, so the boilerplate check and
test collection in this repository are unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VDpZfU6Xrs9HAgSQU46mWW
Derives a server-side design from the label pipeline design proposal by
first writing use cases and scenarios, then designing only what those
cases require.

03-usecases.md
- 16 use cases (UC-01..UC-16) with actors, triggers, and design refs
- Detailed main/alternate/exception flows for the 8 cases where backend
  contracts diverge
- 6 end-to-end scenarios (bootstrap, daily batch, drift, audit replay,
  labeler swap, parser change)
- 22 edge cases (EC-01..EC-22) the backend must answer
- Non-functional assumptions stated as assumptions, not constants

04-backend-design.md
- Backend review of the proposal: 11 decisions left open (G1..G11),
  each mapped to the section that closes it
- Control plane (Postgres) vs data plane (lake) split with rationale;
  7 control tables
- State machines for run and review task, including leases
- REST contracts for run, fusion, review platform, dataset, registry,
  drift/lineage/replay
- Idempotency keys, scope-key exclusive job locking, outbox for
  exactly-once lake writes
- Error catalog, RBAC with three-layer holdout isolation, metrics
- Case-to-mechanism traceability table and roadmap overlay on M1..M8
- Explicit non-goals to bound scope at the stated operating size

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VT1t6FEdipAhQbdU4HNYnP
Second pass over 03/04 against the design proposal and DDL. Eight
defects, three of them correctness bugs in the spec itself.

Leakage and bias (new G12-G14, EC-23-EC-25)
- Holdout-purpose L3 must not propagate to L2. Taking §12.4 literally
  ("L3 arrives, update to human_final") puts the evaluation baseline
  into the training labels and breaks the §4.5 leakage contract.
  Incremental fusion now reads v_l3_train only.
- Anchor review tasks are now blind: no candidates, no consensus in the
  lease response. Showing the consensus turns anchor L3 into a
  confirmation of L2, which is what calibration and labeler accuracy
  are measured against.
- holdout_pct must be fixed per task at creation. It is deterministic,
  but changing it reshuffles every past assignment.

Control plane bugs
- Lease SQL was invalid: Postgres rejects FOR UPDATE with window
  functions. Rewritten as per-route locked CTEs.
- Same-reviewer exclusion only covered the disagreement route, while
  double review lives on the anchor route.
- labeling_run natural key was globally unique, which permanently
  blocked the corrective re-runs P1 mandates. Now partial on active
  runs, with rerun_of/rerun_reason.
- review_task unique key covered completed rows, blocking re-review
  after republish. Now partial on open states.
- Shard resume by cursor loses failures scattered before the cursor;
  resume is the anti-join against L1 rows already loaded for the run.

Also: escalation creates a new task row instead of reverting state;
fusion lock scope moved to task level (migration touches two ontology
versions); per-job-type DB roles, since one worker process running all
job types under one account voids the holdout permission layer;
incremental fusion batched in a 5-minute window to stop l2_version
explosion; §14 collects the six changes that 02-design/DDL need; §N
references disambiguated between the two documents.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VT1t6FEdipAhQbdU4HNYnP
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.

2 participants