Airlock

 view release on metacpan or  search on metacpan

docs/superpowers/plans/2026-10-02-airlock-phase-1.md  view on Meta::CPAN

    store            => AirlockExample::StoreDBI->new( dbh => sub { $dbh } )->as_subs,
    now              => sub { $clock }
  );
  my $start = $airlock->open( client_id => 'cli', scope => 'read' )->data;
  is( $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->status, 'authorization_pending', 'pending' );
  ok( $airlock->approve( $start->{user_code}, subject => { id => 'alice', amr => [qw( pwd otp )] } )->ok, 'approved' );
  $clock += 5;
  my $token = $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->data->{access_token};
  is_deeply( $airlock->verify_token($token)->{amr}, [qw( pwd otp )], 'the token verifies from the database' );
  is( $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->status, 'invalid_grant', 'redeemed once' );
  my ( $secrets ) = $dbh->selectrow_array( 'SELECT COUNT(*) FROM airlock WHERE hash IN (?, ?)', undef, $start->{device_code}, $token );
  is( $secrets, 0, 'neither the device code nor the token is in the table' );
  $clock += 4000;
  is( $airlock->purge, 2, 'purge removes request and token' );
};

done_testing;
```

`t/81-example-store-dbio.t`:

docs/superpowers/plans/2026-10-02-airlock-phase-1.md  view on Meta::CPAN

    'INSERT INTO '.$self->table.' ('.join( ', ', @fields ).') VALUES ('.join( ', ', ('?') x @fields ).')',
    undef, @{$row}{@fields}
  );
  return 1;
}

sub find {
  my ( $self, $field, $value ) = @_;
  croak __PACKAGE__.'->find by '.$field.' is not supported' unless $field eq 'hash' || $field eq 'user_code';
  return unless defined $value;
  return $self->_dbh->selectrow_hashref(
    'SELECT '.join( ', ', $self->_fields ).' FROM '.$self->table.' WHERE '.$field.' = ?', undef, $value
  );
}

# The WHERE on the old state is the whole point: of two concurrent redeems
# only one statement changes a row.
sub update {
  my ( $self, $hash, $from_state, $changes ) = @_;
  my %known  = map { $_ => 1 } $self->_fields;
  my @fields = sort keys %$changes;

examples/lib/AirlockExample/StoreDBI.pm  view on Meta::CPAN

    'INSERT INTO '.$self->table.' ('.join( ', ', @fields ).') VALUES ('.join( ', ', ('?') x @fields ).')',
    undef, @{$row}{@fields}
  );
  return 1;
}

sub find {
  my ( $self, $field, $value ) = @_;
  croak __PACKAGE__.'->find by '.$field.' is not supported' unless $field eq 'hash' || $field eq 'user_code';
  return unless defined $value;
  return $self->_dbh->selectrow_hashref(
    'SELECT '.join( ', ', $self->_fields ).' FROM '.$self->table.' WHERE '.$field.' = ?', undef, $value
  );
}

# The WHERE on the old state is the whole point: of two concurrent redeems
# only one statement changes a row.
sub update {
  my ( $self, $hash, $from_state, $changes ) = @_;
  my %known  = map { $_ => 1 } $self->_fields;
  my @fields = sort keys %$changes;

misc/agent-context/.claude/skills/kanban-issues-karr-coordination/SKILL.md  view on Meta::CPAN

bodies) a card is `k12`, never `#12` — the forge resolves `#12` against its
own issue 12. Commands take `k12` as well as `12`.

## Name yourself once

```bash
export KARR_CLAIM=$(karr agent-name)     # the checkout's directory name, e.g. "karr"
```

Claims are matched by name: `--claim` stamps it, `handoff` checks it,
`list --claimed-by` selects on it. Export `KARR_CLAIM` once per session and
leave `--claim` off: `pick`, `handoff` and `list --claimed-by` default to it,
and `move` and `edit` know a card you hold by it. `create`, `move` and `edit`
write it onto a card only when the card ends up in a `require_claim` column:
filing a card, promoting it to `todo` or adding a note leaves it free.
`archive` and `delete` ignore it — a card you hold needs `--claim NAME` there.
An explicit `--claim NAME` still wins. Agents in separate worktrees already
differ by name; several agents in the **same** directory take
`karr agent-name --unique` (`karr-8fa`).

