# Schedule earliest finish

`schedule-earliest-finish` · version 1.0.0 · Graphs & scheduling · free, no key needed

Compute CPM earliest start and earliest finish times for a DAG with node durations, plus the project makespan.

**Use when you need to: schedule earliest finish · cpm earliest start and finish · earliest finish times for dag tasks.**

## Supported

- schedule earliest finish
- cpm earliest start and finish
- earliest finish times for dag tasks

## Not supported

- calendar dates
- working hours
- edge lags other than finish-to-start 0
- latest start slack and critical path

## Behavior

- Input is a directed simple graph plus durations whose own keys are exactly the node ids and whose values are canonical non-negative integer strings of at most 18 digits.
- Edge from→to means from must finish before to may start (finish-to-start lag 0).
- The graph must be a DAG; a cycle including a self-loop throws invalid_input with a message containing cycle.
- Earliest start of a node is 0 when it has no predecessors, otherwise the maximum earliest finish among its predecessors.
- Earliest finish of a node is its earliest start plus its duration.
- Output nodes lists every node in declared nodes-array order with id, earliest_start, and earliest_finish as canonical integer strings.
- makespan is the maximum earliest finish, or "0" when there are no nodes.
- Times that exceed 18 digits throw invalid_input with a digit-limit message.

## Input

- `nodes` (array of string, required): max items 2000; each min length 1; each max length 256
- `edges` (array of object, required): max items 10000
- `durations` (object, required)

## Output

- `nodes` (array of object, required): max items 2000
- `makespan` (string, required): max length 18; pattern `^(0|[1-9][0-9]*)$`

## Limits

- max nodes: 2000
- max edges: 10000
- max node id bytes: 256
- max duration digits: 18

## Example

Request input:

```json
{
  "nodes": [
    "design",
    "code",
    "review",
    "test",
    "ship"
  ],
  "edges": [
    {
      "from": "design",
      "to": "code"
    },
    {
      "from": "design",
      "to": "review"
    },
    {
      "from": "code",
      "to": "test"
    },
    {
      "from": "review",
      "to": "test"
    },
    {
      "from": "test",
      "to": "ship"
    }
  ],
  "durations": {
    "design": "3",
    "code": "5",
    "review": "2",
    "test": "4",
    "ship": "1"
  }
}
```

Response:

```json
{
  "result": {
    "nodes": [
      {
        "id": "design",
        "earliest_start": "0",
        "earliest_finish": "3"
      },
      {
        "id": "code",
        "earliest_start": "3",
        "earliest_finish": "8"
      },
      {
        "id": "review",
        "earliest_start": "3",
        "earliest_finish": "5"
      },
      {
        "id": "test",
        "earliest_start": "8",
        "earliest_finish": "12"
      },
      {
        "id": "ship",
        "earliest_start": "12",
        "earliest_finish": "13"
      }
    ],
    "makespan": "13"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "schedule-earliest-finish",
  "version": "1.0.0",
  "input": {
    "nodes": [
      "design",
      "code",
      "review",
      "test",
      "ship"
    ],
    "edges": [
      {
        "from": "design",
        "to": "code"
      },
      {
        "from": "design",
        "to": "review"
      },
      {
        "from": "code",
        "to": "test"
      },
      {
        "from": "review",
        "to": "test"
      },
      {
        "from": "test",
        "to": "ship"
      }
    ],
    "durations": {
      "design": "3",
      "code": "5",
      "review": "2",
      "test": "4",
      "ship": "1"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/schedule-earliest-finish/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"nodes":["design","code","review","test","ship"],"edges":[{"from":"design","to":"code"},{"from":"design","to":"review"},{"from":"code","to":"test"},{"from":"review","to":"test"},{"from":"test","to":"ship"}],"durations":{"design":"3","code":"5","review":"2","test":"4","ship":"1"}}'
```

The machine-readable contract is at [/v1/tools/schedule-earliest-finish/versions/1.0.0](/v1/tools/schedule-earliest-finish/versions/1.0.0).

### CLI

```sh
node cli.mjs run schedule-earliest-finish 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Schedule critical path](/tools/schedule-critical-path): Compute CPM zero-slack critical nodes and tight edges on a DAG, plus one representative critical path.
- [Schedule ASAP layers](/tools/schedule-asap-layers): Partition a DAG into ASAP topological generations: each layer is the nodes that become ready together.
- [Schedule ready nodes](/tools/schedule-ready-nodes): List DAG nodes that can start because they are not completed and every predecessor is completed.
- [Graph DAG longest path](/tools/graph-dag-longest-path): Return a longest node-weighted path in a DAG, where path weight is the sum of node durations.
- [Graph topological sort](/tools/graph-topological-sort): Return a Kahn topological order of a directed acyclic graph, breaking ready-set ties by declared node index.
- [Graph transitive reduction](/tools/graph-transitive-reduction): Compute the transitive reduction of a DAG: keep an edge u→v iff the original graph has no directed path from u to v of length at least 2.
