Align Coconstructive¶
Align CoConstructive — mvp.align_coconstructive
Cluster: Safety & Alignment | Type: component | MCP Tools: None
Overview¶
Co-constructive dialogue alignment analyser (advisory tier): it always computes a deterministic heuristic floor across four axes — turn balance, inter-turn coherence, goal alignment, and response depth — combined into a single quality score, then a default-on advisory LLM dialogue judge may refine the scores when enabled and a real backend is reachable (degrading to the floor when suppressed via G6_DISABLE_LLM / offline / opt-out or on judge failure; the judge never relabels score_provenance). Semantic similarity between turns uses mvp.align_verbsamp.semantic_engine (sentence-transformers when available, TF-IDF/Jaccard fallback). The block also produces a ranked list of improvement suggestions and a refined goal statement based on observed content.
MVP heuristic, not a validated alignment measure
Use this component as a lightweight dialogue coaching and review aid. Its scores are heuristic signals, not a validated measure of safety, alignment, educational quality, or regulatory readiness. For production decisions, treat the output as one input to human review and pair it with explicit task-specific checks, tests, or evaluation criteria.
When to use:
- Auditing a multi-turn conversation for alignment with a stated goal before logging it as a training example
- Generating actionable improvement hints for a dialogue agent mid-session
- Evaluating whether human-AI co-construction is achieving shared understanding
Do not use as the sole basis for:
- Approving high-stakes user advice or regulated-domain outputs
- Claiming that a system is aligned, safe, or pedagogically validated
- Replacing human review for launch, deployment, billing, clinical, legal, or financial decisions
Example:
from mvp.align_coconstructive import AlignCoConstructiveBlock, CoConstructiveInput, DialogueTurn
block = AlignCoConstructiveBlock(name="coconst")
result = block.infer(CoConstructiveInput(
messages=[DialogueTurn(role="user", content="Explain gravity."),
DialogueTurn(role="assistant", content="Gravity is a fundamental force.")],
goal="Explain gravity clearly",
))
# result.value.alignment_score → float; result.value.suggestions → list of strings
Works well with: align_verbsamp, align_prompt_library, align_evals
Current Limitations¶
- The core analyser's deterministic FLOOR is heuristic (turn balance, semantic overlap, response depth, goal similarity); a default-on advisory LLM judge may refine the scores when a real backend is reachable, but neither the floor nor the judge understands intent, truthfulness, harm, or policy compliance on its own, and the judge's output is not a validated/calibrated measure (score_provenance stays calibrated=False / expert_validated=False).
- MCP session operations add useful scaffolding, persistence, skill modelling, and anti-rubber-stamping checks, but some scoring paths are intentionally simple for MVP use and should be interpreted as coaching signals rather than precise metrics. Tier 1 reports
dialogue_qualityas a float score; Tier 2 MCP reportsdialogue_qualityas a string label such asbalanced,ai_dominated,high,medium, orlow. - Capability discovery is read-only:
AlignCoConstructiveBlock.describe_backend()andcoconstructive_describereport backend name, agentic availability, tier split, scoring provenance, envelope defaults, and redacted SQLite health without reading or printing secret values. - Suggestions can be generic when the conversation is short or underspecified. Add concrete
goalandevaluation_criteriavalues for more useful feedback. - For launch and pilot workflows, pair this component with domain tests, explicit acceptance criteria, and human review before presenting results as reliable production evidence.
Public API¶
AlignCoConstructiveBlock(AIBlock[CoConstructiveInput, CoConstructiveOutput, None])¶
Co-constructive dialogue alignment analyser (advisory tier).
| Field | Type | Default |
|---|---|---|
name | str | 'align_coconstructive' |
resource_bounds | ResourceBounds \| None | None |
usage | ResourceUsage | field(default_factory=ResourceUsage) |
planner | Any \| None | None |
Methods:
describe_backend() -> dict[str, Any]¶
infer(data: CoConstructiveInput) -> Result[CoConstructiveOutput]¶
verify_dialogue_quality(messages: list[DialogueTurn], goal: str = '', min_quality: float = 0.3, min_turns: int = 2) -> Result[dict[str, Any]]¶
Verify dialogue meets minimum co-constructive quality thresholds.
DialogueTurn(BaseModel)¶
| Field | Type | Default |
|---|---|---|
role | str | required |
content | str | required |
CoConstructiveInput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
messages | list[DialogueTurn] | required |
goal | str | '' |
evaluation_criteria | list[str] | Field(default_factory=list) |
n_refinements | int | 3 |
Methods:
messages_not_empty(v: list[DialogueTurn]) -> list[DialogueTurn]¶
refinements_positive(v: int) -> int¶
CoConstructiveOutput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
alignment_score | float | required |
dialogue_quality | float | required |
suggestions | list[str] | required |
refined_goal | str | required |
issues | list[str] | required |
n_turns | int | required |
n_user_turns | int | required |
n_assistant_turns | int | required |
degraded | bool | False |
degradation_reason | str | '' |
completion_state | Literal['verified', 'qualified-draft', 'blocked-escalated'] | 'qualified-draft' |
warning_card | dict[str, Any] \| None | None |
score_provenance | dict[str, Any] | Field(default_factory=lambda: {'similarity_backend': 'unknown', 'calibrated': False, 'expert_validated': False}) |
agentic_evidence | dict[str, Any] | Field(default_factory=dict) |
AlignCoConstructiveMCPBlock(AIBlock[MCPCoConstructiveInput, MCPCoConstructiveOutput, dict])¶
| Field | Type | Default |
|---|---|---|
name | str | 'align_coconstructive_mcp' |
state | dict \| None | None |
db_path | str | ':memory:' |
resource_bounds | ResourceBounds \| None | None |
usage | ResourceUsage | field(default_factory=ResourceUsage) |
Methods:
infer(inp: MCPCoConstructiveInput) -> Result[MCPCoConstructiveOutput]¶
MCPCoConstructiveInput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
op | str | required |
session_id | str \| None | None |
goal | str \| None | None |
messages | list[dict[str, Any]] | Field(default_factory=list) |
turn_content | str \| None | None |
turn_role | str \| None | None |
skill_domain | str \| None | None |
skill_level | str \| None | None |
evidence | str \| None | None |
scaffold_config | dict[str, Any] | Field(default_factory=dict) |
decision_id | str \| None | None |
override_reason | str \| None | None |
reason | str \| None | None |
evaluation_criteria | list[str] | Field(default_factory=list) |
n_refinements | int | 1 |
limit | int | 20 |
Methods:
op_not_empty(v: str) -> str¶
refinements_positive(v: int) -> int¶
limit_positive(v: int) -> int¶
MCPCoConstructiveOutput(BaseModel)¶
| Field | Type | Default |
|---|---|---|
op | str | required |
success | bool | required |
session_id | str \| None | None |
sessions | list[dict[str, Any]] | Field(default_factory=list) |
turns | list[dict[str, Any]] | Field(default_factory=list) |
zpd_phase | str \| None | None |
scaffold_level | str \| None | None |
scaffold_config | dict[str, Any] | Field(default_factory=dict) |
bias_detected | bool | False |
consecutive_agreements | int | 0 |
skill_model | dict[str, Any] | Field(default_factory=dict) |
suggestions | list[str] | Field(default_factory=list) |
refined_goal | str \| None | None |
alignment_score | float | 0.0 |
dialogue_quality | str | '' |
metacognition_prompts | list[str] | Field(default_factory=list) |
reflection_questions | list[str] | Field(default_factory=list) |
overrides | list[dict[str, Any]] | Field(default_factory=list) |
calibration | dict[str, Any] | Field(default_factory=dict) |
review | dict[str, Any] | Field(default_factory=dict) |
stats | dict[str, Any] | Field(default_factory=dict) |
count | int | 0 |
message | str | '' |
error | str | '' |
degraded | bool | False |
degradation_reason | str | '' |
completion_state | Literal['verified', 'qualified-draft', 'blocked-escalated'] | 'qualified-draft' |
warning_card | dict[str, Any] \| None | None |
capabilities | dict[str, Any] | Field(default_factory=dict) |
score_provenance | dict[str, Any] | Field(default_factory=lambda: {'similarity_backend': 'unknown', 'calibrated': False, 'expert_validated': False}) |
Methods: