"""New sequential teaching correction and a deliberately inadequate repair control."""


def fixed_api(connection, tenant, label, request_id):
    """Enforce the retained selected-case promise before writing; not concurrency proof."""
    owner = connection.execute('SELECT tenant FROM documents WHERE id = 1').fetchone()[0]
    if owner != tenant:
        return {'status': 403, 'error': 'forbidden', 'request_id': request_id}
    connection.execute('UPDATE documents SET label = ? WHERE id = 1', (label,))
    connection.commit()
    return {'status': 200, 'label': label, 'request_id': request_id}


def reject_all_no_write(connection, tenant, label, request_id):
    """Seeded no-write repair candidate: safe denial cannot replace owner success."""
    return {'status': 403, 'error': 'forbidden', 'request_id': request_id}
