logo
  • Docs
  • API Reference
    Introduction
    What is Lix?
    Getting Started
    Comparison to Git
    Lix for AI Agents
    Essentials
    How Lix Works
    Querying Changes
    Data Model
    Plugins
    Persistence
    Guides
    Versions (Branching)
    History
    Diffs
    Attribution (Blame)
    Change Proposals
    Validation Rules
    Undo/Redo
    Restore
    Conversations
    Labels
    Key-Value Store
    Environment API
    Testing
    React Integration
    Logging & Debugging
    Deterministic Mode
    Metadata
    Writer Key
    Architecture
    Lix as File Format
    Previous pageDiffsNext pageChange Proposals

    #Attribution (Blame)

    Attribution enables seeing who made changes and when, providing transparency and accountability in collaborative environments. Lix surfaces attribution for every modification.

    Blame

    #Examples

    #Find out who authored a change

    When a user selects an element in your application (like a table cell, paragraph, or form field), you can query the attribution for that entity.

    import { openLix } from "@lix-js/sdk";
    // Assume that `selectedEntity` is the entity the user has selected in your application
    const selectedEntity = {
      entity_id: "example-entity",
      schema_key: "json_property",
      file_id: "/example.json",
    };
    
    // For demonstration, we'll query an actual entity from the database
    const actualEntity = await lix.db
      .selectFrom("state")
      .selectAll()
      .limit(1)
      .executeTakeFirst();
    
    if (actualEntity) {
      // Query the change information for this entity
      console.log(
        `Entity ${actualEntity.entity_id} was last modified at ${actualEntity.updated_at}`,
      );
      console.log(`Change ID: ${actualEntity.change_id}`);
      console.log(`Entity type: ${actualEntity.schema_key}`);
    } else {
      console.log("No entities found in the database");
    }

    #File change attribution

    import { openLix } from "@lix-js/sdk";
    
    // Assume that `selectedEntity` is the entity the user has selected in your application
    const selectedEntity = {
      entity_id: "example-entity",
      schema_key: "json_property",
      file_id: "/example.json",
    };
    
    // For demonstration, we'll query an actual entity from the database
    const actualEntity = await lix.db
      .selectFrom("state")
      .selectAll()
      .limit(1)
      .executeTakeFirst();
    
    if (actualEntity) {
      // Query the change information for this entity
      console.log(
        `Entity ${actualEntity.entity_id} was last modified at ${actualEntity.updated_at}`,
      );
      console.log(`Change ID: ${actualEntity.change_id}`);
      console.log(`Entity type: ${actualEntity.schema_key}`);
    } else {
      console.log("No entities found in the database");
    }
    const fileEntity = await lix.db
      .selectFrom("file")
      .where("path", "=", "/example.json")
      .selectAll()
      .executeTakeFirst();
    
    if (fileEntity) {
      console.log(
        `File ${fileEntity.path} was last modified at ${fileEntity.lixcol_updated_at}`,
      );
      console.log(`File change ID: ${fileEntity.lixcol_change_id}`);
    } else {
      console.log(
        "File /example.json not found - run getting-started example first",
      );
    }