acting_for 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 416659519f04a4cf5f2639684e6078fe51766cf1eb727ac7b9cde851207d4f9e
4
- data.tar.gz: b976be543b26602045c4f0db0152bbf5e051c028c54f18f70e2aae335f702a9e
3
+ metadata.gz: c2cf10e43b5a53e032b3ed767d98a807a9781e8f02e451782d803b39336da444
4
+ data.tar.gz: 784c28baa1b257fdbc3628ddfa6d2c9609caba77c0785d93c8f4d6ba088bdb44
5
5
  SHA512:
6
- metadata.gz: 5173d14fb39328a07f28957a365a4dbafe845f8dfbc4b2a73045f57f2c69a40ba6f96de9306b21a77d7b16d9cd10b6f136e93567f771bb5c0df0df082f4f11b3
7
- data.tar.gz: 31cb9911b3a8efa9d4a6e54a5c30fb4eff45f15e0f54a1007391727959d37b10503e8da45ff994cd26389d345d51e26651fa3fdc0f46c490f9ae503c91fb2bab
6
+ metadata.gz: fa525cb88236196b3751dfa14b362bed7487a799849288191530af319d47bdf95ad95c2602204332f0b02566a7538b9cc3d9ac2fc3e9b508c6077f1ab534dffa
7
+ data.tar.gz: d9ce75cd4ec4a74e2150aaebb53a6c2da9bdf645c806b3c137136b5bcca7ce69ce83910fcc9640c61d63f0081c92e0a456df7e20505ed75a4388cde0bfe175c1
data/README.md CHANGED
@@ -14,7 +14,15 @@ AI AgentがPrincipalの代理として何をしてよいかを、委任された
14
14
 
15
15
  ## Status
16
16
 
