# The task lifecycle

Source: https://usecns.dev/lifecycle/

You do not need to install the whole system to follow this lifecycle. Start with a repository, a change you want to make, and your existing tests. Add one tool when it helps with a specific question.

**New here?** [Start with Axon, then layer on Soma](https://usecns.dev/get-started/). The worked examples cover a small JavaScript project without a model service, memory server or coding-agent integration.

## Fig. 2   Task lifecycle, five stages [Full architecture ↗](https://usecns.dev/architecture/)

1. 2.1

   ### Orient

   Read the task and the repository. Identify the behavior your change must preserve.

   [Cortex](https://usecns.dev/organ-cortex/)[Engram](https://usecns.dev/organ-engram/)[Soma](https://usecns.dev/organ-soma/)
2. 2.2

   ### Retrieve

   Find the relevant code and follow its callers with Axon. Recall prior decisions with Engram when available.

   [Thalamus](https://usecns.dev/organ-thalamus/)[Engram](https://usecns.dev/organ-engram/)[Axon](https://usecns.dev/organ-axon/)
3. 2.3

   ### Execute

   Make a small change and run the project's tests. Model-assisted work is optional.

   [Thalamus](https://usecns.dev/organ-thalamus/)
4. 2.4

   ### Closeout gate

   Inspect the delta and applicable Soma concerns. Distinguish passed checks from checks that could not run.

   [Thalamus](https://usecns.dev/organ-thalamus/)[Soma](https://usecns.dev/organ-soma/)[Axon](https://usecns.dev/organ-axon/)
5. 2.5

   ### Consolidate

   Commit the change and its tests, refresh maps, and retain useful lessons for the next task.

   [Engram](https://usecns.dev/organ-engram/)

## 1. Orient: what am I changing?

Read the task, identify the repository and understand the rule the change must preserve. In the [Axon walkthrough](https://usecns.dev/tutorial-axon/), that rule is that retrying an invoice must reuse its original idempotency key.

With Axon installed, `axon index --full --json` builds a local structural index. A coding-agent seat and memory mounts can help later; they are not prerequisites for this first step.

## 2. Retrieve: where does the behavior live?

Use `axon search processInvoice --json` to locate the implementation, then `axon trace processInvoice --direction incoming --json` to find callers. Open the returned source locations rather than treating the graph as the final answer.

If the project already uses Engram, recall relevant decisions too. Remote semantic search is optional; the introductory Axon example uses local structure only.

## 3. Execute: make and test a small change

Edit the relevant code, run the project's tests, and inspect the diff. These remain ordinary development tasks; CNS is not a replacement for the language's test runner.

The example uses `node --test`. A passing test answers its particular assertion, not whether every downstream consumer is safe. Thalamus and Cortex can support model-assisted work later, but neither is needed to make this local change.

## 4. Close out: which project rules need review?

Axon's `delta` describes the changed code and its bounded structural reach. Soma's `concerns check` identifies project rules that the change touches. [Add a first Soma rule](https://usecns.dev/tutorial-soma/) to see a shadow concern report a match without pretending that it is already an enforced gate.

Once a rule has been evaluated and promoted, [make it a gate](https://usecns.dev/tutorial-soma-gate/). A matching active concern is a reason to review, not proof that the code is wrong. Run application tests independently. A requested check that could not run is not a pass.

## 5. Consolidate: leave the next developer a better starting point

Review and commit the change with its tests and any updated project rules. Rebuild stale local evidence when needed. Explain what changed and why so the next developer does not have to rediscover the same constraint.

Engram can retain selected lessons across sessions when you add it. For the first walkthrough, Git history and the authored Soma concern are enough.