# crafting/actions
Documentation: 0.6.0 (source: v0.6.0).

Markdown source of https://docs-v0-6-0.atlas-kit-docs.pages.dev/reference/crafting/actions/ — see https://docs-v0-6-0.atlas-kit-docs.pages.dev/ai/ for the full machine-readable surface.

## Interfaces

<a id="craftingfeerate"></a>

### CraftingFeeRate

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:20](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L20)

The crafting fee rate a batch started now at a Starbase would pay, as the
program resolves it, with the accounts and slot it was read from.

#### Example

```ts
declare const rate: CraftingFeeRate;
console.log(rate.craftingFeeBasisPoints, rate.source);
```

#### Properties

<a id="accounts"></a>

##### accounts

```ts
readonly accounts: {
  democracyHistory: Address;
  democracyHistoryGeneration?: Address;
  democracyHistoryPolicy?: Address;
  starbaseGovernance: Address;
};
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:36](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L36)

###### democracyHistory

```ts
readonly democracyHistory: Address;
```

###### democracyHistoryGeneration?

```ts
readonly optional democracyHistoryGeneration?: Address;
```

###### democracyHistoryPolicy?

```ts
readonly optional democracyHistoryPolicy?: Address;
```

###### starbaseGovernance

```ts
readonly starbaseGovernance: Address;
```

<a id="craftingfeebasispoints"></a>

##### craftingFeeBasisPoints

```ts
readonly craftingFeeBasisPoints: number;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:25](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L25)

Basis points applied to the Recipe fee: 10,000 leaves it unchanged.

<a id="slot"></a>

##### slot

```ts
readonly slot: bigint;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:43](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L43)

Confirmed slot of the Democracy history read.

<a id="source"></a>

##### source

```ts
readonly source: 
  | "default"
  | "governance"
  | "history-policy"
  | "history-generation"
  | "history-disabled";
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:30](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L30)

`default`: no governance or daily Democracy history, so 10,000.
`governance`: the Starbase's enabled governance parameters.
`history-policy`, `history-generation` and `history-disabled`: the
effective parameters of the System's daily Democracy history.

<a id="starbasesequenceid"></a>

##### starbaseSequenceId

```ts
readonly starbaseSequenceId: bigint;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:23](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L23)

The Starbase generation the rate applies to.

<a id="system"></a>

##### system

```ts
readonly system: Address;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:21](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L21)

#### Methods

<a id="tojson"></a>

##### toJSON()

```ts
toJSON(): unknown;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:44](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L44)

###### Returns

`unknown`

***

<a id="plancancelcraftingprocessoptions"></a>

### PlanCancelCraftingProcessOptions

Defined in: [packages/sage/src/crafting/actions/index.ts:143](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L143)

Inputs for cancelling one Crafting Process.

Cancellation has no timing rule, so it takes no timestamp. Final inventory
capacity, permissions, input and crew returns, and account closure remain
chain-authoritative.

#### Example

```ts
declare const authorization: PlanAuthorization;
const options: PlanCancelCraftingProcessOptions = { authorization };
```

#### Properties

<a id="authorization"></a>

##### authorization

```ts
readonly authorization: PlanAuthorization;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:144](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L144)

***

<a id="plancompletecraftingprocessoptions"></a>

### PlanCompleteCraftingProcessOptions

Defined in: [packages/sage/src/crafting/actions/index.ts:126](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L126)

Inputs for completing one Crafting Process.

`atUnixSeconds` is an explicit non-negative Unix timestamp used only for the
deterministic local lifecycle check. Final permission, freshness, output
capacity, XP, and account closure remain chain-authoritative.

#### Example

```ts
declare const authorization: PlanAuthorization;
const options: PlanCompleteCraftingProcessOptions = {
  authorization,
  atUnixSeconds: 1_700_004_000n,
};
```

#### Properties

<a id="atunixseconds"></a>

##### atUnixSeconds

```ts
readonly atUnixSeconds: bigint;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:128](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L128)

<a id="authorization-1"></a>

##### authorization

```ts
readonly authorization: PlanAuthorization;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:127](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L127)

***

<a id="planstartcraftingprocessoptions"></a>

### PlanStartCraftingProcessOptions

Defined in: [packages/sage/src/crafting/actions/index.ts:101](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L101)

Inputs for starting one exact Crafting Process.

`quantity` is a positive raw unsigned-u64 integer. `numCrew` is the exact
crew count requested by the instruction, at least 1 and within unsigned u32.
With a Crafting Hab the job reserves `numCrew` scaled by the Hab's
crew-count modifier, rounded up, from the Starbase Player's available crew. `craftingProcess` is
the address of a new caller-created signer; planning retains only its address.
Supply `craftingHab` when the Recipe requires or should use Hab production.
Recipe inputs are always taken from the Starbase Player's Starbase cargo,
with or without a Hab; the Hab contributes production and modifiers only.

#### Example

```ts
declare const authorization: PlanAuthorization;
declare const craftingProcess: Address;
const options: PlanStartCraftingProcessOptions = {
  authorization,
  craftingProcess,
  quantity: 2n,
  numCrew: 6,
};
```

#### Properties

<a id="authorization-2"></a>

##### authorization

```ts
readonly authorization: PlanAuthorization;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:102](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L102)

<a id="craftinghab"></a>

##### craftingHab?

```ts
readonly optional craftingHab?: CraftingHabSnapshot;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:106](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L106)

<a id="craftingprocess"></a>

##### craftingProcess

```ts
readonly craftingProcess: Address;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:103](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L103)

<a id="numcrew"></a>

##### numCrew

```ts
readonly numCrew: number;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:105](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L105)

<a id="quantity"></a>

##### quantity

