Skip to contents

Writes outputs/<run>/live/clustering_pass_<N>.json with the AI's partition proposal for pass N: the input leaves, the proposed cluster assignments, and the AI's rationale per cluster + overall. Called from generate_themes_multipass() in R/theme_algorithm_v2.R after every clustering call.

Usage

live_record_clustering_pass(tracker, pass_n, leaves, proposal, codes = NULL)

Arguments

tracker

A LiveTracker or NULL.

pass_n

Integer; the pass number (1-based).

leaves

The list of leaves shown to the AI at this pass (each leaf record carries leaf_id, leaf_type, and member_code_keys).

proposal

The AI's proposal record returned by ai_propose_clustering(): verdict, cluster_assignments, overall_rationale.

codes

Optional list of code records (the original codebook extraction); used to enrich the snapshot with code names per leaf.

Value

The (possibly updated) tracker, invisibly.

Details

Honors C-tenet 3 (live tracking artifacts during processing): a researcher can cat outputs/<run>/live/clustering_pass_2.json mid-run and see exactly what pass 2 did.

Atomic rewrite (write-temp + rename) so a researcher cat-ing the file always sees a coherent snapshot. Safe to call with tracker = NULL (no-op).