# NightWeaving

One night's weaving of a loom: consolidation that runs in the background once its conversations go quiet. It records what it did, the dream log it wrote, and the tokens it spent.

**Kind:** an object, used in responses.

## Fields

Every field is present in a response; empty ones are `null`.

| Field | Type | Description |
|---|---|---|
| `loomId` | `uuid` | The loom that was woven. |
| `status` | [`NightWeavingStatus`](https://docs.maitento.com/reference/types/night-weaving-status.md) | Whether it is still running, completed or failed. |
| `dateCompleted` | `datetime \| null` | When it finished (UTC), whether it completed or failed. Null while it is running. |
| `sourceInteractionProcessId` | `uuid \| null` | The interaction run whose model credentials the weaving used, and to which its usage is attributed. |
| `sessionIds` | `uuid[]` | The sessions (`LoomSession`) it consolidated. |
| `counts` | [`NightWeavingCounts`](https://docs.maitento.com/reference/types/night-weaving-counts.md) | What it did, counted. |
| `dreamLog` | `string \| null` | The weaver's private journal entry for the night, also woven as a reflection thread. |
| `dreamLogThreadId` | `uuid \| null` | The reflection thread the dream log was woven as. Null when none was written. |
| `error` | `string \| null` | What went wrong, when anything did. Null otherwise. |
| `tokenUsage` | [`InteractionProcessTokenUsage`](https://docs.maitento.com/reference/types/interaction-process-token-usage.md)`[]` | The tokens the night spent, one entry per model call. |
| `tenantId` | `uuid` | The id of the tenant it belongs to. |
| `id` | `uuid` | The unique id. Use it in `by-id` routes and wherever another object refers to this one. |
| `dateCreated` | `datetime` | When it was created, in UTC. |
| `dateUpdated` | `datetime` | When it was last changed, in UTC. |

## Example

```json
{
  "loomId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "status": "Running",
  "dateCompleted": "2026-10-26T12:00:00.0000000Z",
  "sourceInteractionProcessId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "sessionIds": [
    "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f"
  ],
  "counts": {
    "sessionsConsolidated": 0,
    "episodesWoven": 0,
    "threadsWoven": 0,
    "threadsTightened": 0,
    "threadsFrayed": 0,
    "threadsMerged": 0,
    "threadsSuperseded": 0,
    "dreamLogsRetired": 0,
    "intentionsLapsed": 0,
    "tensionsFound": 0,
    "themesWoven": 0,
    "themesRefined": 0,
    "panelsWoven": 0,
    "patternsRefined": 0,
    "threadsMadeOwn": 0,
    "companionsLinked": 0,
    "threadsEmbedded": 0
  },
  "dreamLog": "...",
  "dreamLogThreadId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "error": "...",
  "tokenUsage": [
    {
      "turnId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "date": "2026-10-26T12:00:00.0000000Z",
      "provider": "...",
      "model": "...",
      "agentName": "...",
      "agentId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "usages": [],
      "finished": false,
      "credentialId": "...",
      "isOwnLicense": false,
      "tier": "..."
    }
  ],
  "tenantId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "dateCreated": "2026-10-26T12:00:00.0000000Z",
  "dateUpdated": "2026-10-26T12:00:00.0000000Z"
}
```

## Where it's used

- [`looms.nightWeavingsSince`](https://docs.maitento.com/reference/api/looms.md) (`GET /looms/night-weavings`)
- [`looms.nightWeavings`](https://docs.maitento.com/reference/api/looms.md) (`GET /looms/by-id/{id}/night-weavings`)
- Inside [`LoomInspection`](https://docs.maitento.com/reference/types/loom-inspection.md)