## Read the board

misc/agent-context/.claude/skills/kanban-issues-karr-coordination/references/claims.md  view on Meta::CPAN

# Claims: pick, handoff, unlock, several agents on one board

## The claim name

Claims are matched by name: `--claim` stamps it, `handoff` and `pick` check
it, `list --claimed-by` and `log --agent` select on it. Every command taking
`--claim` (`create`, `move`, `edit`, `pick`, `handoff`, `delete`, `archive`)
and `list --claimed-by` defaults to `KARR_CLAIM`; an explicit `--claim NAME`
wins over it. `create`, `move` and `edit` are narrower: they take `KARR_CLAIM`
only when the card ends up in a `require_claim` column, so a card filed,
promoted to `todo` or annotated for others stays unclaimed. `edit --release`
never claims. `backlog` holds no claim at all: an explicit `--claim` onto a
backlog card is refused (exit 1, naming `karr move ID todo --claim NAME`), and
moving a card into backlog releases the claim it carried.
karr writes the name nowhere — it is per process, so concurrent agents never
see each other's.

misc/agent-context/.claude/skills/kanban-issues-karr-coordination/references/cross-board.md  view on Meta::CPAN

a directory from `--board NAME=PATH` or from the fleet config, matching the
repository's directory basename.

`--resolve` settles a link whose far card has reached one of the **far**
board's own terminal statuses, and lifts `blocked` when a card's last link
settles, printing the reason it lifted. A far card that does not exist settles
nothing. A board this machine cannot place is reported, not fatal.

Like `depends_on`, a cross-board link blocks nothing by itself: `pick` hands
the card over and says what it waits on. The `blocked` flag is what keeps the
card out of `pick` and out of karr-foundation's selection — the link is the
fact, `blocked` is the decision.

## How it is stored

The links ride in `tags` (`needs:BOARD#ID`, `escalated-from:BOARD#ID`), not
in a frontmatter field of their own: kanban-md marshals a card from its own
struct and would drop an unmodelled key the first time it writes, while `tags`
is modelled on both sides.

t/80-example-store-dbi.t  view on Meta::CPAN

    store            => AirlockExample::StoreDBI->new( dbh => sub { $dbh } )->as_subs,
    now              => sub { $clock }
  );
  my $start = $airlock->open( client_id => 'cli', scope => 'read' )->data;
  is( $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->status, 'authorization_pending', 'pending' );
  ok( $airlock->approve( $start->{user_code}, subject => { id => 'alice', amr => [qw( pwd otp )] } )->ok, 'approved' );
  $clock += 5;
  my $token = $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->data->{access_token};
  is_deeply( $airlock->verify_token($token)->{amr}, [qw( pwd otp )], 'the token verifies from the database' );
  is( $airlock->redeem( device_code => $start->{device_code}, client_id => 'cli' )->status, 'invalid_grant', 'redeemed once' );
  my ( $secrets ) = $dbh->selectrow_array( 'SELECT COUNT(*) FROM airlock WHERE hash IN (?, ?)', undef, $start->{device_code}, $token );
  is( $secrets, 0, 'neither the device code nor the token is in the table' );
  $clock += 4000;
  is( $airlock->purge, 2, 'purge removes request and token' );
};

done_testing;

t/keycloak/k8s.yaml  view on Meta::CPAN

#   ...
#   kubectl delete namespace airlock-test
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  labels:
    app: keycloak
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
        - name: keycloak
          image: quay.io/keycloak/keycloak:26.8.0

t/keycloak/k8s.yaml  view on Meta::CPAN

        - name: realm
          configMap:
            name: airlock-realm
---
apiVersion: v1
kind: Service
metadata:
  name: keycloak
spec:
  type: NodePort
  selector:
    app: keycloak
  ports:
    - name: http
      port: 8080
      targetPort: http



( run in 3.070 seconds using v1.01-cache-2.11-cpan-1bcd28dbaf1 )