17
- > **Implemented and CI verified; Not released.** The Public API, migrations, models, constraints, automatic Audit persistence, and formal test suite are implemented. CI covers Ruby 3.4 / 4.0, Rails 8.0 / 8.1, and PostgreSQL 16. The runnable setup was verified in a new Rails application in [D230](docs/DECISIONS.md#d230-runnable-quick-start-implementation). ActingFor has not been published to RubyGems.
17
+ > **Released: v0.1.1.** ActingFor 0.1.1 is published on [RubyGems](https://rubygems.org/gems/acting_for) and as [GitHub Release v0.1.1](https://github.com/cuichangquan/acting_for/releases/tag/v0.1.1). It adds `Decision#reason_code` while keeping the existing Decision statuses, Delegation semantics, AuditEvent reason values, and database schema unchanged. CI covers Ruby 3.4 / 4.0, Rails 8.0 / 8.1, and PostgreSQL 16.
18
+
19
+ Next candidate: [0.1.2](docs/release_notes_v0_1_2.md) aligns constraint evaluation with the documented exact Symbol-key Context contract and adds an authorization-to-host-log correlation example. The candidate is not yet published; the released installation instructions below remain on 0.1.1.
20
+
21
+ ## ActingFor at a glance
22
+
23
+ ![ActingFor overview: Principal, Delegation, Agent, authorization decisions, AuditEvent, and Rails Host Application](docs/images/acting_for_overview.svg)
24
+
25
+ The diagram summarizes the v0.1 responsibility boundary: the Host authenticates/resolves the Agent and Principal and establishes trusted business data; ActingFor evaluates the Delegation and returns `allow`, `deny`, or `require_approval`. Approval workflow and business execution remain Host responsibilities.
18
26
 
19
27
  ## Why ActingFor?
20
28
 
@@ -168,19 +176,22 @@ decision = ActingFor.authorize(
168
176
  context: { amount: product.price }
169
177
  )
170
178
 
179
+ decision.status # => :allow
171
180
  decision.allowed? # => true when product.price is 8_900
181
+
182
+ decision.reason_code # => :delegation_allowed
172
183
  ```
173
184
 
174
- Both calls use the implemented [v0.1 Public API](docs/public_api_v0_1.md). Context values that affect authorization must be established by the host, not trusted directly from an Agent request.
185
+ The released 0.1.0 contract remains documented in the [v0.1 Public API](docs/public_api_v0_1.md). The [0.1.1 `Decision#reason_code` API note](docs/decision_reason_code.md) documents the final-reason accessor added in 0.1.1. Context values that affect authorization must be established by the host, not trusted directly from an Agent request.
175
186
 
176
187
  ## Quick Start
177
188
 
178
- ActingFor is not yet published to RubyGems. This pre-release setup installs the public GitHub `main` branch.
189
+ Install the released `0.1.1` gem from RubyGems.
179
190
 
180
191
  1. Add the Gem and install dependencies:
181
192
 
182
193
  ```ruby
183
- gem "acting_for", github: "cuichangquan/acting_for", branch: "main"
194
+ gem "acting_for", "~> 0.1.1"
184
195
  # Rails 8.0 uses JSON options removed in JSON 3.
185
196
  gem "json", "< 3"
186
197
  ```
@@ -240,7 +251,7 @@ ActingFor is not yet published to RubyGems. This pre-release setup installs the
240
251
  # => [:allow, true, false, false]
241
252
  ```
242
253
 
243
- For the complete runnable setup—including a new Rails application, public GitHub pre-release installation, host models, all three `¥8,900 / ¥20,000 / ¥50,000` outcomes, Audit behavior, and production security guidance—see [Getting Started](docs/getting_started.md).
254
+ For the complete runnable setup—including a new Rails application, RubyGems installation, host models, all three `¥8,900 / ¥20,000 / ¥50,000` outcomes, Audit behavior, and production security guidance—see [Getting Started](docs/getting_started.md).
244
255
 
245
256
  ## How does an external AI Agent reach ActingFor?
246
257
 
@@ -446,11 +457,15 @@ ActingFor is not an authentication provider, OAuth/OIDC server, Agent framework,
446
457
  Project documents are maintained primarily in Japanese:
447
458
 
448
459
  - [Getting Started](docs/getting_started.md)
460
+ - [Release Runbook](docs/release_runbook.md)
461
+ - [v0.1.0 Release Process and Verification Record](docs/release_process_v0_1_0.md)
462
+ - [v0.1.0 Release Notes](docs/release_notes_v0_1_0.md)
449
463
  - [Current State](docs/CURRENT_STATE.md)
450
464
  - [Progress](docs/PROGRESS.md)
451
465
  - [Project scope, roadmap, and terminology](docs/PROJECT.md)
452
466
  - [Decisions and rationale](docs/DECISIONS.md)
453
467
  - [v0.1 Public API](docs/public_api_v0_1.md)
468
+ - [Decision reason_code API](docs/decision_reason_code.md)
454
469
  - [v0.1 Security Model](docs/security_model_v0_1.md)
455
470
  - [v0.1 Domain Model](docs/domain_model_v0_1.md)
456
471
  - [v0.1 Gem Structure](docs/gem_structure_v0_1.md)
@@ -158,7 +158,7 @@ module ActingFor
158
158
  resource_type: resource_type,
159
159
  resource_id: resource_id,
160
160
  decision: decision_value,
161
- reason_code: ActingFor::AuditEvent::DECISION_REASONS.fetch(decision_value),
161
+ reason_code: decision.reason_code.to_s,
162
162
  matched_delegation_ids: matches.map(&:id).sort,
163
163
  sanitized_context: sanitized_context
164
164
  }
@@ -18,7 +18,7 @@ module ActingFor
18
18
 
19
19
  field = constraint["field"]
20
20
  key = field.to_sym
21
- return false unless context.key?(key)
21
+ return false unless exact_symbol_key?(context, key)
22
22
 
23
23
  actual = context[key]
24
24
  return false if actual.nil?
@@ -45,6 +45,10 @@ module ActingFor
45
45
  end
46
46
  end
47
47
 
48
+ def exact_symbol_key?(context, key)
49
+ context.each_key.any? { |existing_key| existing_key.is_a?(Symbol) && existing_key == key }
50
+ end
51
+
48
52
  def canonical_constraint?(constraint)
49
53
  return false unless constraint.is_a?(Hash)
50
54
  return false unless constraint.keys.all?(String)
@@ -1,14 +1,20 @@
1
1
  module ActingFor
2
2
  class Decision
3
3
  STATUSES = %i[allow deny require_approval].freeze
4
- private_constant :STATUSES
4
+ REASON_CODES = {
5
+ allow: :delegation_allowed,
6
+ deny: :no_matching_delegation,
7
+ require_approval: :delegation_requires_approval
8
+ }.freeze
9
+ private_constant :STATUSES, :REASON_CODES
5
10
 
6
- attr_reader :status
11
+ attr_reader :status, :reason_code
7
12
 
8
13
  def initialize(status)
9
14
  raise ArgumentError, "invalid decision status" unless STATUSES.include?(status)
10
15
 
11
16
  @status = status
17
+ @reason_code = REASON_CODES.fetch(status)
12
18
  freeze
13
19
  end
14
20
 
@@ -1,3 +1,3 @@
1
1
  module ActingFor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acting_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChangQuan Cui
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-11-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rubocop