KorAP / Kustvakt

:speedboat: User and policy management component for KorAP, capable of rewriting queries for policy based document restrictions.
BSD 2-Clause "Simplified" License
4 stars 3 forks source link

QueryContextRewrite #755

Open margaretha opened 1 month ago

margaretha commented 1 month ago

Maximum token context should be configurable in Kustvakt as described in #745. It should be implemented in Kustvakt as a rewrite that overrides the context when the requested size is larger than the maximum.

Where should the rewrite notes be placed?

  1. Within context

    "meta" : {
    "context" : {
      "left" : [ "token", 40 ],
      "right" : [ "token", 40 ],
      "rewrites" : [ {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "operation" : "operation:override",
        "scope" : "left(60)"
      }, {
        "@type" : "koral:rewrite",
        "src" : "Kustvakt",
        "operation" : "operation:override",
        "scope" : "right(60)"
      } ]
    },
    "tokens" : false,
    "snippets" : true,
    "timeout" : 10000
    }
  2. Within meta

{
  "meta" : {
    "context" : {
      "left" : [ "token", 40 ],
      "right" : [ "token", 40 ]
    },
    "tokens" : false,
    "snippets" : true,
    "timeout" : 10000,
    "rewrites" : [ {
      "@type" : "koral:rewrite",
      "src" : "Kustvakt",
      "operation" : "operation:override",
      "scope" : "context-left(60)"
    }, {
      "@type" : "koral:rewrite",
      "src" : "Kustvakt",
      "operation" : "operation:override",
      "scope" : "context-right(60)"
    } ]
  },
Akron commented 3 days ago

So - the scope always contains the original for operation:override? Wouldn't it then be better to have a rewrite like:

"rewrites" : [ {
  "@type" : "koral:rewrite",
  "src" : "Kustvakt",
  "operation" : "operation:override",
  "scope" : "context",
  "src" : {
    "left": [ "token", 40 ],
    "right" : [ "token", 40 ]
  }
}]

or:

"rewrites" : [ {
  "@type" : "koral:rewrite",
  "src" : "Kustvakt",
  "operation" : "operation:override",
  "scope" : "left",
  "src" : [ "token", 60 ]
}, {
  "@type" : "koral:rewrite",
  "src" : "Kustvakt",
  "operation" : "operation:override",
  "scope" : "right"
  "src" : [ "token", 60 ]
}]

Just scope only makes sense for injections, right? That way it would be possible to "roll back" the rewrite. And actually, both would work, so when the parser would understand the rewrites, it could be easily understand and actually "flatten" the rewrites to the query root.