```ts
readonly quantity: bigint;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:104](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L104)

## Functions

<a id="getcraftingfeerate"></a>

### getCraftingFeeRate()

```ts
function getCraftingFeeRate(ctx, system): Promise<CraftingFeeRate>;
```

Defined in: [packages/sage/src/crafting/actions/fee-rate.ts:62](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/fee-rate.ts#L62)

Reads the crafting fee rate a batch started now at a Starbase would pay,
resolved as the start Plan resolves it: the System's daily Democracy history
when initialized, else enabled Starbase governance, else 10,000 basis
points. Pass `craftingFeeBasisPoints` to `deriveCraftingBatchEstimate`.

Read-only: nothing is created or funded. The rate can change when the chain
day or the governance policy changes before a batch starts; an existing
Process keeps the rate it recorded when it started.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `ctx` | [`SageContext`](/reference/#sagecontext) |
| `system` | [`Address`](/reference/#address-20) |

#### Returns

`Promise`\<[`CraftingFeeRate`](/reference/crafting/actions/#craftingfeerate)\>

#### Example

```ts
declare const ctx: SageContext, system: Address;
const rate = await getCraftingFeeRate(ctx, system);
console.log(rate.craftingFeeBasisPoints, rate.source, rate.slot);
```

***

<a id="plancancelcraftingprocess"></a>

### planCancelCraftingProcess()

```ts
function planCancelCraftingProcess(
   ctx, 
   process, 
input): Promise<Plan>;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:1151](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L1151)

Plans cancellation of one Crafting Process without signing or writes.

The planner resolves and validates the Process account graph, requires Profile
ownership, and rejects a Process whose Starbase was destroyed. Cancellation
has no timing rule: a finished Process can still be cancelled, which returns
its inputs and crew instead of producing outputs. A Process Hab is passed by
its stored address in whatever state it is in, or even if it no longer
exists. Final inventory capacity, permissions, returned inputs and crew, and
account closure remain chain-authoritative.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `ctx` | [`SageContext`](/reference/#sagecontext) |
| `process` | [`CraftingProcessSnapshot`](/reference/crafting/#craftingprocesssnapshot) |
| `input` | [`PlanCancelCraftingProcessOptions`](/reference/crafting/actions/#plancancelcraftingprocessoptions) |

#### Returns

`Promise`\<[`Plan`](/reference/planning/#plan)\>

#### Example

```ts
declare const ctx: SageContext;
declare const process: CraftingProcessSnapshot;
declare const options: PlanCancelCraftingProcessOptions;
const plan = await planCancelCraftingProcess(ctx, process, options);
console.log(plan.describe());
```

***

<a id="plancompletecraftingprocess"></a>

### planCompleteCraftingProcess()

```ts
function planCompleteCraftingProcess(
   ctx, 
   process, 
input): Promise<Plan>;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:1048](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L1048)

Plans completion of one Crafting Process without signing, simulation, or writes.

The planner resolves and validates the Process account graph, requires Profile
ownership, and checks the translated lifecycle at the caller-provided Unix
timestamp. Output capacity, permissions, XP, closure, and final execution
freshness remain chain-authoritative.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `ctx` | [`SageContext`](/reference/#sagecontext) |
| `process` | [`CraftingProcessSnapshot`](/reference/crafting/#craftingprocesssnapshot) |
| `input` | [`PlanCompleteCraftingProcessOptions`](/reference/crafting/actions/#plancompletecraftingprocessoptions) |

#### Returns

`Promise`\<[`Plan`](/reference/planning/#plan)\>

#### Example

```ts
declare const ctx: SageContext;
declare const process: CraftingProcessSnapshot;
declare const options: PlanCompleteCraftingProcessOptions;
const plan = await planCompleteCraftingProcess(ctx, process, options);
console.log(plan.describe());
```

***

<a id="planstartcraftingprocess"></a>

### planStartCraftingProcess()

```ts
function planStartCraftingProcess(
   ctx, 
   recipe, 
   player, 
input): Promise<Plan>;
```

Defined in: [packages/sage/src/crafting/actions/index.ts:544](https://github.com/Aephia/atlas-kit/blob/v0.6.0/packages/sage/src/crafting/actions/index.ts#L544)

Plans one Crafting Process start without signing, simulation, or writes.

The planner validates the loaded Recipe and Starbase Player, optional Hab,
known ingredient balances, the crew the job reserves, the Hab job limit
including the Character's research concurrency bonus, and exact
whole-account state. The ATLAS fee and any crew-roster bonuses remain
chain-authoritative. It returns one inert Plan whose two required signer
roles are bound only during execution.

Each start consumes exactly one Recipe use, whatever its quantity, and needs
the Recipe's fresh `usageCountRaw` to be below `usageLimitRaw`. A stored
limit of `0n` is therefore never usable. Cancelling or destroying a process
returns its use. See `docs/evidence/crafting-zero-usage-limit.md`.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `ctx` | [`SageContext`](/reference/#sagecontext) |
| `recipe` | [`RecipeSnapshot`](/reference/crafting/#recipesnapshot) |
| `player` | `StarbasePlayerSnapshot` |
| `input` | [`PlanStartCraftingProcessOptions`](/reference/crafting/actions/#planstartcraftingprocessoptions) |

#### Returns

`Promise`\<[`Plan`](/reference/planning/#plan)\>

#### Example

```ts
declare const ctx: SageContext;
declare const recipe: RecipeSnapshot;
declare const player: StarbasePlayerSnapshot;
declare const options: PlanStartCraftingProcessOptions;
const plan = await planStartCraftingProcess(ctx, recipe, player, options);
console.log(plan.describe());
```

## References

<a id="planauthorization"></a>

### PlanAuthorization

Re-exports [PlanAuthorization](/reference/cargo/actions/#planauthorization)
